-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
report back intent execution result #3132
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,7 @@ mod mock; | |
#[cfg(test)] | ||
mod tests; | ||
|
||
pub use core_primitives::{Identity, Intention, MemberAccount, OmniAccountConverter}; | ||
pub use core_primitives::{Identity, Intent, MemberAccount, OmniAccountConverter}; | ||
pub use frame_system::pallet_prelude::BlockNumberFor; | ||
pub use pallet::*; | ||
|
||
|
@@ -55,6 +55,13 @@ pub enum RawOrigin<AccountId> { | |
pub mod pallet { | ||
use super::*; | ||
|
||
#[derive(PartialEq, Eq, Clone, RuntimeDebug, Encode, Decode, TypeInfo)] | ||
pub enum IntentExecutionResult { | ||
Success, | ||
Failure, | ||
} | ||
|
||
/// The current storage version. | ||
const STORAGE_VERSION: StorageVersion = StorageVersion::new(0); | ||
|
||
#[pallet::pallet] | ||
|
@@ -97,6 +104,8 @@ pub mod pallet { | |
|
||
/// Convert an `Identity` to OmniAccount type | ||
type OmniAccountConverter: OmniAccountConverter<OmniAccount = Self::AccountId>; | ||
|
||
type SetOmniExecutorOrigin: EnsureOrigin<<Self as frame_system::Config>::RuntimeOrigin>; | ||
} | ||
|
||
pub type MemberAccounts<T> = BoundedVec<MemberAccount, <T as Config>::MaxAccountStoreLength>; | ||
|
@@ -115,6 +124,10 @@ pub mod pallet { | |
pub type MemberAccountHash<T: Config> = | ||
StorageMap<Hasher = Blake2_128Concat, Key = H256, Value = T::AccountId>; | ||
|
||
#[pallet::storage] | ||
#[pallet::getter(fn omni_executor)] | ||
pub type OmniExecutor<T: Config> = StorageValue<_, T::AccountId, OptionQuery>; | ||
|
||
#[pallet::event] | ||
#[pallet::generate_deposit(pub(super) fn deposit_event)] | ||
pub enum Event<T: Config> { | ||
|
@@ -132,8 +145,12 @@ pub mod pallet { | |
DispatchedAsOmniAccount { who: T::AccountId, result: DispatchResult }, | ||
/// Some call is dispatched as signed origin | ||
DispatchedAsSigned { who: T::AccountId, result: DispatchResult }, | ||
/// Intention is requested | ||
IntentionRequested { who: T::AccountId, intention: Intention }, | ||
/// Intent is requested | ||
IntentRequested { who: T::AccountId, intent: Intent }, | ||
/// Intent is executed | ||
IntentExecuted { who: T::AccountId, intent: Intent, result: IntentExecutionResult }, | ||
/// Omni executor is set | ||
OmniExecutorSet { omni_executor: T::AccountId }, | ||
} | ||
|
||
#[pallet::error] | ||
|
@@ -144,6 +161,7 @@ pub mod pallet { | |
InvalidAccount, | ||
UnknownAccountStore, | ||
EmptyAccount, | ||
RequireOmniExecutor, | ||
} | ||
|
||
#[pallet::call] | ||
|
@@ -290,9 +308,9 @@ pub mod pallet { | |
|
||
#[pallet::call_index(6)] | ||
#[pallet::weight((195_000_000, DispatchClass::Normal))] | ||
pub fn request_intention(origin: OriginFor<T>, intention: Intention) -> DispatchResult { | ||
pub fn request_intent(origin: OriginFor<T>, intent: Intent) -> DispatchResult { | ||
let who = T::OmniAccountOrigin::ensure_origin(origin)?; | ||
Self::deposit_event(Event::IntentionRequested { who, intention }); | ||
Self::deposit_event(Event::IntentRequested { who, intent }); | ||
Ok(()) | ||
} | ||
|
||
|
@@ -325,6 +343,31 @@ pub mod pallet { | |
|
||
Ok(Pays::No.into()) | ||
} | ||
|
||
#[pallet::call_index(8)] | ||
#[pallet::weight((195_000_000, DispatchClass::Normal, Pays::No))] | ||
pub fn intent_executed( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think later we could have an enum representing the status of an
|
||
origin: OriginFor<T>, | ||
who: T::AccountId, | ||
intent: Intent, | ||
result: IntentExecutionResult, | ||
) -> DispatchResult { | ||
Self::ensure_omni_executor(origin)?; | ||
Self::deposit_event(Event::IntentExecuted { who, intent, result }); | ||
Ok(()) | ||
} | ||
|
||
#[pallet::call_index(9)] | ||
#[pallet::weight((195_000_000, DispatchClass::Normal, Pays::No))] | ||
pub fn set_omni_executor( | ||
origin: OriginFor<T>, | ||
new_omni_executor: T::AccountId, | ||
) -> DispatchResult { | ||
T::SetOmniExecutorOrigin::ensure_origin(origin)?; | ||
OmniExecutor::<T>::put(new_omni_executor.clone()); | ||
Self::deposit_event(Event::OmniExecutorSet { omni_executor: new_omni_executor }); | ||
Ok(()) | ||
} | ||
} | ||
|
||
impl<T: Config> Pallet<T> { | ||
|
@@ -346,6 +389,14 @@ pub mod pallet { | |
|
||
Ok(member_accounts) | ||
} | ||
|
||
fn ensure_omni_executor(origin: OriginFor<T>) -> DispatchResult { | ||
ensure!( | ||
Some(ensure_signed(origin)?) == Self::omni_executor(), | ||
Error::<T>::RequireOmniExecutor | ||
); | ||
Ok(()) | ||
} | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...or/ethereum/intention-executor/Cargo.toml → ...cutor/ethereum/intent-executor/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
[package] | ||
name = "intention-executor" | ||
name = "intent-executor" | ||
version = "0.1.0" | ||
authors = ['Trust Computing GmbH <[email protected]>'] | ||
edition.workspace = true | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we use
teebag
as the sole place to manage enclaves? I'm not sure if RA is ready for omni-executor thoughThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw the
TEECallOrigin
does go through the teebag storagesThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
omni-executor is not registered as enclave at this moment