Skip to content

Commit

Permalink
adjust idgraph updater origin
Browse files Browse the repository at this point in the history
  • Loading branch information
Kailai-Wang committed Nov 30, 2023
1 parent 96659be commit 0f111e0
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 130 deletions.
3 changes: 1 addition & 2 deletions node/src/chain_specs/litmus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use cumulus_primitives_core::ParaId;
use litmus_parachain_runtime::{
AccountId, AuraId, Balance, BalancesConfig, CollatorSelectionConfig, CouncilMembershipConfig,
GenesisConfig, ParachainInfoConfig, PolkadotXcmConfig, SessionConfig, SystemConfig,
TechnicalCommitteeMembershipConfig, TeerexConfig, VCManagementConfig, UNIT, WASM_BINARY,
TechnicalCommitteeMembershipConfig, TeerexConfig, UNIT, WASM_BINARY,
};
use sc_service::ChainType;
use sc_telemetry::TelemetryEndpoints;
Expand Down Expand Up @@ -238,7 +238,6 @@ fn generate_genesis(
parachain_system: Default::default(),
polkadot_xcm: PolkadotXcmConfig { safe_xcm_version: Some(SAFE_XCM_VERSION) },
teerex: TeerexConfig { allow_sgx_debug_mode: true, admin: None },
vc_management: VCManagementConfig { admin: None },
transaction_payment: Default::default(),
tokens: Default::default(),
}
Expand Down
18 changes: 9 additions & 9 deletions pallets/identity-management/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,15 @@ benchmarks! {
assert_last_event::<T>(Event::ActivateIdentityRequested{ shard }.into());
}

update_idgraph_fingerprint {
let call_origin = T::TEECallOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?;
let account: T::AccountId = frame_benchmarking::account("TEST_A", 0u32, USER_SEED);
let new_fingerprint = H256::default();
}: _<T::RuntimeOrigin>(call_origin, account.clone(), new_fingerprint)
verify {
assert_last_event::<T>(Event::IDGraphFingerprintUpdated { account, new_fingerprint }.into())
}

// Benchmark `identity_linked`. There are no worst conditions. The benchmark showed that
// execution time is constant irrespective of encrypted_data size.
identity_linked {
Expand Down Expand Up @@ -138,15 +147,6 @@ benchmarks! {
verify {
assert_last_event::<T>(Event::LinkIdentityFailed { account: Some(account), detail, req_ext_hash }.into())
}

idgraph_updated {
let call_origin = T::TEECallOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?;
let account: T::AccountId = frame_benchmarking::account("TEST_A", 0u32, USER_SEED);
let new_fingerprint = H256::default();
}: _<T::RuntimeOrigin>(call_origin, account.clone(), new_fingerprint)
verify {
assert_last_event::<T>(Event::IDGraphFingerprintUpdated { account, new_fingerprint }.into())
}
}

#[cfg(test)]
Expand Down
30 changes: 16 additions & 14 deletions pallets/identity-management/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ pub mod pallet {
type DelegateeAdminOrigin: EnsureOrigin<Self::RuntimeOrigin>;
// origin that is allowed to call extrinsics
type ExtrinsicWhitelistOrigin: EnsureOrigin<Self::RuntimeOrigin, Success = Self::AccountId>;
// dedicated origin to update the IDGraph hash
type UpdateIDGraphFingerprintOrigin: EnsureOrigin<Self::RuntimeOrigin>;
}

#[pallet::event]
Expand Down Expand Up @@ -242,6 +244,20 @@ pub mod pallet {
Ok(().into())
}

#[pallet::call_index(6)]
#[pallet::weight(<T as Config>::WeightInfo::update_idgraph_fingerprint())]
pub fn update_idgraph_fingerprint(
origin: OriginFor<T>,
account: T::AccountId,
new_fingerprint: H256,
) -> DispatchResultWithPostInfo {
let _ = T::UpdateIDGraphFingerprintOrigin::ensure_origin(origin)?;
// we don't care if `account` already exists
IDGraphFingerprint::<T>::insert(account.clone(), new_fingerprint);
Self::deposit_event(Event::IDGraphFingerprintUpdated { account, new_fingerprint });
Ok(Pays::No.into())
}

/// ---------------------------------------------------
/// The following extrinsics are supposed to be called by TEE only
/// ---------------------------------------------------
Expand Down Expand Up @@ -312,19 +328,5 @@ pub mod pallet {
}
Ok(Pays::No.into())
}

