From 7d98b24d20edd4b943ed7ee623c215c99eb3f875 Mon Sep 17 00:00:00 2001 From: Jianwei Zhu Date: Wed, 4 Dec 2024 10:58:31 -0800 Subject: [PATCH] eliminate gas fee requirement for syncing GK messages --- pallets/phala/src/mq.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pallets/phala/src/mq.rs b/pallets/phala/src/mq.rs index b059b6438c..0612b4c22a 100644 --- a/pallets/phala/src/mq.rs +++ b/pallets/phala/src/mq.rs @@ -66,7 +66,7 @@ pub mod pallet { pub fn sync_offchain_message( origin: OriginFor, signed_message: SignedMessage, - ) -> DispatchResult { + ) -> DispatchResultWithPostInfo { ensure_signed(origin)?; // Check sender @@ -89,9 +89,16 @@ pub mod pallet { crate::registry::Pallet::::check_message(&signed_message)?; // Update ingress OffchainIngress::::insert(sender.clone(), expected_seq + 1); + // Check if is Gatekeeper + let is_gatekeeper = matches!(sender, phala_types::messaging::SenderId::Gatekeeper); // Call dispatch_message Self::dispatch_message(signed_message.message); - Ok(()) + + if is_gatekeeper { + Ok(Pays::No.into()) + } else { + Ok(Pays::Yes.into()) + } } // Messaging API for end user.