diff --git a/parachain/Cargo.lock b/parachain/Cargo.lock index 2a79d8546f..4b7e019a05 100644 --- a/parachain/Cargo.lock +++ b/parachain/Cargo.lock @@ -7582,6 +7582,7 @@ dependencies = [ "pallet-group", "pallet-teebag", "pallet-timestamp", + "pallet-utility", "parity-scale-codec", "scale-info", "sp-core", @@ -8108,6 +8109,7 @@ dependencies = [ "log", "pallet-balances", "pallet-timestamp", + "pallet-utility", "parity-scale-codec", "ring 0.16.20", "rustls-webpki 0.102.0-alpha.3", @@ -8249,6 +8251,7 @@ dependencies = [ "pallet-group", "pallet-teebag", "pallet-timestamp", + "pallet-utility", "parity-scale-codec", "scale-info", "sp-core", diff --git a/parachain/pallets/identity-management/Cargo.toml b/parachain/pallets/identity-management/Cargo.toml index 1c3ceb5355..8973e277aa 100644 --- a/parachain/pallets/identity-management/Cargo.toml +++ b/parachain/pallets/identity-management/Cargo.toml @@ -26,6 +26,7 @@ pallet-timestamp = { workspace = true, features = ["std"] } sp-io = { workspace = true, features = ["std"] } pallet-teebag = { workspace = true, features = ["std", "test-util"] } pallet-group = { workspace = true, features = ["std"] } +pallet-utility = { workspace = true, features = ["std"] } [features] default = ["std"] diff --git a/parachain/pallets/identity-management/src/mock.rs b/parachain/pallets/identity-management/src/mock.rs index 79777fdd20..900dd41dfc 100644 --- a/parachain/pallets/identity-management/src/mock.rs +++ b/parachain/pallets/identity-management/src/mock.rs @@ -81,6 +81,7 @@ frame_support::construct_runtime!( Timestamp: pallet_timestamp, IdentityManagement: pallet_identity_management, IMPExtrinsicWhitelist: pallet_group, + Utility: pallet_utility, } ); @@ -164,6 +165,13 @@ impl pallet_group::Config for Test { type GroupManagerOrigin = frame_system::EnsureRoot; } +impl pallet_utility::Config for Test { + type RuntimeEvent = RuntimeEvent; + type RuntimeCall = RuntimeCall; + type PalletsOrigin = OriginCaller; + type WeightInfo = (); +} + pub fn new_test_ext() -> sp_io::TestExternalities { use pallet_teebag::test_util::{ get_signer, TEST8_CERT, TEST8_SIGNER_PUB, TEST8_TIMESTAMP, URL, diff --git a/parachain/pallets/teebag/Cargo.toml b/parachain/pallets/teebag/Cargo.toml index f86d1e55aa..6ab25e821c 100644 --- a/parachain/pallets/teebag/Cargo.toml +++ b/parachain/pallets/teebag/Cargo.toml @@ -28,6 +28,7 @@ frame-support = { workspace = true } frame-system = { workspace = true } pallet-balances = { workspace = true, optional = true } pallet-timestamp = { workspace = true } +pallet-utility = { workspace = true } sp-core = { workspace = true } sp-io = { workspace = true } sp-runtime = { workspace = true } @@ -62,12 +63,14 @@ std = [ "sp-std/std", "pallet-timestamp/std", "pallet-balances?/std", + "pallet-utility/std", ] runtime-benchmarks = [ "frame-support/runtime-benchmarks", "frame-benchmarking/runtime-benchmarks", "pallet-balances?/runtime-benchmarks", "pallet-timestamp/runtime-benchmarks", + "pallet-utility/runtime-benchmarks", ] try-runtime = ["frame-support/try-runtime"] # workaround to cross crate boundary, see https://github.com/rust-lang/cargo/issues/8379 diff --git a/parachain/pallets/teebag/src/lib.rs b/parachain/pallets/teebag/src/lib.rs index e1a7066ff4..8ae095b3e3 100644 --- a/parachain/pallets/teebag/src/lib.rs +++ b/parachain/pallets/teebag/src/lib.rs @@ -65,7 +65,9 @@ pub mod pallet { pub struct Pallet(PhantomData); #[pallet::config] - pub trait Config: frame_system::Config + pallet_timestamp::Config { + pub trait Config: + frame_system::Config + pallet_timestamp::Config + pallet_utility::Config + { type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Weight information for extrinsics in this pallet. type WeightInfo: WeightInfo; @@ -668,6 +670,38 @@ pub mod pallet { Self::finalize_block(sender, shard, confirmation); Ok(Pays::No.into()) } + + // A wrapper to utility.call to waive the tx fee if the caller is tee-worker + // the weight is copied from pallet_utility + #[pallet::call_index(23)] + #[pallet::weight({ + use pallet_utility::WeightInfo; + let dispatch_infos = calls.iter().map(|call| call.get_dispatch_info()).collect::>(); + let dispatch_weight = dispatch_infos.iter() + .map(|di| di.weight) + .fold(Weight::zero(), |total: Weight, weight: Weight| total.saturating_add(weight)) + .saturating_add(::WeightInfo::batch(calls.len() as u32)); + let dispatch_class = { + let all_operational = dispatch_infos.iter() + .map(|di| di.class) + .all(|class| class == DispatchClass::Operational); + if all_operational { + DispatchClass::Operational + } else { + DispatchClass::Normal + } + }; + (dispatch_weight, dispatch_class) + })] + pub fn batch( + origin: OriginFor, + calls: Vec<::RuntimeCall>, + ) -> DispatchResultWithPostInfo { + let sender = ensure_signed(origin.clone())?; + let _ = EnclaveRegistry::::get(&sender).ok_or(Error::::EnclaveNotExist)?; + let _ = pallet_utility::Pallet::::batch(origin, calls)?; + Ok(Pays::No.into()) + } } } diff --git a/parachain/pallets/teebag/src/mock.rs b/parachain/pallets/teebag/src/mock.rs index 7bb394a67a..c7fae0291e 100644 --- a/parachain/pallets/teebag/src/mock.rs +++ b/parachain/pallets/teebag/src/mock.rs @@ -49,6 +49,7 @@ construct_runtime!( Balances: pallet_balances, Timestamp: pallet_timestamp, Teebag: pallet_teebag, + Utility: pallet_utility, } ); @@ -129,6 +130,13 @@ impl pallet_teebag::Config for Test { type WeightInfo = (); } +impl pallet_utility::Config for Test { + type RuntimeEvent = RuntimeEvent; + type RuntimeCall = RuntimeCall; + type PalletsOrigin = OriginCaller; + type WeightInfo = (); +} + // This function basically just builds a genesis storage key/value store according to // our desired mockup. RA from enclave compiled in debug mode is allowed pub fn new_test_ext(is_dev_mode: bool) -> sp_io::TestExternalities { diff --git a/parachain/pallets/vc-management/Cargo.toml b/parachain/pallets/vc-management/Cargo.toml index 697322c5aa..60cff00356 100644 --- a/parachain/pallets/vc-management/Cargo.toml +++ b/parachain/pallets/vc-management/Cargo.toml @@ -27,7 +27,7 @@ pallet-timestamp = { workspace = true, features = ["std"] } sp-io = { workspace = true, features = ["std"] } pallet-group = { workspace = true, features = ["std"] } pallet-teebag = { workspace = true, features = ["std", "test-util"] } - +pallet-utility = { workspace = true, features = ["std"] } [features] default = ["std"] @@ -52,5 +52,6 @@ std = [ "pallet-teebag/std", "pallet-balances/std", "pallet-group/std", + "pallet-utility/std", ] try-runtime = ["frame-support/try-runtime"] diff --git a/parachain/pallets/vc-management/src/mock.rs b/parachain/pallets/vc-management/src/mock.rs index a8242d0f1c..3e9f9b10fa 100644 --- a/parachain/pallets/vc-management/src/mock.rs +++ b/parachain/pallets/vc-management/src/mock.rs @@ -78,6 +78,7 @@ frame_support::construct_runtime!( Balances: pallet_balances, Teebag: pallet_teebag, Timestamp: pallet_timestamp, + Utility: pallet_utility, VCManagement: pallet_vc_management, VCMPExtrinsicWhitelist: pallet_group, } @@ -163,6 +164,13 @@ impl pallet_group::Config for Test { type GroupManagerOrigin = frame_system::EnsureRoot; } +impl pallet_utility::Config for Test { + type RuntimeEvent = RuntimeEvent; + type RuntimeCall = RuntimeCall; + type PalletsOrigin = OriginCaller; + type WeightInfo = (); +} + pub fn new_test_ext() -> sp_io::TestExternalities { use pallet_teebag::test_util::{ get_signer, TEST8_CERT, TEST8_SIGNER_PUB, TEST8_TIMESTAMP, URL, diff --git a/parachain/runtime/litentry/src/lib.rs b/parachain/runtime/litentry/src/lib.rs index 0fe656a87f..176f7164d3 100644 --- a/parachain/runtime/litentry/src/lib.rs +++ b/parachain/runtime/litentry/src/lib.rs @@ -221,7 +221,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { impl_name: create_runtime_str!("litentry-parachain"), authoring_version: 1, // same versioning-mechanism as polkadot: use last digit for minor updates - spec_version: 9200, + spec_version: 9201, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 1, diff --git a/parachain/runtime/paseo/src/lib.rs b/parachain/runtime/paseo/src/lib.rs index 8c5267e471..e18997cdff 100644 --- a/parachain/runtime/paseo/src/lib.rs +++ b/parachain/runtime/paseo/src/lib.rs @@ -227,7 +227,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { impl_name: create_runtime_str!("paseo-parachain"), authoring_version: 1, // same versioning-mechanism as polkadot: use last digit for minor updates - spec_version: 9200, + spec_version: 9201, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 1, diff --git a/parachain/runtime/rococo/src/lib.rs b/parachain/runtime/rococo/src/lib.rs index ba7f2ca240..334234027c 100644 --- a/parachain/runtime/rococo/src/lib.rs +++ b/parachain/runtime/rococo/src/lib.rs @@ -226,7 +226,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { impl_name: create_runtime_str!("rococo-parachain"), authoring_version: 1, // same versioning-mechanism as polkadot: use last digit for minor updates - spec_version: 9200, + spec_version: 9201, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 1, diff --git a/tee-worker/common/core-primitives/extrinsics-factory/src/lib.rs b/tee-worker/common/core-primitives/extrinsics-factory/src/lib.rs index ab58d65853..f5b831f853 100644 --- a/tee-worker/common/core-primitives/extrinsics-factory/src/lib.rs +++ b/tee-worker/common/core-primitives/extrinsics-factory/src/lib.rs @@ -166,7 +166,7 @@ where (metadata.clone(), m.get_runtime_version(), m.get_runtime_transaction_version()) })?; let batch_call = - OpaqueCall::from_tuple(&compose_call!(node_metadata, "Utility", "batch", calls)); + OpaqueCall::from_tuple(&compose_call!(node_metadata, "Teebag", "batch", calls)); let mut nonce_lock = self.nonce_cache.load_for_mutation()?; let mut nonce_value = nonce_lock.0;