#[pallet::call_index(35)]
#[pallet::weight(<T as Config>::WeightInfo::idgraph_updated())]
pub fn idgraph_updated(
origin: OriginFor<T>,
account: T::AccountId,
new_fingerprint: H256,
) -> DispatchResultWithPostInfo {
let _ = T::TEECallOrigin::ensure_origin(origin)?;
// we don't care if `account` already exists
IDGraphFingerprint::<T>::insert(account.clone(), new_fingerprint);
Self::deposit_event(Event::IDGraphFingerprintUpdated { account, new_fingerprint });
Ok(Pays::No.into())
}
}
}
116 changes: 58 additions & 58 deletions pallets/identity-management/src/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
//! Autogenerated weights for pallet_identity_management
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2023-11-28, STEPS: `20`, REPEAT: `50`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! DATE: 2023-11-30, STEPS: `20`, REPEAT: `50`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `tee-dev`, CPU: `Intel(R) Xeon(R) E-2274G CPU @ 4.00GHz`
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("rococo-dev"), DB CACHE: 20
Expand Down Expand Up @@ -55,11 +55,11 @@ pub trait WeightInfo {
fn link_identity() -> Weight;
fn deactivate_identity() -> Weight;
fn activate_identity() -> Weight;
fn update_idgraph_fingerprint() -> Weight;
fn identity_linked() -> Weight;
fn identity_deactivated() -> Weight;
fn identity_activated() -> Weight;
fn some_error() -> Weight;
fn idgraph_updated() -> Weight;
}

