-
Notifications
You must be signed in to change notification settings - Fork 72
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
Modify the scheduleAs parameter to be an optional parameter #499
Conversation
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.
Looks good, but I left two comments.
// Make sure the owner is the proxy account of the user account. | ||
if let Some(schedule_as_account) = schedule_as.clone() { | ||
T::EnsureProxy::ensure_ok(schedule_as_account, who.clone())?; | ||
} |
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.
Yeah, this is definitely needed. This will be skipped if schedule_as is null?
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.
Yes, this will be skipped if schedule_as is null.
/// * `Other("proxy error: expected `ProxyType::Any`")`: schedule_as must be a proxy account of type "any" for the caller. | ||
#[pallet::call_index(3)] | ||
#[pallet::weight(<T as Config>::WeightInfo::schedule_xcmp_task_full(schedule.number_of_executions()).saturating_add(T::DbWeight::get().reads(1)))] | ||
pub fn schedule_xcmp_task_through_proxy( |
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.
Can you add comment to your PR? Is this function deprecated?
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.
Yes. This function is deprecated.
#[pallet::weight( | ||
<T as Config>::WeightInfo::schedule_xcmp_task_full(schedule.number_of_executions()) | ||
.saturating_add(T::DbWeight::get().reads(if schedule_as.is_some() { 1 } else { 0 })) | ||
)] | ||
pub fn schedule_xcmp_task( |
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.
Since the code for schedule_xcmp_task
and schedule_xcmp_task_through_task
is essentially the same, I merged them.
Added instruction_sequence
and schedule_as
parameters.
instruction_sequence
: The instruction sequence for the XCM call.
schedule_as
: The real task executor. If it is None, the caller will be the executor.
Related OAK-blockchain PR: AvaProtocol/OAK-blockchain#499 Dependencies: AvaProtocol/oak.js#143 AvaProtocol/oak.js#144 **Task was scheduled** <img width="917" alt="image" src="https://github.com/OAK-Foundation/xcm-demo/assets/16951509/b43b1b94-436b-496b-a75b-ce12f6d2cc3e"> **Task was executed** <img width="673" alt="image" src="https://github.com/OAK-Foundation/xcm-demo/assets/16951509/57875e30-d8ed-43a6-9e3f-8b4f4cde1273"> Log: ``` 1. Transfer TUR to the derivative account on turing-local: status.type Ready status.type InBlock status.type Finalized 2. One-time proxy setup on moonbase-local a) Add a proxy for Alice If there is none setup on moonbase-local oakChainData.paraId: 2114 Add a proxy of moonbase-local (paraId:1000) and proxyType: Any on Turing ... Proxy address: 0xfde409e557153fceffd60db438375b2247df3418 status.type Ready status.type InBlock status.type Finalized b) Topping up the proxy account on moonbase-local with DEV ... status.type Ready status.type InBlock status.type Finalized User Alice turing-local address: 6AwtFW6sYcQ8RcuAJeXdDKuFtUVXj4xW57ghjYQ5xyciT1yd, moonbase-local address: 0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac 3. Execute an XCM from moonbase-local to turing-local ... a). Create a payload to store in Turing’s task ... b). Send extrinsic from moonbase-local to turing-local to schedule task. Listen to TaskScheduled event on turing-local chain ... Listen XCMP task events Send extrinsic from moonbase-local to schedule task. extrinsic: 0x21060301010009210103010100092101dc6a337f000000000000000000000000e1023c010004000000000000000003010100a10f03010100092103010200a10f040300141354778000000000000000000000c9012601f24ff3a9cf04c71dbc94d0b566f7a27b94566cac01581501000000000000000000000000000000000000000000000000000000000000a72f549a1a12b9b49f30a7f3aeb1f4e96389c5d8000000000000000000000000000000000000000000000000000000000000000010d09de08a0003404ac76c5a15010003401462a85a8603000100031d4a5a434a38010001071d72c531014a38010000 status.type Ready automationTime:TaskScheduled:: (phase={"applyExtrinsic":0}) AccountId32: 6AubHEyP5NhszkySgTAznkkQpiBjnBRkh2EidUQFv8k7kaPK Bytes: 0x31362d302d31 Option<AccountId32>: Found the event and retrieved TaskId, 16-0-1 Keep Listening automationTime.TaskExecuted until 2024-01-09 10:00:52(1704765652) to verify that the task(taskId: 16-0-1) will be successfully triggered ... status.type InBlock automationTime:TaskExecuted:: (phase=Initialization) AccountId32: 6AubHEyP5NhszkySgTAznkkQpiBjnBRkh2EidUQFv8k7kaPK Bytes: 0x31362d302d31 XcmpMessageSent event: { phase: 'Initialization', event: { method: 'XcmpMessageSent', section: 'xcmpQueue', index: '0x2804', data: { messageHash: '0x03c026ccf147d5277559da361e7d6ddc28709f002fcf240cfa35ee816ca0a51a' } }, topics: [] } messageHash: 0x03c026ccf147d5277559da361e7d6ddc28709f002fcf240cfa35ee816ca0a51a status.type Finalized 4. Listen xcmpQueue.Success event with messageHash(0x03c026ccf147d5277559da361e7d6ddc28709f002fcf240cfa35ee816ca0a51a) and find ethereum.Executed event on Parachain... xcmpQueue:Success:: (phase={"applyExtrinsic":1}) Option<[u8;32]>: 0x03c026ccf147d5277559da361e7d6ddc28709f002fcf240cfa35ee816ca0a51a {"refTime":"Compact<u64>","proofSize":"Compact<u64>"}: {"refTime":813047000,"proofSize":28373} ethereum.Executed event: {"from":"0xf24ff3a9cf04c71dbc94d0b566f7a27b94566cac","to":"0xa72f549a1a12b9b49f30a7f3aeb1f4e96389c5d8","transactionHash":"0xe8d1b7bf8ae46af6b1a31f10d50f2e39f0cab13905c0361770c2a64b50f606a8","exitReason":{"Succeed":"Stopped"},"extraData":""} Reached the end of main() ... ```
We can use the Derivative account as the task executor without the need to add proxy relationships on the Turing chain.