Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.7.4 fix #243

Merged
merged 2 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 8 additions & 12 deletions c-pallets/audit/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ pallet-cess-staking = { path = '../staking', version = '4.0.0-dev', default-feat
pallet-preimage = { version = "4.0.0-dev", default-features = false, git = 'https://github.com/CESSProject/substrate', branch = "cess-polkadot-v0.9.42" }

# local pallet
cp-bloom-filter = { path = '../../primitives/bloom-filter', version = '0.1.0', default-features = false }
cp-scheduler-credit = { path = '../../primitives/scheduler-credit', version = '0.1.0', default-features = false }
cp-cess-common = { path = '../../primitives/common', version = '0.1.0', default-features = false }
cp-enclave-verify = { path = '../../primitives/enclave-verify', version = '0.1.0', default-features = false }
pallet-sminer-reward = { default-features = false, path = "../sminer-reward", version = "0.7.4" }
cp-bloom-filter = { path = '../../primitives/bloom-filter', default-features = false }
cp-scheduler-credit = { path = '../../primitives/scheduler-credit', default-features = false }
cp-cess-common = { path = '../../primitives/common', default-features = false }
cp-enclave-verify = { path = '../../primitives/enclave-verify', default-features = false }
pallet-sminer-reward = { default-features = false, path = "../sminer-reward" }

[dependencies.frame-benchmarking]
default-features = false
Expand Down Expand Up @@ -84,25 +84,21 @@ version = '7.0.0'
[dependencies.pallet-file-bank]
default-features = false
path = '../file-bank'
version = '0.7.0'

# local dependencies
[dependencies.pallet-sminer]
default-features = false
path = '../sminer'
version = '0.7.0'

# local dependencies
[dependencies.pallet-tee-worker]
default-features = false
path = '../tee-worker'
version = '0.7.0'

# local dependencies
[dependencies.pallet-storage-handler]
default-features = false
path = '../storage-handler'
version = '0.7.0'

[dev-dependencies.frame-support-test]
default-features = false
Expand All @@ -129,9 +125,9 @@ sp-npos-elections = { version = "4.0.0-dev", git = "https://github.com/CESSProje
frame-election-provider-support = { version = "4.0.0-dev", default-features = false, git = "https://github.com/CESSProject/substrate", branch = "cess-polkadot-v0.9.42" }
pallet-session = { version = "4.0.0-dev", default-features = false, git = "https://github.com/CESSProject/substrate", branch = "cess-polkadot-v0.9.42" }
pallet-bags-list = { version = "4.0.0-dev", git = "https://github.com/CESSProject/substrate", branch = "cess-polkadot-v0.9.42" }
pallet-scheduler-credit = { version = "0.1.0", default-features = false, path = '../scheduler-credit'}
cp-cess-common = { path = '../../primitives/common', version = '0.1.0', default-features = false }
pallet-oss = { path = '../oss', version = '0.7.0', default-features = false }
pallet-scheduler-credit = { default-features = false, path = '../scheduler-credit'}
cp-cess-common = { path = '../../primitives/common', default-features = false }
pallet-oss = { path = '../oss', default-features = false }

[features]
default = ["std"]
Expand Down
2 changes: 1 addition & 1 deletion c-pallets/audit/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pub(super) const IDLE_PROVE_RATE: u128 = 71_582_788;

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

pub(super) const IDLE_FAULT_TOLERANT: u8 = 2;
// pub(super) const IDLE_FAULT_TOLERANT: u8 = 2;

pub(super) const SERVICE_FAULT_TOLERANT: u8 = 2;

Expand Down
66 changes: 40 additions & 26 deletions c-pallets/audit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ use sp_std::{
convert:: { TryFrom, TryInto },
prelude::*,
};
use cp_cess_common::*;
pub use weights::WeightInfo;

type AccountOf<T> = <T as frame_system::Config>::AccountId;
Expand Down Expand Up @@ -372,6 +371,10 @@ pub mod pallet {
#[pallet::storage]
#[pallet::getter(fn verify_slip)]
pub(super) type VerifySlip<T: Config> = StorageDoubleMap<_, Blake2_128Concat, BlockNumberOf<T>, Blake2_128Concat, AccountOf<T>, bool>;
// FOR TEST
#[pallet::storage]
#[pallet::getter(fn test_option_storage)]
pub(super) type TestOptionStorageV2<T: Config> = StorageMap<_, Blake2_128Concat, u32, ProveInfo<T>>;

#[pallet::pallet]
#[pallet::storage_version(STORAGE_VERSION)]
Expand Down Expand Up @@ -642,15 +645,26 @@ pub mod pallet {
Ok(())
})
}

// FOR TEST
#[pallet::call_index(7)]
#[transactional]
#[pallet::weight(100_000_000)]
#[pallet::weight(Weight::zero())]
pub fn update_counted_clear(origin: OriginFor<T>, miner: AccountOf<T>) -> DispatchResult {
let _ = ensure_root(origin)?;

<CountedClear<T>>::insert(&miner, 0);

Ok(())
}
// FOR TEST
#[pallet::call_index(8)]
#[transactional]
#[pallet::weight(Weight::zero())]
pub fn test_insert_option(origin: OriginFor<T>, key: u32, value: ProveInfo<T> ) -> DispatchResult {
let _sender = ensure_signed(origin)?;

TestOptionStorageV2::insert(key, value);

Ok(())
}
}
Expand All @@ -663,33 +677,33 @@ pub mod pallet {
if let Ok(challenge_info) = <ChallengeSnapShot<T>>::try_get(&miner) {
weight = weight.saturating_add(T::DbWeight::get().reads(1));
if challenge_info.prove_info.service_prove.is_none() {
let count = <CountedClear<T>>::get(&miner).checked_add(1).unwrap_or(6);
weight = weight.saturating_add(T::DbWeight::get().reads(1));
let count = <CountedClear<T>>::get(&miner).checked_add(1).unwrap_or(6);
weight = weight.saturating_add(T::DbWeight::get().reads(1));

let _ = T::MinerControl::clear_punish(
let _ = T::MinerControl::clear_punish(
&miner,
count,
challenge_info.miner_snapshot.idle_space,
challenge_info.miner_snapshot.service_space
);
weight = weight.saturating_add(T::DbWeight::get().reads_writes(1, 1));
//For Testing
if count >= 6 {
let result = T::MinerControl::force_miner_exit(&miner);
weight = weight.saturating_add(T::DbWeight::get().reads_writes(5, 5));
if result.is_err() {
log::info!("force clear miner: {:?} failed", miner);
}
<CountedClear<T>>::remove(&miner);
weight = weight.saturating_add(T::DbWeight::get().writes(1));
} else {
<CountedClear<T>>::insert(
&miner,
count,
challenge_info.miner_snapshot.idle_space,
challenge_info.miner_snapshot.service_space
count,
);
weight = weight.saturating_add(T::DbWeight::get().reads_writes(1, 1));
//For Testing
if count >= 6 {
let result = T::MinerControl::force_miner_exit(&miner);
weight = weight.saturating_add(T::DbWeight::get().reads_writes(5, 5));
if result.is_err() {
log::info!("force clear miner: {:?} failed", miner);
}
<CountedClear<T>>::remove(&miner);
weight = weight.saturating_add(T::DbWeight::get().writes(1));
} else {
<CountedClear<T>>::insert(
&miner,
count,
);
weight = weight.saturating_add(T::DbWeight::get().writes(1));
}
weight = weight.saturating_add(T::DbWeight::get().writes(1));
}
}
}

<ChallengeSlip<T>>::remove(&now, &miner);
Expand Down
4 changes: 3 additions & 1 deletion c-pallets/cacher/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ sp-std = { version = "5.0.0", default-features = false, git = "https://github.co
sp-runtime = { version = "7.0.0", default-features = false, git = "https://github.com/CESSProject/substrate", branch = "cess-polkadot-v0.9.42" }
frame-support = { version = "4.0.0-dev", default-features = false, git = "https://github.com/CESSProject/substrate", branch = "cess-polkadot-v0.9.42" }
frame-system = { version = "4.0.0-dev", default-features = false, git = "https://github.com/CESSProject/substrate", branch = "cess-polkadot-v0.9.42" }
cp-cess-common = { path = '../../primitives/common', version = '0.1.0', default-features = false }
frame-benchmarking = { version = '4.0.0-dev', default-features = false, git = 'https://github.com/CESSProject/substrate', branch = 'cess-polkadot-v0.9.42', optional = true}

#local dependencies
cp-cess-common = { path = '../../primitives/common', default-features = false }

[dev-dependencies]
sp-core = {version = '7.0.0', git = 'https://github.com/CESSProject/substrate', default-features = false, branch = 'cess-polkadot-v0.9.42'}
pallet-balances = { version = "4.0.0-dev", git = "https://github.com/CESSProject/substrate", branch = "cess-polkadot-v0.9.42" }
Expand Down
21 changes: 5 additions & 16 deletions c-pallets/file-bank/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ pallet-grandpa = { version = "4.0.0-dev", default-features = false, git = "https
pallet-scheduler = { version = '4.0.0-dev', git = 'https://github.com/CESSProject/substrate', branch = "cess-polkadot-v0.9.42", default-features = false }
# sc-network = { version = "0.10.0-dev", git = "https://github.com/CESSProject/substrate", branch = "cess-polkadot-v0.9.42" }

# local dependencies
pallet-sminer = { default-features = false, path = '../sminer' }
pallet-tee-worker = { default-features = false, path = '../tee-worker' }
pallet-storage-handler = { default-features = false, path = '../storage-handler' }

[dependencies.frame-benchmarking]
default-features = false
git = 'https://github.com/CESSProject/substrate'
Expand Down Expand Up @@ -80,22 +85,6 @@ git = 'https://github.com/CESSProject/substrate'
branch = "cess-polkadot-v0.9.42"
version = '7.0.0'

# local dependencies
[dependencies.pallet-sminer]
default-features = false
path = '../sminer'
version = '0.7.0'

[dependencies.pallet-tee-worker]
default-features = false
path = '../tee-worker'
version = '0.7.0'

[dependencies.pallet-storage-handler]
default-features = false
path = '../storage-handler'
version = '0.7.0'

# dev dependencies
[dev-dependencies]
pallet-cess-staking = { path = '../staking', version = '4.0.0-dev', default-features = false}
Expand Down
4 changes: 2 additions & 2 deletions c-pallets/file-bank/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1085,10 +1085,10 @@ pub mod pallet {

Ok(())
}

// FOR TEST
#[pallet::call_index(20)]
#[transactional]
#[pallet::weight(10_000_000_000)]
#[pallet::weight(Weight::zero())]
pub fn root_clear_failed_count(origin: OriginFor<T>) -> DispatchResult {
let _ = ensure_root(origin)?;

Expand Down
4 changes: 3 additions & 1 deletion c-pallets/oss/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ sp-std = { version = "5.0.0", default-features = false, git = "https://github.co
sp-runtime = { version = "7.0.0", default-features = false, git = "https://github.com/CESSProject/substrate", branch = "cess-polkadot-v0.9.42" }
frame-support = { version = "4.0.0-dev", default-features = false, git = "https://github.com/CESSProject/substrate", branch = "cess-polkadot-v0.9.42" }
frame-system = { version = "4.0.0-dev", default-features = false, git = "https://github.com/CESSProject/substrate", branch = "cess-polkadot-v0.9.42" }
cp-cess-common = { path = '../../primitives/common', version = '0.1.0', default-features = false }
frame-benchmarking = { version = '4.0.0-dev', default-features = false, git = 'https://github.com/CESSProject/substrate', branch = "cess-polkadot-v0.9.42", optional = true}

#local dependencies
cp-cess-common = { path = '../../primitives/common', default-features = false }

[dev-dependencies]
sp-core = {version = '7.0.0', git = 'https://github.com/CESSProject/substrate', default-features = false, branch = "cess-polkadot-v0.9.42"}
pallet-balances = { version = "4.0.0-dev", git = "https://github.com/CESSProject/substrate", branch = "cess-polkadot-v0.9.42" }
Expand Down
3 changes: 2 additions & 1 deletion c-pallets/scheduler-credit/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ sp-runtime = { version = "7.0.0", default-features = false, git = "https://githu
frame-support = { version = "4.0.0-dev", default-features = false, git = "https://github.com/CESSProject/substrate", branch = "cess-polkadot-v0.9.42" }
frame-system = { version = "4.0.0-dev", default-features = false, git = "https://github.com/CESSProject/substrate", branch = "cess-polkadot-v0.9.42" }

cp-scheduler-credit = { version = "0.1.0", default-features = false, path = '../../primitives/scheduler-credit' }
#lock dependencies
cp-scheduler-credit = { default-features = false, path = '../../primitives/scheduler-credit' }

[dev-dependencies]
sp-io = { version = "7.0.0", default-features = false, git = "https://github.com/CESSProject/substrate", branch = "cess-polkadot-v0.9.42" }
Expand Down
2 changes: 0 additions & 2 deletions c-pallets/sminer-reward/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ use frame_support::{
dispatch::{DispatchResult},
pallet_prelude::{StorageValue, ValueQuery},
};
use codec::{Decode, Encode};
use scale_info::TypeInfo;
// use sp_std::prelude::*;
use sp_runtime::{
SaturatedConversion,
Expand Down
15 changes: 8 additions & 7 deletions c-pallets/sminer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,17 @@ serde = { version = "1.0.136", optional = true }
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] }
scale-info = { default-features = false, features = ['derive'], version = "2.0.1" }
rand_chacha = { version = "0.2", default-features = false, optional = true }
cp-cess-common = { path = '../../primitives/common', version = '0.1.0', default-features = false }
pallet-preimage = { version = "4.0.0-dev", default-features = false, git = 'https://github.com/CESSProject/substrate', branch = "cess-polkadot-v0.9.42" }
cp-enclave-verify = { path = '../../primitives/enclave-verify', version = '0.1.0', default-features = false }
cp-bloom-filter = { path = '../../primitives/bloom-filter', version = '0.1.0', default-features = false }
pallet-cess-staking = { path = '../staking', version = '4.0.0-dev', default-features = false }


#local crate
pallet-tee-worker = { default-features = false, path = '../tee-worker', version = '0.7.0' }
pallet-storage-handler = { default-features = false, path = '../storage-handler', version = '0.7.0' }
pallet-sminer-reward = { default-features = false, path = "../sminer-reward", version = "0.7.4" }
pallet-tee-worker = { default-features = false, path = '../tee-worker' }
pallet-storage-handler = { default-features = false, path = '../storage-handler' }
pallet-sminer-reward = { default-features = false, path = "../sminer-reward" }
pallet-cess-staking = { default-features = false, path = '../staking' }
cp-enclave-verify = { path = '../../primitives/enclave-verify', default-features = false }
cp-bloom-filter = { path = '../../primitives/bloom-filter', default-features = false }
cp-cess-common = { path = '../../primitives/common', default-features = false }

[dependencies.frame-benchmarking]
default-features = false
Expand Down
3 changes: 2 additions & 1 deletion c-pallets/sminer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,7 @@ pub mod pallet {
///
/// Parameters:
/// - `acc`: Withdraw money account.
/// FOR TEST
#[pallet::call_index(14)]
#[transactional]
#[pallet::weight(35_000_000)]
Expand Down Expand Up @@ -717,7 +718,7 @@ pub mod pallet {
// FOR TESTING
#[pallet::call_index(15)]
#[transactional]
#[pallet::weight(100_000)]
#[pallet::weight(Weight::zero())]
pub fn update_expender(
origin: OriginFor<T>,
k: u64,
Expand Down
4 changes: 2 additions & 2 deletions c-pallets/storage-handler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ sp-runtime = { version = "7.0.0", git = 'https://github.com/CESSProject/substrat
frame-benchmarking = { version = '4.0.0-dev', git = 'https://github.com/CESSProject/substrate', branch = "cess-polkadot-v0.9.42", default-features = false }

# local dependencies
cp-cess-common = { version = '0.1.0', path = '../../primitives/common', default-features = false }
pallet-sminer-reward = { default-features = false, path = "../sminer-reward", version = "0.7.4" }
cp-cess-common = { path = '../../primitives/common', default-features = false }
pallet-sminer-reward = { default-features = false, path = "../sminer-reward" }

[features]
default = ["std"]
Expand Down
8 changes: 4 additions & 4 deletions c-pallets/storage-handler/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,21 +333,21 @@ pub mod pallet {
});
Ok(())
}

// FOR TEST
#[pallet::call_index(4)]
#[transactional]
#[pallet::weight(100_000_000)]
#[pallet::weight(Weight::zero())]
pub fn update_price(origin: OriginFor<T>) -> DispatchResult {
let _ = ensure_root(origin)?;
let default_price: BalanceOf<T> = 30u32.saturated_into();
UnitPrice::<T>::put(default_price);

Ok(())
}

// FOR TEST
#[pallet::call_index(5)]
#[transactional]
#[pallet::weight(100_000_000)]
#[pallet::weight(Weight::zero())]
pub fn update_user_life(origin: OriginFor<T>, user: AccountOf<T>, deadline: BlockNumberOf<T>) -> DispatchResult {
let _ = ensure_root(origin)?;

Expand Down
8 changes: 5 additions & 3 deletions c-pallets/tee-worker/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ codec = { package = "parity-scale-codec", version = "3.0.0", default-features =
scale-info = { default-features = false, features = ['derive'], version = "2.0.1" }
serde_json = { version = '1.0.67', default-features = false, features = ['alloc'] }
log = { version = "0.4.14", default-features = false }
cp-cess-common = { path = '../../primitives/common', version = '0.1.0', default-features = false }
cp-scheduler-credit = { path = '../../primitives/scheduler-credit', version = '0.1.0', default-features = false }
cp-enclave-verify = { path = '../../primitives/enclave-verify', version = '0.1.0', default-features = false }
sp-io = { version = "7.0.0", default-features = false, branch = 'cess-polkadot-v0.9.42', git = 'https://github.com/CESSProject/substrate' }

# local dependencies
cp-cess-common = { path = '../../primitives/common', default-features = false }
cp-scheduler-credit = { path = '../../primitives/scheduler-credit', default-features = false }
cp-enclave-verify = { path = '../../primitives/enclave-verify', default-features = false }

[dependencies.frame-benchmarking]
default-features = false
git = 'https://github.com/CESSProject/substrate'
Expand Down
4 changes: 2 additions & 2 deletions c-pallets/tee-worker/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ pub mod pallet {

#[pallet::call_index(1)]
#[transactional]
#[pallet::weight(100_000_000)]
#[pallet::weight(Weight::zero())]
pub fn update_whitelist(origin: OriginFor<T>, mr_enclave: [u8; 64]) -> DispatchResult {
let _ = ensure_root(origin)?;
<MrEnclaveWhitelist<T>>::mutate(|list| -> DispatchResult {
Expand Down Expand Up @@ -207,7 +207,7 @@ pub mod pallet {
// FOR TESTING
#[pallet::call_index(3)]
#[transactional]
#[pallet::weight(100_000_000)]
#[pallet::weight(Weight::zero())]
pub fn update_podr2_pk(origin: OriginFor<T>, podr2_pbk: Podr2Key) -> DispatchResult {
let _sender = ensure_root(origin)?;

Expand Down
Loading
Loading