/// Weights for pallet_identity_management using the Substrate node and recommended hardware.
Expand All @@ -71,8 +71,8 @@ impl<T: frame_system::Config> WeightInfo for LitentryWeight<T> {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 13_109_000 picoseconds.
Weight::from_parts(13_404_000, 0)
// Minimum execution time: 12_476_000 picoseconds.
Weight::from_parts(12_793_000, 0)
.saturating_add(T::DbWeight::get().writes(1_u64))
}
/// Storage: IdentityManagement Delegatee (r:1 w:1)
Expand All @@ -81,8 +81,8 @@ impl<T: frame_system::Config> WeightInfo for LitentryWeight<T> {
// Proof Size summary in bytes:
// Measured: `79`
// Estimated: `3513`
// Minimum execution time: 18_979_000 picoseconds.
Weight::from_parts(19_312_000, 3513)
// Minimum execution time: 18_305_000 picoseconds.
Weight::from_parts(18_709_000, 3513)
.saturating_add(T::DbWeight::get().reads(1_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
Expand All @@ -92,8 +92,8 @@ impl<T: frame_system::Config> WeightInfo for LitentryWeight<T> {
// Proof Size summary in bytes:
// Measured: `76`
// Estimated: `1561`
// Minimum execution time: 17_737_000 picoseconds.
Weight::from_parts(18_048_000, 1561)
// Minimum execution time: 17_266_000 picoseconds.
Weight::from_parts(17_608_000, 1561)
.saturating_add(T::DbWeight::get().reads(1_u64))
}
/// Storage: IMPExtrinsicWhitelist GroupControlOn (r:1 w:0)
Expand All @@ -102,8 +102,8 @@ impl<T: frame_system::Config> WeightInfo for LitentryWeight<T> {
// Proof Size summary in bytes:
// Measured: `76`
// Estimated: `1561`
// Minimum execution time: 15_655_000 picoseconds.
Weight::from_parts(16_069_000, 1561)
// Minimum execution time: 15_515_000 picoseconds.
Weight::from_parts(15_775_000, 1561)
.saturating_add(T::DbWeight::get().reads(1_u64))
}
/// Storage: IMPExtrinsicWhitelist GroupControlOn (r:1 w:0)
Expand All @@ -112,62 +112,62 @@ impl<T: frame_system::Config> WeightInfo for LitentryWeight<T> {
// Proof Size summary in bytes:
// Measured: `76`
// Estimated: `1561`
// Minimum execution time: 15_762_000 picoseconds.
Weight::from_parts(16_058_000, 1561)
// Minimum execution time: 15_495_000 picoseconds.
Weight::from_parts(15_770_000, 1561)
.saturating_add(T::DbWeight::get().reads(1_u64))
}
/// Storage: Teerex EnclaveIndex (r:1 w:0)
/// Proof Skipped: Teerex EnclaveIndex (max_values: None, max_size: None, mode: Measured)
fn identity_linked() -> Weight {
/// Storage: IdentityManagement IDGraphFingerprint (r:0 w:1)
/// Proof: IdentityManagement IDGraphFingerprint (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen)
fn update_idgraph_fingerprint() -> Weight {
// Proof Size summary in bytes:
// Measured: `255`
// Estimated: `3720`
// Minimum execution time: 18_758_000 picoseconds.
Weight::from_parts(19_047_000, 3720)
// Minimum execution time: 20_641_000 picoseconds.
Weight::from_parts(20_986_000, 3720)
.saturating_add(T::DbWeight::get().reads(1_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
/// Storage: Teerex EnclaveIndex (r:1 w:0)
/// Proof Skipped: Teerex EnclaveIndex (max_values: None, max_size: None, mode: Measured)
fn identity_deactivated() -> Weight {
fn identity_linked() -> Weight {
// Proof Size summary in bytes:
// Measured: `255`
// Estimated: `3720`
// Minimum execution time: 18_784_000 picoseconds.
Weight::from_parts(19_109_000, 3720)
// Minimum execution time: 18_140_000 picoseconds.
Weight::from_parts(18_549_000, 3720)
.saturating_add(T::DbWeight::get().reads(1_u64))
}
/// Storage: Teerex EnclaveIndex (r:1 w:0)
/// Proof Skipped: Teerex EnclaveIndex (max_values: None, max_size: None, mode: Measured)
fn identity_activated() -> Weight {
fn identity_deactivated() -> Weight {
// Proof Size summary in bytes:
// Measured: `255`
// Estimated: `3720`
// Minimum execution time: 18_869_000 picoseconds.
Weight::from_parts(19_113_000, 3720)
// Minimum execution time: 18_157_000 picoseconds.
Weight::from_parts(18_510_000, 3720)
.saturating_add(T::DbWeight::get().reads(1_u64))
}
/// Storage: Teerex EnclaveIndex (r:1 w:0)
/// Proof Skipped: Teerex EnclaveIndex (max_values: None, max_size: None, mode: Measured)
fn some_error() -> Weight {
fn identity_activated() -> Weight {
// Proof Size summary in bytes:
// Measured: `255`
// Estimated: `3720`
// Minimum execution time: 18_685_000 picoseconds.
Weight::from_parts(19_049_000, 3720)
// Minimum execution time: 18_225_000 picoseconds.
Weight::from_parts(18_547_000, 3720)
.saturating_add(T::DbWeight::get().reads(1_u64))
}
/// Storage: Teerex EnclaveIndex (r:1 w:0)
/// Proof Skipped: Teerex EnclaveIndex (max_values: None, max_size: None, mode: Measured)
/// Storage: IdentityManagement IDGraphFingerprint (r:0 w:1)
/// Proof: IdentityManagement IDGraphFingerprint (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen)
fn idgraph_updated() -> Weight {
fn some_error() -> Weight {
// Proof Size summary in bytes:
// Measured: `255`
// Estimated: `3720`
// Minimum execution time: 20_961_000 picoseconds.
Weight::from_parts(21_275_000, 3720)
// Minimum execution time: 18_094_000 picoseconds.
Weight::from_parts(18_477_000, 3720)
.saturating_add(T::DbWeight::get().reads(1_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
}

Expand All @@ -179,8 +179,8 @@ impl WeightInfo for () {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 13_109_000 picoseconds.
Weight::from_parts(13_404_000, 0)
// Minimum execution time: 12_476_000 picoseconds.
Weight::from_parts(12_793_000, 0)
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
/// Storage: IdentityManagement Delegatee (r:1 w:1)
Expand All @@ -189,8 +189,8 @@ impl WeightInfo for () {
// Proof Size summary in bytes:
// Measured: `79`
// Estimated: `3513`
// Minimum execution time: 18_979_000 picoseconds.
Weight::from_parts(19_312_000, 3513)
// Minimum execution time: 18_305_000 picoseconds.
Weight::from_parts(18_709_000, 3513)
.saturating_add(RocksDbWeight::get().reads(1_u64))
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
Expand All @@ -200,8 +200,8 @@ impl WeightInfo for () {
// Proof Size summary in bytes:
// Measured: `76`
// Estimated: `1561`
// Minimum execution time: 17_737_000 picoseconds.
Weight::from_parts(18_048_000, 1561)
// Minimum execution time: 17_266_000 picoseconds.
Weight::from_parts(17_608_000, 1561)
.saturating_add(RocksDbWeight::get().reads(1_u64))
}
/// Storage: IMPExtrinsicWhitelist GroupControlOn (r:1 w:0)
Expand All @@ -210,8 +210,8 @@ impl WeightInfo for () {
// Proof Size summary in bytes:
// Measured: `76`
// Estimated: `1561`
// Minimum execution time: 15_655_000 picoseconds.
Weight::from_parts(16_069_000, 1561)
// Minimum execution time: 15_515_000 picoseconds.
Weight::from_parts(15_775_000, 1561)
.saturating_add(RocksDbWeight::get().reads(1_u64))
}
/// Storage: IMPExtrinsicWhitelist GroupControlOn (r:1 w:0)
Expand All @@ -220,61 +220,61 @@ impl WeightInfo for () {
// Proof Size summary in bytes:
// Measured: `76`
// Estimated: `1561`
// Minimum execution time: 15_762_000 picoseconds.
Weight::from_parts(16_058_000, 1561)
// Minimum execution time: 15_495_000 picoseconds.
Weight::from_parts(15_770_000, 1561)
.saturating_add(RocksDbWeight::get().reads(1_u64))
}
/// Storage: Teerex EnclaveIndex (r:1 w:0)
/// Proof Skipped: Teerex EnclaveIndex (max_values: None, max_size: None, mode: Measured)
fn identity_linked() -> Weight {
/// Storage: IdentityManagement IDGraphFingerprint (r:0 w:1)
/// Proof: IdentityManagement IDGraphFingerprint (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen)
fn update_idgraph_fingerprint() -> Weight {
// Proof Size summary in bytes:
// Measured: `255`
// Estimated: `3720`
// Minimum execution time: 18_758_000 picoseconds.
Weight::from_parts(19_047_000, 3720)
// Minimum execution time: 20_641_000 picoseconds.
Weight::from_parts(20_986_000, 3720)
.saturating_add(RocksDbWeight::get().reads(1_u64))
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
/// Storage: Teerex EnclaveIndex (r:1 w:0)
/// Proof Skipped: Teerex EnclaveIndex (max_values: None, max_size: None, mode: Measured)
fn identity_deactivated() -> Weight {
fn identity_linked() -> Weight {
// Proof Size summary in bytes:
// Measured: `255`
// Estimated: `3720`
// Minimum execution time: 18_784_000 picoseconds.
Weight::from_parts(19_109_000, 3720)
// Minimum execution time: 18_140_000 picoseconds.
Weight::from_parts(18_549_000, 3720)
.saturating_add(RocksDbWeight::get().reads(1_u64))
}
/// Storage: Teerex EnclaveIndex (r:1 w:0)
/// Proof Skipped: Teerex EnclaveIndex (max_values: None, max_size: None, mode: Measured)
fn identity_activated() -> Weight {
fn identity_deactivated() -> Weight {
// Proof Size summary in bytes:
// Measured: `255`
// Estimated: `3720`
// Minimum execution time: 18_869_000 picoseconds.
Weight::from_parts(19_113_000, 3720)
// Minimum execution time: 18_157_000 picoseconds.
Weight::from_parts(18_510_000, 3720)
.saturating_add(RocksDbWeight::get().reads(1_u64))
}
/// Storage: Teerex EnclaveIndex (r:1 w:0)
/// Proof Skipped: Teerex EnclaveIndex (max_values: None, max_size: None, mode: Measured)
fn some_error() -> Weight {
fn identity_activated() -> Weight {
// Proof Size summary in bytes:
// Measured: `255`
// Estimated: `3720`
// Minimum execution time: 18_685_000 picoseconds.
Weight::from_parts(19_049_000, 3720)
// Minimum execution time: 18_225_000 picoseconds.
Weight::from_parts(18_547_000, 3720)
.saturating_add(RocksDbWeight::get().reads(1_u64))
}
/// Storage: Teerex EnclaveIndex (r:1 w:0)
/// Proof Skipped: Teerex EnclaveIndex (max_values: None, max_size: None, mode: Measured)
/// Storage: IdentityManagement IDGraphFingerprint (r:0 w:1)
/// Proof: IdentityManagement IDGraphFingerprint (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen)
fn idgraph_updated() -> Weight {
fn some_error() -> Weight {
// Proof Size summary in bytes:
// Measured: `255`
// Estimated: `3720`
// Minimum execution time: 20_961_000 picoseconds.
Weight::from_parts(21_275_000, 3720)
// Minimum execution time: 18_094_000 picoseconds.
Weight::from_parts(18_477_000, 3720)
.saturating_add(RocksDbWeight::get().reads(1_u64))
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
}
Loading

0 comments on commit 0f111e0

Please sign in to comment.