From 7607ebff3b2eaa2901f3552fb1246a87dd509e2e Mon Sep 17 00:00:00 2001 From: BillyWooo Date: Sat, 21 Sep 2024 21:45:22 +0200 Subject: [PATCH] Revert "Identity staking follow up " (#3077) * Revert "Identity staking follow up (#2976)" This reverts commit 2f55394b83966a5eb5438bace1dd4006d1a73c47. * Revert "fixing clippy issues (#3076)" This reverts commit ac42ede0511b2dee3dc66762930a50b18f10fe96. --- Cargo.lock | 3 - pallets/score-staking/Cargo.toml | 5 - pallets/score-staking/src/lib.rs | 88 +------ pallets/score-staking/src/mock.rs | 74 +----- pallets/score-staking/src/tests.rs | 234 +++--------------- pallets/score-staking/src/types.rs | 1 - precompiles/score-staking/Cargo.toml | 3 - precompiles/score-staking/src/mock.rs | 61 +---- precompiles/score-staking/src/tests.rs | 14 +- runtime/litentry/src/lib.rs | 1 - runtime/paseo/src/lib.rs | 1 - runtime/rococo/src/lib.rs | 1 - tee-worker/Cargo.lock | 143 +++++------ .../app-libs/parentchain-interface/Cargo.toml | 13 +- .../src/integritee/event_filter.rs | 8 +- .../src/integritee/event_handler.rs | 209 ++-------------- .../src/target_a/event_filter.rs | 6 - .../src/target_a/event_handler.rs | 2 - .../src/target_b/event_filter.rs | 6 - .../src/target_b/event_handler.rs | 2 - .../extrinsics-factory/src/lib.rs | 2 +- .../node-api/metadata/src/lib.rs | 28 +-- .../node-api/metadata/src/metadata_mocks.rs | 32 +-- .../metadata/src/pallet_score_staking.rs | 36 --- .../core-primitives/storage/src/keys.rs | 14 -- tee-worker/core-primitives/types/src/lib.rs | 4 +- .../types/src/parentchain/events.rs | 25 -- .../types/src/parentchain/mod.rs | 16 +- .../indirect-calls-executor/src/executor.rs | 5 +- .../indirect-calls-executor/src/mock.rs | 8 - tee-worker/enclave-runtime/Cargo.lock | 9 - .../src/initialization/global_components.rs | 6 +- .../src/initialization/parentchain/common.rs | 5 +- tee-worker/litentry/primitives/Cargo.toml | 2 - tee-worker/litentry/primitives/src/lib.rs | 1 - 35 files changed, 151 insertions(+), 917 deletions(-) delete mode 100644 tee-worker/core-primitives/node-api/metadata/src/pallet_score_staking.rs diff --git a/Cargo.lock b/Cargo.lock index d02e3dfda6..2140ce3ff0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7449,7 +7449,6 @@ dependencies = [ "pallet-evm", "pallet-parachain-staking", "pallet-score-staking", - "pallet-teebag", "pallet-timestamp", "parity-scale-codec", "precompile-utils", @@ -7943,8 +7942,6 @@ dependencies = [ "num-integer", "pallet-balances", "pallet-parachain-staking", - "pallet-teebag", - "pallet-timestamp", "parity-scale-codec", "scale-info", "serde", diff --git a/pallets/score-staking/Cargo.toml b/pallets/score-staking/Cargo.toml index f6c91f9a8d..a4869ecd19 100644 --- a/pallets/score-staking/Cargo.toml +++ b/pallets/score-staking/Cargo.toml @@ -13,14 +13,12 @@ serde = { workspace = true } frame-benchmarking = { workspace = true, optional = true } frame-support = { workspace = true } frame-system = { workspace = true } -pallet-timestamp = { workspace = true } sp-core = { workspace = true } sp-runtime = { workspace = true } sp-std = { workspace = true } core-primitives = { workspace = true } pallet-parachain-staking = { workspace = true } -pallet-teebag = { workspace = true } [dev-dependencies] sp-io = { workspace = true } @@ -44,15 +42,12 @@ std = [ "pallet-balances/std", "core-primitives/std", "pallet-parachain-staking/std", - "pallet-teebag/std", - "pallet-timestamp/std", ] runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", "frame-support/runtime-benchmarks", "frame-system/runtime-benchmarks", "sp-runtime/runtime-benchmarks", - "pallet-timestamp/runtime-benchmarks", ] try-runtime = [ "frame-support/try-runtime", diff --git a/pallets/score-staking/src/lib.rs b/pallets/score-staking/src/lib.rs index 16d947f403..9d8b09aa7b 100644 --- a/pallets/score-staking/src/lib.rs +++ b/pallets/score-staking/src/lib.rs @@ -114,8 +114,6 @@ pub mod pallet { type AdminOrigin: EnsureOrigin; /// AccountId converter type AccountIdConvert: AccountIdConvert; - // For extrinsics that should only be called by origins from TEE - type TEECallOrigin: EnsureOrigin; } #[pallet::error] @@ -152,45 +150,20 @@ pub mod pallet { ScoreUserCountUnderflow, // when the score user count would exceed `MaxScoreUserCount` MaxScoreUserCountReached, - // the token staking amount has been updated already for the round - TokenStakingAmountAlreadyUpdated, } #[pallet::event] #[pallet::generate_deposit(pub (crate) fn deposit_event)] pub enum Event { - PoolStarted { - start_block: BlockNumberFor, - }, + PoolStarted { start_block: BlockNumberFor }, PoolStopped {}, - ScoreFeederSet { - new_score_feeder: Option, - }, - RoundConfigSet { - new_config: RoundSetting, - }, - ScoreUpdated { - who: Identity, - new_score: Score, - }, - ScoreRemoved { - who: Identity, - }, + ScoreFeederSet { new_score_feeder: Option }, + RoundConfigSet { new_config: RoundSetting }, + ScoreUpdated { who: Identity, new_score: Score }, + ScoreRemoved { who: Identity }, ScoreCleared {}, - TokenStakingAmountUpdated { - account: T::AccountId, - amount: BalanceOf, - }, - RewardDistributionStarted { - total: BalanceOf, - distributed: BalanceOf, - round_index: RoundIndex, - }, - RewardDistributionCompleted {}, - RewardClaimed { - who: T::AccountId, - amount: BalanceOf, - }, + RewardCalculated { total: BalanceOf, distributed: BalanceOf }, + RewardClaimed { who: T::AccountId, amount: BalanceOf }, } #[pallet::storage] @@ -269,8 +242,7 @@ pub mod pallet { // We are about to start a new round // 1. update round info - let round_index = r.index.saturating_add(1); - r.index = round_index; + r.index = r.index.saturating_add(1); r.start_block = now; Round::::put(r); weight = weight.saturating_add(T::DbWeight::get().reads_writes(1, 1)); @@ -307,10 +279,9 @@ pub mod pallet { weight = weight.saturating_add(T::DbWeight::get().reads_writes(2, 1)); } - Self::deposit_event(Event::::RewardDistributionStarted { + Self::deposit_event(Event::::RewardCalculated { total: round_reward, distributed: all_user_reward, - round_index, }); weight @@ -474,47 +445,6 @@ pub mod pallet { let payment = Scores::::get(&account).ok_or(Error::::UserNotExist)?; Self::claim(origin, payment.unpaid_reward) } - - #[pallet::call_index(9)] - #[pallet::weight((195_000_000, DispatchClass::Normal))] - pub fn update_token_staking_amount( - origin: OriginFor, - account: T::AccountId, - amount: BalanceOf, - round_index: RoundIndex, - ) -> DispatchResultWithPostInfo { - let _ = T::TEECallOrigin::ensure_origin(origin)?; - - match Scores::::get(&account) { - Some(mut s) => { - if round_index <= s.last_token_distributed_round { - return Err(Error::::TokenStakingAmountAlreadyUpdated.into()); - } - let last_round = Round::::get(); - s.last_round_reward += amount; - s.total_reward += amount; - s.unpaid_reward += amount; - s.last_token_distributed_round = last_round.index; - Scores::::insert(account.clone(), s); - Self::deposit_event(Event::TokenStakingAmountUpdated { - account: account.clone(), - amount, - }); - Ok(Pays::No.into()) - }, - None => Err(Error::::UserNotExist.into()), - } - } - - #[pallet::call_index(10)] - #[pallet::weight((195_000_000, DispatchClass::Normal))] - pub fn complete_reward_distribution(origin: OriginFor) -> DispatchResultWithPostInfo { - let _ = T::TEECallOrigin::ensure_origin(origin)?; - - Self::deposit_event(Event::RewardDistributionCompleted {}); - - Ok(Pays::No.into()) - } } } diff --git a/pallets/score-staking/src/mock.rs b/pallets/score-staking/src/mock.rs index d50d8acff3..2463ac0540 100644 --- a/pallets/score-staking/src/mock.rs +++ b/pallets/score-staking/src/mock.rs @@ -18,11 +18,8 @@ use crate::{ self as pallet_score_staking, AccountIdConvert, Config, Perbill, PoolState, RoundSetting, }; -use core::marker::PhantomData; use frame_support::{ - assert_ok, construct_runtime, ord_parameter_types, - pallet_prelude::EnsureOrigin, - parameter_types, + assert_ok, construct_runtime, ord_parameter_types, parameter_types, traits::{OnFinalize, OnInitialize}, }; use frame_system::{EnsureRoot, EnsureSignedBy}; @@ -54,7 +51,6 @@ construct_runtime!( Balances: pallet_balances, ParachainStaking: pallet_parachain_staking, ScoreStaking: pallet_score_staking, - Teebag: pallet_teebag, } ); @@ -170,66 +166,6 @@ impl pallet_score_staking::Config for Test { type YearlyIssuance = ConstU128<{ 100_000_000 * UNIT }>; type YearlyInflation = DefaultYearlyInflation; type MaxScoreUserCount = ConstU32<2>; - type TEECallOrigin = EnsureEnclaveSigner; -} - -parameter_types! { - pub const MinimumPeriod: u64 = 6000 / 2; -} - -pub type Moment = u64; - -impl pallet_timestamp::Config for Test { - type Moment = Moment; - type OnTimestampSet = (); - type MinimumPeriod = MinimumPeriod; - type WeightInfo = (); -} - -parameter_types! { - pub const MomentsPerDay: u64 = 86_400_000; // [ms/d] -} - -impl pallet_teebag::Config for Test { - type RuntimeEvent = RuntimeEvent; - type MomentsPerDay = MomentsPerDay; - type SetAdminOrigin = EnsureRoot; - type MaxEnclaveIdentifier = ConstU32<1>; - type MaxAuthorizedEnclave = ConstU32<2>; - type WeightInfo = (); -} - -pub struct EnsureEnclaveSigner(PhantomData); -impl EnsureOrigin for EnsureEnclaveSigner -where - T: frame_system::Config + pallet_teebag::Config + pallet_timestamp::Config, - ::AccountId: From<[u8; 32]>, - ::Hash: From<[u8; 32]>, -{ - type Success = T::AccountId; - fn try_origin(o: T::RuntimeOrigin) -> Result { - o.into().and_then(|o| match o { - frame_system::RawOrigin::Signed(who) - if pallet_teebag::EnclaveRegistry::::contains_key(&who) => - { - Ok(who) - }, - r => Err(T::RuntimeOrigin::from(r)), - }) - } - - #[cfg(feature = "runtime-benchmarks")] - fn try_successful_origin() -> Result { - use pallet_teebag::test_util::{get_signer, TEST8_MRENCLAVE, TEST8_SIGNER_PUB}; - let signer: ::AccountId = get_signer(TEST8_SIGNER_PUB); - if !pallet_teebag::EnclaveRegistry::::contains_key(signer.clone()) { - assert_ok!(pallet_teebag::Pallet::::add_enclave( - &signer, - &pallet_teebag::Enclave::default().with_mrenclave(TEST8_MRENCLAVE), - )); - } - Ok(frame_system::RawOrigin::Signed(signer).into()) - } } pub fn alice() -> AccountId { @@ -250,14 +186,6 @@ pub fn new_test_ext(fast_round: bool) -> sp_io::TestExternalities { .assimilate_storage(&mut t) .unwrap(); - pallet_teebag::GenesisConfig:: { - allow_sgx_debug_mode: true, - admin: Some(AccountKeyring::Alice.to_account_id()), - mode: pallet_teebag::OperationalMode::Production, - } - .assimilate_storage(&mut t) - .unwrap(); - pallet_score_staking::GenesisConfig:: { state: PoolState::Stopped, marker: Default::default(), diff --git a/pallets/score-staking/src/tests.rs b/pallets/score-staking/src/tests.rs index 3075fd5400..77b87b4dcc 100644 --- a/pallets/score-staking/src/tests.rs +++ b/pallets/score-staking/src/tests.rs @@ -18,9 +18,8 @@ use crate::{mock::*, Error, Event, PoolState, RoundInfo, RoundSetting, ScorePayment, Scores}; use core_primitives::{Identity, DAYS, YEARS}; -use frame_support::{assert_err, assert_noop, assert_ok}; +use frame_support::{assert_err, assert_ok}; use pallet_parachain_staking::{Delegator, OnAllDelegationRemoved}; -use pallet_teebag::{Enclave, WorkerType}; use sp_runtime::Perbill; fn round_reward() -> Balance { @@ -128,13 +127,10 @@ fn default_mint_works() { // run to next reward distribution round run_to_block(7); - System::assert_last_event(RuntimeEvent::ScoreStaking( - Event::::RewardDistributionStarted { - total: round_reward(), - distributed: 0, - round_index: 2, - }, - )); + System::assert_last_event(RuntimeEvent::ScoreStaking(Event::::RewardCalculated { + total: round_reward(), + distributed: 0, + })); }); } @@ -169,13 +165,7 @@ fn score_staking_works() { assert_ok!(ScoreStaking::update_score(RuntimeOrigin::signed(alice()), alice().into(), 500)); assert_eq!( ScoreStaking::scores(alice()).unwrap(), - ScorePayment { - score: 500, - total_reward: 0, - last_round_reward: 0, - unpaid_reward: 0, - last_token_distributed_round: 0 - } + ScorePayment { score: 500, total_reward: 0, last_round_reward: 0, unpaid_reward: 0 } ); assert_eq!(ScoreStaking::total_score(), 500); assert_eq!(ScoreStaking::score_user_count(), 1); @@ -191,14 +181,11 @@ fn score_staking_works() { // run to next reward distribution round, alice should win all rewards run_to_block(7); - System::assert_last_event(RuntimeEvent::ScoreStaking( - Event::::RewardDistributionStarted { - total: round_reward(), - distributed: round_reward(), - round_index: 2, - }, - )); - // total reward first distribution + System::assert_last_event(RuntimeEvent::ScoreStaking(Event::::RewardCalculated { + total: round_reward(), + distributed: round_reward(), + })); + // total reward round 1 let mut alice_total_reward = round_reward(); assert_eq!( ScoreStaking::scores(alice()).unwrap(), @@ -207,22 +194,18 @@ fn score_staking_works() { total_reward: alice_total_reward, last_round_reward: alice_total_reward, unpaid_reward: alice_total_reward, - last_token_distributed_round: 0, } ); // alice's winning should accumulate run_to_block(12); - System::assert_last_event(RuntimeEvent::ScoreStaking( - Event::::RewardDistributionStarted { - total: round_reward(), - distributed: round_reward(), - round_index: 3, - }, - )); - // total reward second distribution + // total reward round 2 alice_total_reward += round_reward(); + System::assert_last_event(RuntimeEvent::ScoreStaking(Event::::RewardCalculated { + total: round_reward(), + distributed: round_reward(), + })); assert_eq!( ScoreStaking::scores(alice()).unwrap(), ScorePayment { @@ -230,7 +213,6 @@ fn score_staking_works() { total_reward: alice_total_reward, last_round_reward: round_reward(), unpaid_reward: alice_total_reward, - last_token_distributed_round: 0, } ); @@ -239,16 +221,13 @@ fn score_staking_works() { pallet_parachain_staking::Total::::put(1600); run_to_block(17); - System::assert_last_event(RuntimeEvent::ScoreStaking( - Event::::RewardDistributionStarted { - total: round_reward(), - distributed: calculate_round_reward(2000, 2000, 900, 1600), - round_index: 4, - }, - )); - // total reward third distribution + // total reward round 3 alice_total_reward += calculate_round_reward(2000, 2000, 900, 1600); + System::assert_last_event(RuntimeEvent::ScoreStaking(Event::::RewardCalculated { + total: round_reward(), + distributed: calculate_round_reward(2000, 2000, 900, 1600), + })); assert_eq!( ScoreStaking::scores(alice()).unwrap(), ScorePayment { @@ -256,7 +235,6 @@ fn score_staking_works() { total_reward: alice_total_reward, last_round_reward: calculate_round_reward(2000, 2000, 900, 1600), unpaid_reward: alice_total_reward, - last_token_distributed_round: 0, } ); @@ -269,7 +247,7 @@ fn score_staking_works() { assert_eq!(ScoreStaking::score_user_count(), 2); run_to_block(22); - // total rewards fourth distribution + // total rewards round 4 alice_total_reward += calculate_round_reward(2000, 3000, 900, 3200); let mut bob_total_reward = calculate_round_reward(1000, 3000, 1600, 3200); @@ -280,7 +258,6 @@ fn score_staking_works() { total_reward: alice_total_reward, last_round_reward: calculate_round_reward(2000, 3000, 900, 3200), unpaid_reward: alice_total_reward, - last_token_distributed_round: 0, } ); assert_eq!( @@ -290,7 +267,6 @@ fn score_staking_works() { total_reward: bob_total_reward, last_round_reward: bob_total_reward, unpaid_reward: bob_total_reward, - last_token_distributed_round: 0, } ); @@ -312,7 +288,7 @@ fn score_staking_works() { )); run_to_block(25); - // total rewards fifth distribution + // total rewards round 5 alice_total_reward += calculate_round_reward(2000, 3000, 900, 3200); bob_total_reward += calculate_round_reward(1000, 3000, 1600, 3200); @@ -324,7 +300,7 @@ fn score_staking_works() { )); run_to_block(31); - // total reward sixth distribution + // total reward round 6 alice_total_reward += calculate_round_reward(2000, 2000, 900, 900); // remove increased stake (keep only alice's stake) @@ -340,7 +316,6 @@ fn score_staking_works() { total_reward: alice_total_reward, last_round_reward: round_reward(), unpaid_reward: alice_total_reward, - last_token_distributed_round: 0, } ); @@ -352,7 +327,6 @@ fn score_staking_works() { total_reward: bob_total_reward, last_round_reward: 0, unpaid_reward: bob_total_reward, - last_token_distributed_round: 0, } ); assert_eq!(ScoreStaking::total_score(), 2000); @@ -386,13 +360,10 @@ fn claim_works() { // run to next reward distribution round, alice should win all rewards run_to_block(7); - System::assert_last_event(RuntimeEvent::ScoreStaking( - Event::::RewardDistributionStarted { - total: round_reward(), - distributed: round_reward(), - round_index: 2, - }, - )); + System::assert_last_event(RuntimeEvent::ScoreStaking(Event::::RewardCalculated { + total: round_reward(), + distributed: round_reward(), + })); assert_eq!( ScoreStaking::scores(alice()).unwrap(), ScorePayment { @@ -400,7 +371,6 @@ fn claim_works() { total_reward: round_reward(), last_round_reward: round_reward(), unpaid_reward: round_reward(), - last_token_distributed_round: 0, } ); @@ -416,7 +386,6 @@ fn claim_works() { total_reward: round_reward(), last_round_reward: round_reward(), unpaid_reward: round_reward() - 200, - last_token_distributed_round: 0, } ); @@ -432,7 +401,6 @@ fn claim_works() { total_reward: round_reward(), last_round_reward: round_reward(), unpaid_reward: 0, - last_token_distributed_round: 0, } ); @@ -444,152 +412,6 @@ fn claim_works() { }); } -#[test] -fn update_token_staking_amount_works() { - new_test_ext_with_parachain_staking().execute_with(|| { - let enclave = Enclave::new(WorkerType::Identity); - pallet_teebag::EnclaveRegistry::::insert(alice(), enclave); - - run_to_block(2); - assert_ok!(ScoreStaking::start_pool(RuntimeOrigin::root())); - - run_to_block(3); - pallet_parachain_staking::DelegatorState::::insert( - alice(), - Delegator::new(bob(), bob(), 900), - ); - pallet_parachain_staking::Total::::put(900); - assert_ok!(ScoreStaking::update_score(RuntimeOrigin::signed(alice()), alice().into(), 500)); - - // run to next reward distribution round, alice should win all rewards - run_to_block(7); - let mut total_reward = round_reward(); - - System::assert_last_event(RuntimeEvent::ScoreStaking( - Event::::RewardDistributionStarted { - total: total_reward, - distributed: total_reward, - round_index: 2, - }, - )); - - assert_ok!(ScoreStaking::update_token_staking_amount( - RuntimeOrigin::signed(alice()), - alice(), - 1000, - 2, - )); - - total_reward += 1000; - - assert_eq!( - ScoreStaking::scores(alice()).unwrap(), - ScorePayment { - score: 500, - total_reward, - last_round_reward: total_reward, - unpaid_reward: total_reward, - last_token_distributed_round: 2, - } - ); - - run_to_block(12); - - total_reward += round_reward(); - - assert_noop!( - ScoreStaking::update_token_staking_amount( - RuntimeOrigin::signed(alice()), - alice(), - 1000, - 2, - ), - Error::::TokenStakingAmountAlreadyUpdated - ); - - assert_ok!(ScoreStaking::update_token_staking_amount( - RuntimeOrigin::signed(alice()), - alice(), - 1200, - 3, - )); - - total_reward += 1200; - - System::assert_last_event(RuntimeEvent::ScoreStaking( - Event::::TokenStakingAmountUpdated { account: alice(), amount: 1200 }, - )); - - assert_eq!( - ScoreStaking::scores(alice()).unwrap(), - ScorePayment { - score: 500, - total_reward, - last_round_reward: round_reward() + 1200, - unpaid_reward: total_reward, - last_token_distributed_round: 3, - } - ); - }) -} - -#[test] -fn update_token_staking_amount_origin_check_works() { - new_test_ext(false).execute_with(|| { - assert_noop!( - ScoreStaking::update_token_staking_amount( - RuntimeOrigin::signed(alice()), - alice(), - 1000, - 1 - ), - sp_runtime::DispatchError::BadOrigin - ); - }) -} - -#[test] -fn update_token_staking_amount_existing_user_check_works() { - new_test_ext(false).execute_with(|| { - let enclave = Enclave::new(WorkerType::Identity); - pallet_teebag::EnclaveRegistry::::insert(alice(), enclave); - - assert_noop!( - ScoreStaking::update_token_staking_amount( - RuntimeOrigin::signed(alice()), - alice(), - 1000, - 1 - ), - Error::::UserNotExist - ); - }) -} - -#[test] -fn complete_reward_distribution_works() { - new_test_ext(false).execute_with(|| { - let enclave = Enclave::new(WorkerType::Identity); - pallet_teebag::EnclaveRegistry::::insert(alice(), enclave); - - assert_ok!(ScoreStaking::complete_reward_distribution(RuntimeOrigin::signed(alice()))); - - System::assert_last_event(RuntimeEvent::ScoreStaking( - Event::::RewardDistributionCompleted {}, - )); - }); -} - -#[test] -fn complete_reward_distribution_origin_check_works() { - new_test_ext(false).execute_with(|| { - assert_noop!( - ScoreStaking::complete_reward_distribution(RuntimeOrigin::signed(alice())), - sp_runtime::DispatchError::BadOrigin - ); - }); -} - #[test] fn on_all_delegation_removed_works() { new_test_ext(true).execute_with(|| { diff --git a/pallets/score-staking/src/types.rs b/pallets/score-staking/src/types.rs index 5b6edda153..1456f4e67d 100644 --- a/pallets/score-staking/src/types.rs +++ b/pallets/score-staking/src/types.rs @@ -83,5 +83,4 @@ pub struct ScorePayment { pub total_reward: Balance, pub last_round_reward: Balance, pub unpaid_reward: Balance, - pub last_token_distributed_round: RoundIndex, } diff --git a/precompiles/score-staking/Cargo.toml b/precompiles/score-staking/Cargo.toml index 0913f0877b..e9bc95f33d 100644 --- a/precompiles/score-staking/Cargo.toml +++ b/precompiles/score-staking/Cargo.toml @@ -6,7 +6,6 @@ version = '0.1.0' [dependencies] pallet-score-staking = { workspace = true } -pallet-teebag = { workspace = true } precompile-utils = { workspace = true } fp-evm = { workspace = true } @@ -39,11 +38,9 @@ std = [ "frame-system/std", "pallet-evm/std", "pallet-score-staking/std", - "pallet-teebag/std", "precompile-utils/std", "sp-core/std", "sp-io/std", "sp-runtime/std", "sp-std/std", ] -runtime-benchmarks = [] diff --git a/precompiles/score-staking/src/mock.rs b/precompiles/score-staking/src/mock.rs index c127b263d8..6c5cbb288c 100644 --- a/precompiles/score-staking/src/mock.rs +++ b/precompiles/score-staking/src/mock.rs @@ -15,11 +15,8 @@ // along with Litentry. If not, see . use super::*; -use core::marker::PhantomData; use frame_support::{ - assert_ok, construct_runtime, - pallet_prelude::EnsureOrigin, - parameter_types, + assert_ok, construct_runtime, parameter_types, traits::{OnFinalize, OnInitialize}, weights::Weight, }; @@ -46,7 +43,6 @@ construct_runtime!( Evm: pallet_evm, ParachainStaking: pallet_parachain_staking, ScoreStaking: pallet_score_staking, - Teebag: pallet_teebag, } ); @@ -168,7 +164,6 @@ impl pallet_score_staking::Config for Test { type YearlyIssuance = ConstU128<{ 100_000_000 * UNIT }>; type YearlyInflation = DefaultYearlyInflation; type MaxScoreUserCount = ConstU32<2>; - type TEECallOrigin = EnsureEnclaveSigner; } pub fn precompile_address() -> H160 { @@ -250,52 +245,6 @@ impl pallet_timestamp::Config for Test { type WeightInfo = (); } -parameter_types! { - pub const MomentsPerDay: u64 = 86_400_000; // [ms/d] -} - -impl pallet_teebag::Config for Test { - type RuntimeEvent = RuntimeEvent; - type MomentsPerDay = MomentsPerDay; - type SetAdminOrigin = EnsureRoot; - type MaxEnclaveIdentifier = ConstU32<1>; - type MaxAuthorizedEnclave = ConstU32<2>; - type WeightInfo = (); -} - -pub struct EnsureEnclaveSigner(PhantomData); -impl EnsureOrigin for EnsureEnclaveSigner -where - T: frame_system::Config + pallet_teebag::Config + pallet_timestamp::Config, - ::AccountId: From<[u8; 32]>, - ::Hash: From<[u8; 32]>, -{ - type Success = T::AccountId; - fn try_origin(o: T::RuntimeOrigin) -> Result { - o.into().and_then(|o| match o { - frame_system::RawOrigin::Signed(who) - if pallet_teebag::EnclaveRegistry::::contains_key(&who) => - { - Ok(who) - }, - r => Err(T::RuntimeOrigin::from(r)), - }) - } - - #[cfg(feature = "runtime-benchmarks")] - fn try_successful_origin() -> Result { - use pallet_teebag::test_util::{get_signer, TEST8_MRENCLAVE, TEST8_SIGNER_PUB}; - let signer: ::AccountId = get_signer(TEST8_SIGNER_PUB); - if !pallet_teebag::EnclaveRegistry::::contains_key(signer.clone()) { - assert_ok!(pallet_teebag::Pallet::::add_enclave( - &signer, - &pallet_teebag::Enclave::default().with_mrenclave(TEST8_MRENCLAVE), - )); - } - Ok(frame_system::RawOrigin::Signed(signer).into()) - } -} - pub fn alice() -> AccountId { U8Wrapper(1u8).into() } @@ -310,14 +259,6 @@ pub fn new_test_ext(fast_round: bool) -> sp_io::TestExternalities { .assimilate_storage(&mut t) .unwrap(); - pallet_teebag::GenesisConfig:: { - allow_sgx_debug_mode: true, - admin: Some(alice()), - mode: pallet_teebag::OperationalMode::Production, - } - .assimilate_storage(&mut t) - .unwrap(); - pallet_score_staking::GenesisConfig:: { state: PoolState::Stopped, marker: Default::default(), diff --git a/precompiles/score-staking/src/tests.rs b/precompiles/score-staking/src/tests.rs index c096c09a73..b3e61b6e0e 100644 --- a/precompiles/score-staking/src/tests.rs +++ b/precompiles/score-staking/src/tests.rs @@ -52,13 +52,10 @@ fn claim_is_ok() { // run to next reward distribution round, alice should win all rewards run_to_block(7); - System::assert_last_event(RuntimeEvent::ScoreStaking( - Event::::RewardDistributionStarted { - total: round_reward(), - distributed: round_reward(), - round_index: 2, - }, - )); + System::assert_last_event(RuntimeEvent::ScoreStaking(Event::::RewardCalculated { + total: round_reward(), + distributed: round_reward(), + })); assert_eq!( ScoreStaking::scores(alice()).unwrap(), ScorePayment { @@ -66,7 +63,6 @@ fn claim_is_ok() { total_reward: round_reward(), last_round_reward: round_reward(), unpaid_reward: round_reward(), - last_token_distributed_round: 0, } ); @@ -90,7 +86,6 @@ fn claim_is_ok() { total_reward: round_reward(), last_round_reward: round_reward(), unpaid_reward: round_reward() - 200, - last_token_distributed_round: 0, } ); @@ -114,7 +109,6 @@ fn claim_is_ok() { total_reward: round_reward(), last_round_reward: round_reward(), unpaid_reward: 0, - last_token_distributed_round: 0, } ); diff --git a/runtime/litentry/src/lib.rs b/runtime/litentry/src/lib.rs index 29171d88d9..4815a5fc21 100644 --- a/runtime/litentry/src/lib.rs +++ b/runtime/litentry/src/lib.rs @@ -1127,7 +1127,6 @@ impl pallet_score_staking::Config for Runtime { type YearlyIssuance = ConstU128<{ 100_000_000 * UNIT }>; type YearlyInflation = DefaultYearlyInflation; type MaxScoreUserCount = ConstU32<1_000_000>; - type TEECallOrigin = EnsureEnclaveSigner; } impl runtime_common::BaseRuntimeRequirements for Runtime {} diff --git a/runtime/paseo/src/lib.rs b/runtime/paseo/src/lib.rs index 7121e83eb1..f80bc095ec 100644 --- a/runtime/paseo/src/lib.rs +++ b/runtime/paseo/src/lib.rs @@ -1169,7 +1169,6 @@ impl pallet_score_staking::Config for Runtime { type YearlyIssuance = ConstU128<{ 100_000_000 * UNIT }>; type YearlyInflation = DefaultYearlyInflation; type MaxScoreUserCount = ConstU32<1_000_000>; - type TEECallOrigin = EnsureEnclaveSigner; } impl runtime_common::BaseRuntimeRequirements for Runtime {} diff --git a/runtime/rococo/src/lib.rs b/runtime/rococo/src/lib.rs index 25ed6b2bf7..c875ce5e53 100644 --- a/runtime/rococo/src/lib.rs +++ b/runtime/rococo/src/lib.rs @@ -1168,7 +1168,6 @@ impl pallet_score_staking::Config for Runtime { type YearlyIssuance = ConstU128<{ 100_000_000 * UNIT }>; type YearlyInflation = DefaultYearlyInflation; type MaxScoreUserCount = ConstU32<1_000_000>; - type TEECallOrigin = EnsureEnclaveSigner; } impl runtime_common::BaseRuntimeRequirements for Runtime {} diff --git a/tee-worker/Cargo.lock b/tee-worker/Cargo.lock index 4ffdf6c929..3f7693cab8 100644 --- a/tee-worker/Cargo.lock +++ b/tee-worker/Cargo.lock @@ -384,7 +384,7 @@ dependencies = [ [[package]] name = "binary-merkle-tree" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "hash-db 0.16.0", "log 0.4.20", @@ -886,7 +886,7 @@ dependencies = [ "parity-scale-codec", "scale-info", "sp-core", - "sp-io 7.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42)", + "sp-io 7.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42)", "sp-runtime", "sp-std 5.0.0", "strum 0.26.1", @@ -1837,7 +1837,7 @@ dependencies = [ "scale-info", "serde 1.0.204", "sp-core", - "sp-io 7.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42)", + "sp-io 7.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42)", "sp-runtime", "sp-std 5.0.0", ] @@ -1855,7 +1855,7 @@ dependencies = [ "scale-info", "serde 1.0.204", "sp-core", - "sp-io 7.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42)", + "sp-io 7.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42)", "sp-runtime", "sp-runtime-interface", "sp-std 5.0.0", @@ -1900,7 +1900,7 @@ checksum = "6c2141d6d6c8512188a7891b4b01590a45f6dac67afb4f255c4124dbb86d4eaa" [[package]] name = "frame-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "frame-support", "frame-support-procedural", @@ -1914,7 +1914,7 @@ dependencies = [ "sp-api", "sp-application-crypto", "sp-core", - "sp-io 7.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42)", + "sp-io 7.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42)", "sp-runtime", "sp-runtime-interface", "sp-std 5.0.0", @@ -1925,14 +1925,14 @@ dependencies = [ [[package]] name = "frame-executive" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "frame-support", "frame-system", "parity-scale-codec", "scale-info", "sp-core", - "sp-io 7.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42)", + "sp-io 7.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42)", "sp-runtime", "sp-std 5.0.0", "sp-tracing", @@ -1953,7 +1953,7 @@ dependencies = [ [[package]] name = "frame-support" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "bitflags 1.3.2", "environmental 1.1.4", @@ -1973,7 +1973,7 @@ dependencies = [ "sp-core", "sp-core-hashing-proc-macro", "sp-inherents", - "sp-io 7.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42)", + "sp-io 7.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42)", "sp-runtime", "sp-staking", "sp-state-machine", @@ -1986,7 +1986,7 @@ dependencies = [ [[package]] name = "frame-support-procedural" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "Inflector", "cfg-expr", @@ -2002,7 +2002,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "frame-support-procedural-tools-derive", "proc-macro-crate", @@ -2014,7 +2014,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools-derive" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "proc-macro2", "quote", @@ -2024,7 +2024,7 @@ dependencies = [ [[package]] name = "frame-system" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "frame-support", "log 0.4.20", @@ -2032,7 +2032,7 @@ dependencies = [ "scale-info", "serde 1.0.204", "sp-core", - "sp-io 7.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42)", + "sp-io 7.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42)", "sp-runtime", "sp-std 5.0.0", "sp-version", @@ -2944,7 +2944,6 @@ name = "ita-parentchain-interface" version = "0.1.0" dependencies = [ "env_logger 0.9.3", - "frame-support", "ita-sgx-runtime", "ita-stf", "itc-parentchain-indirect-calls-executor", @@ -2954,21 +2953,15 @@ dependencies = [ "itp-node-api", "itp-ocall-api", "itp-sgx-crypto", - "itp-sgx-externalities", "itp-stf-executor", "itp-stf-primitives", - "itp-stf-state-handler", - "itp-storage", "itp-test", "itp-top-pool-author", "itp-types", "lc-dynamic-assertion", "lc-evm-dynamic-assertions", - "lc-parachain-extrinsic-task-sender", - "litentry-hex-utils 0.1.0", "litentry-primitives", "log 0.4.20", - "pallet-identity-management-tee", "parity-scale-codec", "sgx_tstd", "sp-core", @@ -5023,9 +5016,7 @@ dependencies = [ "core-primitives", "hex", "itp-sgx-crypto", - "itp-utils", "log 0.4.20", - "pallet-parachain-staking", "pallet-teebag", "parity-scale-codec", "rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5036,7 +5027,7 @@ dependencies = [ "serde 1.0.204", "sgx_tstd", "sp-core", - "sp-io 7.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42)", + "sp-io 7.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42)", "sp-runtime", "sp-std 5.0.0", ] @@ -5919,7 +5910,7 @@ checksum = "4d5d9eb14b174ee9aa2ef96dc2b94637a2d4b6e7cb873c7e171f0c20c6cf3eac" [[package]] name = "pallet-assets" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "frame-benchmarking", "frame-support", @@ -5934,7 +5925,7 @@ dependencies = [ [[package]] name = "pallet-authorship" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "frame-support", "frame-system", @@ -5948,7 +5939,7 @@ dependencies = [ [[package]] name = "pallet-balances" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "frame-benchmarking", "frame-support", @@ -5979,7 +5970,7 @@ dependencies = [ "rlp", "scale-info", "sp-core", - "sp-io 7.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42)", + "sp-io 7.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42)", "sp-runtime", "sp-std 5.0.0", ] @@ -6004,7 +5995,7 @@ dependencies = [ "rlp", "scale-info", "sp-core", - "sp-io 7.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42)", + "sp-io 7.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42)", "sp-runtime", "sp-std 5.0.0", ] @@ -6022,7 +6013,7 @@ dependencies = [ "parity-scale-codec", "scale-info", "sp-core", - "sp-io 7.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42)", + "sp-io 7.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42)", "sp-runtime", "sp-std 5.0.0", ] @@ -6056,14 +6047,14 @@ dependencies = [ "parity-scale-codec", "scale-info", "sp-core", - "sp-io 7.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42)", + "sp-io 7.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42)", "sp-runtime", ] [[package]] name = "pallet-session" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "frame-support", "frame-system", @@ -6073,7 +6064,7 @@ dependencies = [ "parity-scale-codec", "scale-info", "sp-core", - "sp-io 7.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42)", + "sp-io 7.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42)", "sp-runtime", "sp-session", "sp-staking", @@ -6083,13 +6074,13 @@ dependencies = [ [[package]] name = "pallet-sudo" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "frame-support", "frame-system", "parity-scale-codec", "scale-info", - "sp-io 7.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42)", + "sp-io 7.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42)", "sp-runtime", "sp-std 5.0.0", ] @@ -6116,7 +6107,7 @@ dependencies = [ "serde 1.0.204", "serde_json 1.0.103", "sp-core", - "sp-io 7.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42)", + "sp-io 7.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42)", "sp-runtime", "sp-std 5.0.0", "x509-cert", @@ -6125,7 +6116,7 @@ dependencies = [ [[package]] name = "pallet-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "frame-benchmarking", "frame-support", @@ -6134,7 +6125,7 @@ dependencies = [ "parity-scale-codec", "scale-info", "sp-inherents", - "sp-io 7.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42)", + "sp-io 7.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42)", "sp-runtime", "sp-std 5.0.0", "sp-timestamp", @@ -6143,7 +6134,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "frame-support", "frame-system", @@ -6151,7 +6142,7 @@ dependencies = [ "scale-info", "serde 1.0.204", "sp-core", - "sp-io 7.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42)", + "sp-io 7.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42)", "sp-runtime", "sp-std 5.0.0", ] @@ -7325,7 +7316,7 @@ dependencies = [ [[package]] name = "sc-keystore" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "array-bytes 4.2.0", "async-trait", @@ -8088,7 +8079,7 @@ dependencies = [ [[package]] name = "sp-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "hash-db 0.16.0", "log 0.4.20", @@ -8108,7 +8099,7 @@ dependencies = [ [[package]] name = "sp-api-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "Inflector", "blake2", @@ -8122,20 +8113,20 @@ dependencies = [ [[package]] name = "sp-application-crypto" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "parity-scale-codec", "scale-info", "serde 1.0.204", "sp-core", - "sp-io 7.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42)", + "sp-io 7.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42)", "sp-std 5.0.0", ] [[package]] name = "sp-arithmetic" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "integer-sqrt", "num-traits 0.2.16", @@ -8149,7 +8140,7 @@ dependencies = [ [[package]] name = "sp-consensus-grandpa" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "finality-grandpa", "log 0.4.20", @@ -8167,7 +8158,7 @@ dependencies = [ [[package]] name = "sp-consensus-slots" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "parity-scale-codec", "scale-info", @@ -8179,7 +8170,7 @@ dependencies = [ [[package]] name = "sp-core" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "array-bytes 4.2.0", "bitflags 1.3.2", @@ -8223,7 +8214,7 @@ dependencies = [ [[package]] name = "sp-core-hashing" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "blake2b_simd", "byteorder 1.4.3", @@ -8252,7 +8243,7 @@ dependencies = [ [[package]] name = "sp-core-hashing-proc-macro" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "proc-macro2", "quote", @@ -8263,7 +8254,7 @@ dependencies = [ [[package]] name = "sp-debug-derive" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "proc-macro2", "quote", @@ -8273,7 +8264,7 @@ dependencies = [ [[package]] name = "sp-externalities" version = "0.13.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "environmental 1.1.4", "parity-scale-codec", @@ -8284,7 +8275,7 @@ dependencies = [ [[package]] name = "sp-inherents" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "async-trait", "impl-trait-for-tuples", @@ -8311,7 +8302,7 @@ dependencies = [ [[package]] name = "sp-io" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "bytes 1.4.0", "ed25519", @@ -8337,7 +8328,7 @@ dependencies = [ [[package]] name = "sp-keyring" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "lazy_static", "sp-core", @@ -8348,7 +8339,7 @@ dependencies = [ [[package]] name = "sp-keystore" version = "0.13.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "futures 0.3.28", "parity-scale-codec", @@ -8362,7 +8353,7 @@ dependencies = [ [[package]] name = "sp-metadata-ir" version = "0.1.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "frame-metadata", "parity-scale-codec", @@ -8373,7 +8364,7 @@ dependencies = [ [[package]] name = "sp-panic-handler" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "backtrace", "lazy_static", @@ -8383,7 +8374,7 @@ dependencies = [ [[package]] name = "sp-runtime" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "either", "hash256-std-hasher", @@ -8397,7 +8388,7 @@ dependencies = [ "sp-application-crypto", "sp-arithmetic", "sp-core", - "sp-io 7.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42)", + "sp-io 7.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42)", "sp-std 5.0.0", "sp-weights", ] @@ -8405,7 +8396,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "bytes 1.4.0", "impl-trait-for-tuples", @@ -8423,7 +8414,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface-proc-macro" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "Inflector", "proc-macro-crate", @@ -8435,7 +8426,7 @@ dependencies = [ [[package]] name = "sp-session" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "parity-scale-codec", "scale-info", @@ -8448,7 +8439,7 @@ dependencies = [ [[package]] name = "sp-staking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "parity-scale-codec", "scale-info", @@ -8461,7 +8452,7 @@ dependencies = [ [[package]] name = "sp-state-machine" version = "0.13.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "hash-db 0.16.0", "log 0.4.20", @@ -8481,7 +8472,7 @@ dependencies = [ [[package]] name = "sp-std" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" [[package]] name = "sp-std" @@ -8492,7 +8483,7 @@ checksum = "af0ee286f98455272f64ac5bb1384ff21ac029fbb669afbaf48477faff12760e" [[package]] name = "sp-storage" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "impl-serde", "parity-scale-codec", @@ -8505,7 +8496,7 @@ dependencies = [ [[package]] name = "sp-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "async-trait", "futures-timer", @@ -8520,7 +8511,7 @@ dependencies = [ [[package]] name = "sp-tracing" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "parity-scale-codec", "sp-std 5.0.0", @@ -8532,7 +8523,7 @@ dependencies = [ [[package]] name = "sp-trie" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "ahash 0.8.3", "hash-db 0.16.0", @@ -8555,7 +8546,7 @@ dependencies = [ [[package]] name = "sp-version" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "impl-serde", "parity-scale-codec", @@ -8572,7 +8563,7 @@ dependencies = [ [[package]] name = "sp-version-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "parity-scale-codec", "proc-macro2", @@ -8583,7 +8574,7 @@ dependencies = [ [[package]] name = "sp-wasm-interface" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "anyhow", "impl-trait-for-tuples", @@ -8597,7 +8588,7 @@ dependencies = [ [[package]] name = "sp-weights" version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "parity-scale-codec", "scale-info", diff --git a/tee-worker/app-libs/parentchain-interface/Cargo.toml b/tee-worker/app-libs/parentchain-interface/Cargo.toml index f1ab5fc840..46cd6d9f6d 100644 --- a/tee-worker/app-libs/parentchain-interface/Cargo.toml +++ b/tee-worker/app-libs/parentchain-interface/Cargo.toml @@ -6,7 +6,6 @@ edition = "2021" [dependencies] # sgx dependencies -pallet-identity-management-tee = { path = "../../litentry/pallets/identity-management", default-features = false } sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true } # local dependencies @@ -17,12 +16,9 @@ itp-api-client-types = { path = "../../core-primitives/node-api/api-client-types itp-enclave-metrics = { path = "../../core-primitives/enclave-metrics", default-features = false } itp-node-api = { path = "../../core-primitives/node-api", default-features = false } itp-ocall-api = { path = "../../core-primitives/ocall-api", default-features = false } -itp-sgx-externalities = { path = "../../core-primitives/substrate-sgx/externalities", default-features = false } itp-stf-primitives = { path = "../../core-primitives/stf-primitives", default-features = false } -itp-stf-state-handler = { path = "../../core-primitives/stf-state-handler", default-features = false } -itp-storage = { path = "../../core-primitives/storage", default-features = false } itp-types = { path = "../../core-primitives/types", default-features = false } -lc-parachain-extrinsic-task-sender = { path = "../../litentry/core/parachain-extrinsic-task/sender", default-features = false } + # no-std compatible libraries codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } log = { version = "0.4", default-features = false } @@ -30,14 +26,12 @@ log = { version = "0.4", default-features = false } substrate-api-client = { optional = true, default-features = false, features = ["std", "sync-api"], git = "https://github.com/scs/substrate-api-client.git", branch = "polkadot-v0.9.42-tag-v0.14.0" } # substrate dep -frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } sp-core = { default-features = false, features = ["full_crypto"], git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } # litentry lc-dynamic-assertion = { path = "../../litentry/core/dynamic-assertion", default-features = false } lc-evm-dynamic-assertions = { path = "../../litentry/core/evm-dynamic-assertions", default-features = false } -litentry-hex-utils = { path = "../../../primitives/hex", default-features = false } litentry-primitives = { path = "../../litentry/primitives", default-features = false } sp-std = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } @@ -51,6 +45,7 @@ itp-test = { path = "../../core-primitives/test" } itp-top-pool-author = { path = "../../core-primitives/top-pool-author", features = ["mocks"] } itc-parentchain-test = { path = "../../core/parentchain/test" } + [features] default = ["std"] std = [ @@ -64,7 +59,6 @@ std = [ "itp-stf-executor/std", "itp-stf-primitives/std", "itp-top-pool-author/std", - "itp-sgx-externalities/std", "itp-types/std", "log/std", "sp-core/std", @@ -73,7 +67,6 @@ std = [ "litentry-primitives/std", "lc-dynamic-assertion/std", "lc-evm-dynamic-assertions/std", - "lc-parachain-extrinsic-task-sender/std", "sp-std/std", ] sgx = [ @@ -83,10 +76,8 @@ sgx = [ "itp-node-api/sgx", "itp-sgx-crypto/sgx", "itp-stf-executor/sgx", - "itp-sgx-externalities/sgx", "itp-top-pool-author/sgx", "litentry-primitives/sgx", "lc-dynamic-assertion/sgx", "lc-evm-dynamic-assertions/sgx", - "lc-parachain-extrinsic-task-sender/sgx", ] diff --git a/tee-worker/app-libs/parentchain-interface/src/integritee/event_filter.rs b/tee-worker/app-libs/parentchain-interface/src/integritee/event_filter.rs index 0c15bbdfcc..456cebe639 100644 --- a/tee-worker/app-libs/parentchain-interface/src/integritee/event_filter.rs +++ b/tee-worker/app-libs/parentchain-interface/src/integritee/event_filter.rs @@ -25,7 +25,7 @@ use itp_types::{ events::{ ActivateIdentityRequested, AssertionCreated, DeactivateIdentityRequested, EnclaveUnauthorized, LinkIdentityRequested, OpaqueTaskPosted, - ParentchainBlockProcessed, RewardDistributionStarted, VCRequested, + ParentchainBlockProcessed, VCRequested, }, FilterEvents, }, @@ -104,10 +104,4 @@ impl FilterEvents for FilterableEvents { ) -> Result, Self::Error> { self.filter() } - - fn get_reward_distribution_started_events( - &self, - ) -> Result, Self::Error> { - self.filter() - } } diff --git a/tee-worker/app-libs/parentchain-interface/src/integritee/event_handler.rs b/tee-worker/app-libs/parentchain-interface/src/integritee/event_handler.rs index c8eb71eb6f..015cdaee70 100644 --- a/tee-worker/app-libs/parentchain-interface/src/integritee/event_handler.rs +++ b/tee-worker/app-libs/parentchain-interface/src/integritee/event_handler.rs @@ -16,52 +16,39 @@ */ use codec::{Decode, Encode}; -use frame_support::storage::storage_prefix; -pub use ita_sgx_runtime::{Balance, Index, Runtime}; +pub use ita_sgx_runtime::{Balance, Index}; use ita_stf::{Getter, TrustedCall, TrustedCallSigned}; use itc_parentchain_indirect_calls_executor::error::Error; use itp_api_client_types::StaticEvent; use itp_enclave_metrics::EnclaveMetric; -use itp_node_api::metadata::{ - pallet_score_staking::ScoreStakingCallIndexes, provider::AccessNodeMetadata, NodeMetadataTrait, -}; -use itp_ocall_api::{EnclaveMetricsOCallApi, EnclaveOnChainOCallApi}; -use itp_sgx_externalities::{SgxExternalities, SgxExternalitiesTrait}; +use itp_ocall_api::EnclaveMetricsOCallApi; use itp_stf_primitives::{traits::IndirectExecutor, types::TrustedOperation}; -use itp_stf_state_handler::handle_state::HandleState; -use itp_storage::{key_to_account_id, storage_map_key, StorageHasher}; use itp_types::{ parentchain::{ events::ParentchainBlockProcessed, AccountId, FilterEvents, HandleParentchainEvents, - ParentchainEventProcessingError, ParentchainId, ProcessedEventsArtifacts, + ParentchainEventProcessingError, ProcessedEventsArtifacts, }, - Delegator, OpaqueCall, RsaRequest, H256, + RsaRequest, H256, }; use lc_dynamic_assertion::AssertionLogicRepository; use lc_evm_dynamic_assertions::repository::EvmAssertionRepository; -use lc_parachain_extrinsic_task_sender::{ParachainExtrinsicSender, SendParachainExtrinsic}; -use litentry_hex_utils::decode_hex; use litentry_primitives::{Assertion, Identity, ValidationData, Web3Network}; use log::*; -use pallet_identity_management_tee::IdentityContext; use sp_core::{blake2_256, H160}; -use sp_runtime::traits::Header; use sp_std::vec::Vec; -use std::{collections::BTreeMap, format, println, string::String, sync::Arc, time::Instant}; +use std::{format, string::String, sync::Arc, time::Instant}; -pub struct ParentchainEventHandler { +pub struct ParentchainEventHandler +where + MetricsApi: EnclaveMetricsOCallApi, +{ pub assertion_repository: Arc, - pub ocall_api: Arc, - pub state_handler: Arc, - pub node_metadata_repository: Arc, + pub metrics_api: Arc, } -impl ParentchainEventHandler +impl ParentchainEventHandler where - OCallApi: EnclaveOnChainOCallApi + EnclaveMetricsOCallApi, - HS: HandleState, - NMR: AccessNodeMetadata, - NMR::MetadataType: NodeMetadataTrait, + MetricsApi: EnclaveMetricsOCallApi, { fn link_identity>( executor: &Executor, @@ -223,169 +210,27 @@ where .save(id, (byte_code, decrypted_secrets)) .map_err(Error::AssertionCreatedHandling)?; let duration = start_time.elapsed(); - if let Err(e) = - self.ocall_api.update_metric(EnclaveMetric::DynamicAssertionSaveTime(duration)) + if let Err(e) = self + .metrics_api + .update_metric(EnclaveMetric::DynamicAssertionSaveTime(duration)) { warn!("Failed to update DynamicAssertionSaveTime metric with error: {:?}", e); } Ok(()) } - - fn update_staking_scores>( - &self, - executor: &Executor, - block_header: impl Header, - round_index: u32, - ) -> Result<(), Error> { - let scores_key_prefix = storage_prefix(b"ScoreStaking", b"Scores"); - let scores_storage_keys_response = self - .ocall_api - .get_storage_keys(scores_key_prefix.into()) - .map_err(|_| Error::Other("Failed to get storage keys".into()))?; - let scores_storage_keys: Vec> = scores_storage_keys_response - .into_iter() - .filter_map(decode_storage_key) - .collect(); - let account_ids: Vec = - scores_storage_keys.iter().filter_map(key_to_account_id).collect(); - - let delegator_state_storage_keys: Vec> = account_ids - .iter() - .map(|account_id| { - storage_map_key( - "ParachainStaking", - "DelegatorState", - account_id, - &StorageHasher::Blake2_128Concat, - ) - }) - .collect(); - let delegator_states: BTreeMap> = self - .ocall_api - .get_multiple_storages_verified( - delegator_state_storage_keys, - &block_header, - &ParentchainId::Litentry, - ) - .map_err(|_| Error::Other("Failed to get multiple storages".into()))? - .into_iter() - .filter_map(|entry| { - let storage_key = decode_storage_key(entry.key)?; - let account_id = key_to_account_id(&storage_key)?; - let delegator = entry.value?; - Some((account_id, delegator)) - }) - .collect(); - - let id_graphs_storage_keys: Vec> = account_ids - .iter() - .map(|account_id| { - storage_map_key( - "IdentityManagement", - "IDGraphs", - &Identity::from(account_id.clone()), - &StorageHasher::Blake2_128Concat, - ) - }) - .collect(); - - let shard = executor.get_default_shard(); - - let accounts_graphs = self - .state_handler - .execute_on_current(&shard, |state, _| { - let mut id_graphs_accounts: BTreeMap> = BTreeMap::new(); - for id_graph_storage_key in id_graphs_storage_keys.iter() { - let id_graph: Vec<(Identity, IdentityContext)> = state - .iter_prefix::>(id_graph_storage_key) - .unwrap_or_default(); - let graph_accounts: Vec = id_graph - .iter() - .filter_map(|(identity, _)| identity.to_account_id()) - .collect(); - if let Some(account_id) = key_to_account_id(id_graph_storage_key) { - id_graphs_accounts.insert(account_id, graph_accounts); - } - } - - id_graphs_accounts - }) - .map_err(|_| Error::Other("Failed to get id graphs".into()))?; - - let extrinsic_sender = ParachainExtrinsicSender::new(); - - let update_token_staking_amount_call_index = self - .node_metadata_repository - .get_from_metadata(|m| m.update_token_staking_amount_call_indexes()) - .map_err(|_| { - Error::Other( - "Metadata retrieval for update_token_staking_amount_call_indexes failed".into(), - ) - })? - .map_err(|_| Error::Other("Invalid metadata".into()))?; - - for account_id in account_ids.iter() { - let default_id_graph = Vec::new(); - let id_graph = accounts_graphs.get(account_id).unwrap_or(&default_id_graph); - let staking_amount: Balance = id_graph - .iter() - .filter_map(|identity| { - let delegator = delegator_states.get(identity)?; - Some(delegator.total) - }) - .sum(); - let call = OpaqueCall::from_tuple(&( - update_token_staking_amount_call_index, - account_id, - staking_amount, - round_index, - )); - extrinsic_sender - .send(call) - .map_err(|_| Error::Other("Failed to send extrinsic".into()))?; - } - - let complete_reward_distribution_call_index = self - .node_metadata_repository - .get_from_metadata(|m| m.complete_reward_distribution_call_indexes()) - .map_err(|_| { - Error::Other( - "Metadata retrieval for complete_reward_distribution_call_indexes failed" - .into(), - ) - })? - .map_err(|_| Error::Other("Invalid metadata".into()))?; - - let complete_reward_distribution_call = - OpaqueCall::from_tuple(&(complete_reward_distribution_call_index.clone())); - extrinsic_sender.send(complete_reward_distribution_call).map_err(|_| { - Error::Other("Failed to send complete_reward_distribution_call extrinsic".into()) - })?; - - Ok(()) - } -} - -fn decode_storage_key(raw_key: Vec) -> Option> { - let hex_key = String::decode(&mut raw_key.as_slice()).unwrap_or_default(); - decode_hex(hex_key).ok() } -impl HandleParentchainEvents - for ParentchainEventHandler +impl HandleParentchainEvents + for ParentchainEventHandler where Executor: IndirectExecutor, - OCallApi: EnclaveOnChainOCallApi + EnclaveMetricsOCallApi, - HS: HandleState, - NMR: AccessNodeMetadata, - NMR::MetadataType: NodeMetadataTrait, + MetricsApi: EnclaveMetricsOCallApi, { fn handle_events( &self, executor: &Executor, events: impl FilterEvents, - block_header: impl Header, ) -> Result { let mut handled_events: Vec = Vec::new(); let mut successful_assertion_ids: Vec = Vec::new(); @@ -504,24 +349,6 @@ where }); } - if let Ok(events) = events.get_reward_distribution_started_events() { - println!("Handling RewardDistributionStarted events"); - events - .iter() - .try_for_each(|event| { - let event_hash = hash_of(&event); - let result = self.update_staking_scores( - executor, - block_header.clone(), - event.round_index, - ); - handled_events.push(event_hash); - - result - }) - .map_err(|_| ParentchainEventProcessingError::RewardDistributionStartedFailure)?; - } - Ok((handled_events, successful_assertion_ids, failed_assertion_ids)) } } diff --git a/tee-worker/app-libs/parentchain-interface/src/target_a/event_filter.rs b/tee-worker/app-libs/parentchain-interface/src/target_a/event_filter.rs index 8209b16a18..2490b2e1d9 100644 --- a/tee-worker/app-libs/parentchain-interface/src/target_a/event_filter.rs +++ b/tee-worker/app-libs/parentchain-interface/src/target_a/event_filter.rs @@ -105,10 +105,4 @@ impl FilterEvents for FilterableEvents { ) -> Result, Self::Error> { Ok(Vec::new()) } - - fn get_reward_distribution_started_events( - &self, - ) -> Result, Self::Error> { - Ok(Vec::new()) - } } diff --git a/tee-worker/app-libs/parentchain-interface/src/target_a/event_handler.rs b/tee-worker/app-libs/parentchain-interface/src/target_a/event_handler.rs index a73312c63e..af091e98f8 100644 --- a/tee-worker/app-libs/parentchain-interface/src/target_a/event_handler.rs +++ b/tee-worker/app-libs/parentchain-interface/src/target_a/event_handler.rs @@ -22,7 +22,6 @@ use itc_parentchain_indirect_calls_executor::error::Error; use itp_stf_primitives::traits::IndirectExecutor; use itp_types::parentchain::{FilterEvents, HandleParentchainEvents, ProcessedEventsArtifacts}; use log::*; -use sp_runtime::traits::Header; use sp_std::vec::Vec; pub struct ParentchainEventHandler {} @@ -36,7 +35,6 @@ where &self, _executor: &Executor, _events: impl FilterEvents, - _block_header: impl Header, ) -> Result { debug!("not handling any events for target a"); Ok((Vec::new(), Vec::new(), Vec::new())) diff --git a/tee-worker/app-libs/parentchain-interface/src/target_b/event_filter.rs b/tee-worker/app-libs/parentchain-interface/src/target_b/event_filter.rs index 8209b16a18..2490b2e1d9 100644 --- a/tee-worker/app-libs/parentchain-interface/src/target_b/event_filter.rs +++ b/tee-worker/app-libs/parentchain-interface/src/target_b/event_filter.rs @@ -105,10 +105,4 @@ impl FilterEvents for FilterableEvents { ) -> Result, Self::Error> { Ok(Vec::new()) } - - fn get_reward_distribution_started_events( - &self, - ) -> Result, Self::Error> { - Ok(Vec::new()) - } } diff --git a/tee-worker/app-libs/parentchain-interface/src/target_b/event_handler.rs b/tee-worker/app-libs/parentchain-interface/src/target_b/event_handler.rs index ce279228bf..56151a9ccc 100644 --- a/tee-worker/app-libs/parentchain-interface/src/target_b/event_handler.rs +++ b/tee-worker/app-libs/parentchain-interface/src/target_b/event_handler.rs @@ -22,7 +22,6 @@ use itc_parentchain_indirect_calls_executor::error::Error; use itp_stf_primitives::traits::IndirectExecutor; use itp_types::parentchain::{FilterEvents, HandleParentchainEvents, ProcessedEventsArtifacts}; use log::*; -use sp_runtime::traits::Header; use sp_std::vec::Vec; pub struct ParentchainEventHandler {} @@ -36,7 +35,6 @@ where &self, _executor: &Executor, _events: impl FilterEvents, - _block_header: impl Header, ) -> Result { debug!("not handling any events for target B"); Ok((Vec::new(), Vec::new(), Vec::new())) diff --git a/tee-worker/core-primitives/extrinsics-factory/src/lib.rs b/tee-worker/core-primitives/extrinsics-factory/src/lib.rs index f869917b27..ab58d65853 100644 --- a/tee-worker/core-primitives/extrinsics-factory/src/lib.rs +++ b/tee-worker/core-primitives/extrinsics-factory/src/lib.rs @@ -35,7 +35,7 @@ use itp_node_api::{ api_client::{ ExtrinsicParams, ParentchainAdditionalParams, ParentchainExtrinsicParams, SignExtrinsic, }, - metadata::{provider::AccessNodeMetadata, NodeMetadata, NodeMetadataProvider}, + metadata::{provider::AccessNodeMetadata, NodeMetadata}, }; use itp_nonce_cache::{MutateNonce, Nonce}; use itp_types::{parentchain::AccountId, OpaqueCall}; diff --git a/tee-worker/core-primitives/node-api/metadata/src/lib.rs b/tee-worker/core-primitives/node-api/metadata/src/lib.rs index 5625e77ed1..1705582b90 100644 --- a/tee-worker/core-primitives/node-api/metadata/src/lib.rs +++ b/tee-worker/core-primitives/node-api/metadata/src/lib.rs @@ -22,10 +22,9 @@ use crate::{ error::Result, pallet_balances::BalancesCallIndexes, pallet_evm_assertion::EvmAssertionsCallIndexes, pallet_imp::IMPCallIndexes, - pallet_proxy::ProxyCallIndexes, pallet_score_staking::ScoreStakingCallIndexes, - pallet_system::SystemConstants, pallet_teebag::TeebagCallIndexes, - pallet_timestamp::TimestampCallIndexes, pallet_utility::UtilityCallIndexes, - pallet_vcmp::VCMPCallIndexes, + pallet_proxy::ProxyCallIndexes, pallet_system::SystemConstants, + pallet_teebag::TeebagCallIndexes, pallet_timestamp::TimestampCallIndexes, + pallet_utility::UtilityCallIndexes, pallet_vcmp::VCMPCallIndexes, }; use codec::{Decode, Encode}; use sp_core::storage::StorageKey; @@ -38,7 +37,6 @@ pub mod pallet_balances; pub mod pallet_evm_assertion; pub mod pallet_imp; pub mod pallet_proxy; -pub mod pallet_score_staking; pub mod pallet_system; pub mod pallet_teebag; pub mod pallet_utility; @@ -50,10 +48,6 @@ pub mod pallet_timestamp; #[cfg(feature = "mocks")] pub mod metadata_mocks; -pub trait NodeMetadataProvider { - fn get_metadata(&self) -> Option<&Metadata>; -} - pub trait NodeMetadataTrait: TeebagCallIndexes + IMPCallIndexes @@ -64,8 +58,6 @@ pub trait NodeMetadataTrait: + BalancesCallIndexes + TimestampCallIndexes + EvmAssertionsCallIndexes - + ScoreStakingCallIndexes - + NodeMetadataProvider { } @@ -78,9 +70,7 @@ impl< + ProxyCallIndexes + BalancesCallIndexes + TimestampCallIndexes - + EvmAssertionsCallIndexes - + ScoreStakingCallIndexes - + NodeMetadataProvider, + + EvmAssertionsCallIndexes, > NodeMetadataTrait for T { } @@ -113,6 +103,10 @@ impl NodeMetadata { } } + pub fn get_metadata(&self) -> Option<&Metadata> { + self.node_metadata.as_ref() + } + /// Return the substrate chain runtime version. pub fn get_runtime_version(&self) -> u32 { self.runtime_spec_version @@ -187,9 +181,3 @@ impl NodeMetadata { } } } - -impl NodeMetadataProvider for NodeMetadata { - fn get_metadata(&self) -> Option<&Metadata> { - self.node_metadata.as_ref() - } -} diff --git a/tee-worker/core-primitives/node-api/metadata/src/metadata_mocks.rs b/tee-worker/core-primitives/node-api/metadata/src/metadata_mocks.rs index a4461eb72a..adf13c8cf8 100644 --- a/tee-worker/core-primitives/node-api/metadata/src/metadata_mocks.rs +++ b/tee-worker/core-primitives/node-api/metadata/src/metadata_mocks.rs @@ -18,10 +18,9 @@ use crate::{ error::Result, pallet_balances::BalancesCallIndexes, pallet_evm_assertion::EvmAssertionsCallIndexes, pallet_imp::IMPCallIndexes, - pallet_proxy::ProxyCallIndexes, pallet_score_staking::ScoreStakingCallIndexes, - pallet_system::SystemConstants, pallet_teebag::TeebagCallIndexes, - pallet_timestamp::TimestampCallIndexes, pallet_utility::UtilityCallIndexes, - pallet_vcmp::VCMPCallIndexes, runtime_call::RuntimeCall, NodeMetadataProvider, + pallet_proxy::ProxyCallIndexes, pallet_system::SystemConstants, + pallet_teebag::TeebagCallIndexes, pallet_timestamp::TimestampCallIndexes, + pallet_utility::UtilityCallIndexes, pallet_vcmp::VCMPCallIndexes, runtime_call::RuntimeCall, }; use codec::{Decode, Encode}; @@ -89,11 +88,6 @@ pub struct NodeMetadataMock { timestamp_set: u8, runtime_spec_version: u32, runtime_transaction_version: u32, - - //ScoreStaking - score_staking_module: u8, - update_token_staking_amount: u8, - complete_reward_distribution: u8, } impl NodeMetadataMock { @@ -149,10 +143,6 @@ impl NodeMetadataMock { timestamp_set: 0, runtime_spec_version: 25, runtime_transaction_version: 4, - - score_staking_module: 100u8, - update_token_staking_amount: 0u8, - complete_reward_distribution: 1u8, } } } @@ -187,16 +177,6 @@ impl TeebagCallIndexes for NodeMetadataMock { } } -impl ScoreStakingCallIndexes for NodeMetadataMock { - fn update_token_staking_amount_call_indexes(&self) -> Result<[u8; 2]> { - Ok([self.score_staking_module, self.update_token_staking_amount]) - } - - fn complete_reward_distribution_call_indexes(&self) -> Result<[u8; 2]> { - Ok([self.score_staking_module, self.complete_reward_distribution]) - } -} - impl IMPCallIndexes for NodeMetadataMock { fn link_identity_call_indexes(&self) -> Result<[u8; 2]> { Ok([self.imp_module, self.imp_link_identity]) @@ -330,9 +310,3 @@ impl EvmAssertionsCallIndexes for NodeMetadataMock { Ok([self.evm_assertions_module, self.evm_assertions_void_assertion]) } } - -impl NodeMetadataProvider for NodeMetadataMock { - fn get_metadata(&self) -> Option<&Metadata> { - None - } -} diff --git a/tee-worker/core-primitives/node-api/metadata/src/pallet_score_staking.rs b/tee-worker/core-primitives/node-api/metadata/src/pallet_score_staking.rs deleted file mode 100644 index 9450e36c01..0000000000 --- a/tee-worker/core-primitives/node-api/metadata/src/pallet_score_staking.rs +++ /dev/null @@ -1,36 +0,0 @@ -/* - Copyright 2021 Integritee AG and Supercomputing Systems AG - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - -*/ -use crate::{error::Result, NodeMetadata}; - -/// Pallet' name: -pub const SCORE_STAKING: &str = "ScoreStaking"; - -// we only list the extrinsics that we care -pub trait ScoreStakingCallIndexes { - fn update_token_staking_amount_call_indexes(&self) -> Result<[u8; 2]>; - - fn complete_reward_distribution_call_indexes(&self) -> Result<[u8; 2]>; -} - -impl ScoreStakingCallIndexes for NodeMetadata { - fn update_token_staking_amount_call_indexes(&self) -> Result<[u8; 2]> { - self.call_indexes(SCORE_STAKING, "update_token_staking_amount") - } - fn complete_reward_distribution_call_indexes(&self) -> Result<[u8; 2]> { - self.call_indexes(SCORE_STAKING, "complete_reward_distribution") - } -} diff --git a/tee-worker/core-primitives/storage/src/keys.rs b/tee-worker/core-primitives/storage/src/keys.rs index c4767097d7..43de4f667e 100644 --- a/tee-worker/core-primitives/storage/src/keys.rs +++ b/tee-worker/core-primitives/storage/src/keys.rs @@ -17,7 +17,6 @@ use codec::Encode; use frame_metadata::v14::StorageHasher; -use sp_core::crypto::AccountId32 as AccountId; use sp_std::vec::Vec; pub fn storage_value_key(module_prefix: &str, storage_prefix: &str) -> Vec { @@ -70,16 +69,3 @@ fn key_hash(key: &K, hasher: &StorageHasher) -> Vec { StorageHasher::Twox64Concat => sp_core::twox_64(&encoded_key).to_vec(), } } - -/// Extracts the AccountId from a storage key -pub fn key_to_account_id(key: &Vec) -> Option { - if key.len() >= 32 { - let account_id_bytes = &key[key.len() - 32..]; - let mut account_id_32_bytes = [0; 32]; - account_id_32_bytes.copy_from_slice(account_id_bytes); - - Some(AccountId::new(account_id_32_bytes)) - } else { - None - } -} diff --git a/tee-worker/core-primitives/types/src/lib.rs b/tee-worker/core-primitives/types/src/lib.rs index 35c31f1f18..a4d58a2969 100644 --- a/tee-worker/core-primitives/types/src/lib.rs +++ b/tee-worker/core-primitives/types/src/lib.rs @@ -29,8 +29,8 @@ pub mod storage; pub use itp_sgx_runtime_primitives::types::*; pub use litentry_primitives::{ - Assertion, AttestationType, DcapProvider, DecryptableRequest, Delegator, Enclave, - EnclaveFingerprint, MrEnclave, SidechainBlockNumber, WorkerType, + Assertion, AttestationType, DcapProvider, DecryptableRequest, Enclave, EnclaveFingerprint, + MrEnclave, SidechainBlockNumber, WorkerType, }; pub use sp_core::{crypto::AccountId32 as AccountId, H256}; diff --git a/tee-worker/core-primitives/types/src/parentchain/events.rs b/tee-worker/core-primitives/types/src/parentchain/events.rs index 3cce6e2e10..f6b40d1339 100644 --- a/tee-worker/core-primitives/types/src/parentchain/events.rs +++ b/tee-worker/core-primitives/types/src/parentchain/events.rs @@ -244,28 +244,3 @@ impl StaticEvent for AssertionCreated { const PALLET: &'static str = "EvmAssertions"; const EVENT: &'static str = "AssertionCreated"; } - -#[derive(Encode, Decode, Debug)] -pub struct RewardDistributionStarted { - pub total: Balance, - pub distributed: Balance, - pub round_index: u32, -} - -impl core::fmt::Display for RewardDistributionStarted { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { - let message = format!( - "{:?} :: total: {}, distributed: {}, round_index: {}", - RewardDistributionStarted::EVENT, - self.total, - self.distributed, - self.round_index - ); - write!(f, "{}", message) - } -} - -impl StaticEvent for RewardDistributionStarted { - const PALLET: &'static str = "ScoreStaking"; - const EVENT: &'static str = "RewardDistributionStarted"; -} diff --git a/tee-worker/core-primitives/types/src/parentchain/mod.rs b/tee-worker/core-primitives/types/src/parentchain/mod.rs index 34bd9f24fa..723127eafa 100644 --- a/tee-worker/core-primitives/types/src/parentchain/mod.rs +++ b/tee-worker/core-primitives/types/src/parentchain/mod.rs @@ -23,17 +23,13 @@ use codec::{Decode, Encode}; use core::fmt::Debug; use events::{ ActivateIdentityRequested, DeactivateIdentityRequested, EnclaveUnauthorized, - LinkIdentityRequested, OpaqueTaskPosted, RewardDistributionStarted, VCRequested, + LinkIdentityRequested, OpaqueTaskPosted, VCRequested, }; use itp_stf_primitives::traits::{IndirectExecutor, TrustedCallVerification}; #[cfg(feature = "std")] use serde::{Deserialize, Serialize}; use sp_core::{bounded::alloc, H160, H256}; -use sp_runtime::{ - generic::Header as HeaderG, - traits::{BlakeTwo256, Header as HeaderT}, - MultiAddress, MultiSignature, -}; +use sp_runtime::{generic::Header as HeaderG, traits::BlakeTwo256, MultiAddress, MultiSignature}; use self::events::ParentchainBlockProcessed; @@ -120,10 +116,6 @@ pub trait FilterEvents { fn get_parentchain_block_proccessed_events( &self, ) -> Result, Self::Error>; - - fn get_reward_distribution_started_events( - &self, - ) -> Result, Self::Error>; } #[derive(Debug)] @@ -143,7 +135,6 @@ where &self, executor: &Executor, events: impl FilterEvents, - block_header: impl HeaderT, ) -> Result; } @@ -158,7 +149,6 @@ pub enum ParentchainEventProcessingError { OpaqueTaskPostedFailure, AssertionCreatedFailure, ParentchainBlockProcessedFailure, - RewardDistributionStartedFailure, } impl core::fmt::Display for ParentchainEventProcessingError { @@ -182,8 +172,6 @@ impl core::fmt::Display for ParentchainEventProcessingError { "Parentchain Event Processing Error: AssertionCreatedFailure", ParentchainEventProcessingError::ParentchainBlockProcessedFailure => "Parentchain Event Processing Error: ParentchainBlockProcessedFailure", - ParentchainEventProcessingError::RewardDistributionStartedFailure => - "Parentchain Event Processing Error: RewardDistributionStartedFailure", }; write!(f, "{}", message) } diff --git a/tee-worker/core/parentchain/indirect-calls-executor/src/executor.rs b/tee-worker/core/parentchain/indirect-calls-executor/src/executor.rs index 14815c880a..61ced37b8a 100644 --- a/tee-worker/core/parentchain/indirect-calls-executor/src/executor.rs +++ b/tee-worker/core/parentchain/indirect-calls-executor/src/executor.rs @@ -167,9 +167,8 @@ impl< })? .ok_or_else(|| Error::Other("Could not create events from metadata".into()))?; - let (processed_events, successful_assertion_ids, failed_assertion_ids) = self - .parentchain_event_handler - .handle_events(self, events, block.header().clone())?; + let (processed_events, successful_assertion_ids, failed_assertion_ids) = + self.parentchain_event_handler.handle_events(self, events)?; let mut calls: Vec = Vec::new(); if !successful_assertion_ids.is_empty() { calls.extend(self.create_assertion_stored_call(successful_assertion_ids)?); diff --git a/tee-worker/core/parentchain/indirect-calls-executor/src/mock.rs b/tee-worker/core/parentchain/indirect-calls-executor/src/mock.rs index ad621adef6..bc63f95317 100644 --- a/tee-worker/core/parentchain/indirect-calls-executor/src/mock.rs +++ b/tee-worker/core/parentchain/indirect-calls-executor/src/mock.rs @@ -12,7 +12,6 @@ use itp_types::{ RsaRequest, H256, }; use sp_core::H160; -use sp_runtime::traits::Header; use std::vec::Vec; pub struct TestEventCreator; @@ -71,12 +70,6 @@ impl FilterEvents for MockEvents { ) -> Result, Self::Error> { Ok(Vec::new()) } - - fn get_reward_distribution_started_events( - &self, - ) -> Result, Self::Error> { - Ok(Vec::new()) - } } pub struct MockParentchainEventHandler {} @@ -90,7 +83,6 @@ where &self, _: &Executor, _: impl FilterEvents, - _: impl Header, ) -> Result { Ok(( Vec::from([H256::default()]), diff --git a/tee-worker/enclave-runtime/Cargo.lock b/tee-worker/enclave-runtime/Cargo.lock index fa4b39f168..e589c28d07 100644 --- a/tee-worker/enclave-runtime/Cargo.lock +++ b/tee-worker/enclave-runtime/Cargo.lock @@ -1966,7 +1966,6 @@ dependencies = [ name = "ita-parentchain-interface" version = "0.1.0" dependencies = [ - "frame-support", "ita-sgx-runtime", "ita-stf", "itc-parentchain-indirect-calls-executor", @@ -1974,18 +1973,12 @@ dependencies = [ "itp-enclave-metrics", "itp-node-api", "itp-ocall-api", - "itp-sgx-externalities", "itp-stf-primitives", - "itp-stf-state-handler", - "itp-storage", "itp-types", "lc-dynamic-assertion", "lc-evm-dynamic-assertions", - "lc-parachain-extrinsic-task-sender", - "litentry-hex-utils 0.1.0", "litentry-primitives", "log", - "pallet-identity-management-tee", "parity-scale-codec", "sgx_tstd", "sp-core", @@ -3391,9 +3384,7 @@ dependencies = [ "core-primitives", "hex", "itp-sgx-crypto", - "itp-utils", "log", - "pallet-parachain-staking", "pallet-teebag", "parity-scale-codec", "rand 0.7.3", diff --git a/tee-worker/enclave-runtime/src/initialization/global_components.rs b/tee-worker/enclave-runtime/src/initialization/global_components.rs index 939d69fe18..5255d5303e 100644 --- a/tee-worker/enclave-runtime/src/initialization/global_components.rs +++ b/tee-worker/enclave-runtime/src/initialization/global_components.rs @@ -177,11 +177,7 @@ pub type IntegriteeParentchainIndirectCallsExecutor = IndirectCallsExecutor< EnclaveTopPoolAuthor, EnclaveNodeMetadataRepository, EventCreator, - integritee::ParentchainEventHandler< - EnclaveOCallApi, - EnclaveStateHandler, - EnclaveNodeMetadataRepository, - >, + integritee::ParentchainEventHandler, EnclaveTrustedCallSigned, EnclaveGetter, >; diff --git a/tee-worker/enclave-runtime/src/initialization/parentchain/common.rs b/tee-worker/enclave-runtime/src/initialization/parentchain/common.rs index 40fa90d6c7..52b345d75a 100644 --- a/tee-worker/enclave-runtime/src/initialization/parentchain/common.rs +++ b/tee-worker/enclave-runtime/src/initialization/parentchain/common.rs @@ -69,13 +69,10 @@ pub(crate) fn create_integritee_parentchain_block_importer( let shielding_key_repository = GLOBAL_SHIELDING_KEY_REPOSITORY_COMPONENT.get()?; let ocall_api = GLOBAL_OCALL_API_COMPONENT.get()?; let repository = GLOBAL_ASSERTION_REPOSITORY.get()?; - let state_handler = GLOBAL_STATE_HANDLER_COMPONENT.get()?; let parentchain_event_handler = LitentryParentchainEventHandler { assertion_repository: repository, - ocall_api: ocall_api.clone(), - state_handler, - node_metadata_repository: node_metadata_repository.clone(), + metrics_api: ocall_api.clone(), }; let stf_enclave_signer = Arc::new(EnclaveStfEnclaveSigner::new( diff --git a/tee-worker/litentry/primitives/Cargo.toml b/tee-worker/litentry/primitives/Cargo.toml index adbc8da826..9f3a4e6cfa 100644 --- a/tee-worker/litentry/primitives/Cargo.toml +++ b/tee-worker/litentry/primitives/Cargo.toml @@ -25,8 +25,6 @@ sgx_tstd = { git = "https://github.com/apache/teaclave-sgx-sdk.git", branch = "m # internal dependencies itp-sgx-crypto = { path = "../../core-primitives/sgx/crypto", default-features = false } -itp-utils = { path = "../../core-primitives/utils", default-features = false } -pallet-parachain-staking = { git = "https://github.com/litentry/litentry-parachain", branch = "release-v0.9.19", default-features = false } pallet-teebag = { git = "https://github.com/litentry/litentry-parachain", branch = "release-v0.9.19", default-features = false } parentchain-primitives = { package = "core-primitives", git = "https://github.com/litentry/litentry-parachain", branch = "release-v0.9.19", default-features = false } diff --git a/tee-worker/litentry/primitives/src/lib.rs b/tee-worker/litentry/primitives/src/lib.rs index 1f05bb0afc..da8d5e8e94 100644 --- a/tee-worker/litentry/primitives/src/lib.rs +++ b/tee-worker/litentry/primitives/src/lib.rs @@ -42,7 +42,6 @@ use bitcoin::sign_message::{signed_msg_hash, MessageSignature}; use codec::{Decode, Encode, MaxEncodedLen}; use itp_sgx_crypto::ShieldingCryptoDecrypt; use log::error; -pub use pallet_parachain_staking::Delegator; pub use pallet_teebag::{ decl_rsa_request, extract_tcb_info_from_raw_dcap_quote, AttestationType, DcapProvider, Enclave, EnclaveFingerprint, MrEnclave, ShardIdentifier, SidechainBlockNumber, WorkerMode, WorkerType,