-
Notifications
You must be signed in to change notification settings - Fork 35
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
adjust liquidstaking on-chain part with xcm-transact #440
Comments
Here is the xcm transact pallet with After testing, there may be some bugs about |
1. Concept
A typical XCM message looks like this: 2. XCM VersionsXCM-v0 3. XCM-v0/v1Since xcm-v0 is already in Kusama production, and there are no big changes between xcm-v0 and xcm-v1, so basically this chapter will introduce the key part of xcm-v0, include 3.1 xcm-transferDMP xcm-transfer, from relaychain to parchain, the implementation code can be found here : UMP xcm-transfer, from parachain to relaychain, the implementation code can be found here : 3.2 xcm-transactTransact is mainly about UMP message, which means from parachain to relaychain. NOTE: the encoded calldata above should be constructed alone in UI, just like a normal transaction.
Here is the code link. 4. XCM-v2As described in this PR-3629, that in XCM-v2, 4.1 Instruction
4.2 xcm-QueryResponse
pub enum Response {
/// No response. Serves as a neutral default.
Null,
/// Some assets.
Assets(MultiAssets),
/// The outcome of an XCM instruction.
ExecutionResult(result::Result<(), (u32, Error)>),
} Since 4.2.1 define a notify callback in the TestPallet let call = pallet_test_notifier::Call::notification_received(0, Default::default());
let notify = Call::TestNotifier(call); 4.2.2 store the query id in relaychain XcmPallet XcmPallet::report_outcome_notify(&mut message, Parachain(PARA_ID).into(), notify, 100); pub fn report_outcome_notify(
message: &mut Xcm<()>,
responder: MultiLocation,
notify: impl Into<<T as Config>::Call>,
timeout: T::BlockNumber,
) {
let dest = T::LocationInverter::invert_location(&responder);
let notify: <T as Config>::Call = notify.into();
let max_response_weight = notify.get_dispatch_info().weight;
**let query_id = Self::new_notify_query(responder, notify, timeout);**
let report_error = Xcm(vec![ReportError { dest, query_id, max_response_weight }]);
message.0.insert(0, SetAppendix(report_error));
} 4.2.3 execute xcm message on relaychain let r = XcmExecutor::<XcmConfig>::execute_xcm(
Parachain(PARA_ID).into(),
Xcm(vec![QueryResponse {
query_id: 0,
response: Response::ExecutionResult(Ok(())),
max_weight: 1_000_000,
}]),
1_000_000_000,
); 4.2.4 execute pub fn notification_received(
origin: OriginFor<T>,
query_id: QueryId,
response: Response,
) -> DispatchResult {
let responder = ensure_response(<T as Config>::Origin::from(origin))?;
Self::deposit_event(Event::<T>::ResponseReceived(responder, query_id, response));
Ok(())
} 4.2.6 assert event in relaychain XcmPallet and TestPallet
Now it's the process of the 4.3 summarize-QueryResponseAccording to above process, let's image if the 5. Conclusion(2021-09-02) |
It seems like xcm-v1 will be included in Polkadot release-v0.9.10, please check this PR-3763. its status is draft for now. |
Subsequent works will be tracked by #502, will close this issue now. |
Excellent document 👍 |
Motivation
Since XCM v2 is onboarding, we should consider integrating with it in our liquidstaking design.
Suggested Solution
The text was updated successfully, but these errors were encountered: