Skip to content
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

test xcm transact #1

Open
yrong opened this issue May 16, 2021 · 2 comments
Open

test xcm transact #1

yrong opened this issue May 16, 2021 · 2 comments

Comments

@yrong
Copy link
Owner

yrong commented May 16, 2021

cumulus:
4cdf87d

rococo:
yrong/polkadot@b70b0af

the core logic in parachain side is wrap a transact xcm to invoke test pallet function in relaychain as following:

log::info!(
target: "ping",
"Begin construct relay transact"
);
let some_value:u32 = 10;
let call = RelayTemplatePalletCall::DoSomething(DoSomethingCall::Something(some_value)).encode();
let msg = Xcm::Transact {
origin_type: OriginKind::SovereignAccount,
require_weight_at_most: 1_000,
call:call.into(),
};
log::info!(
target: "ping",
"Relay transact {:?}",
msg,
);
match T::XcmSender::send_xcm(MultiLocation::X1(Junction::Parent), msg){
Ok(()) => {
Self::deposit_event(Event::TestMsg(some_value));
log::info!(
target: "ping",
"Relay transact sent success!"
);
},
Err(e) => {
Self::deposit_event(Event::ErrorSendingTest());
log::error!(
target: "ping",
"Relay transact sent failed!"
);
}
}
}
}

from parachain log we can see:

2021-05-16 16:01:48  [Parachain] Begin construct relay transact    
2021-05-16 16:01:48  [Parachain] Relay transact Transact { origin_type: Native, require_weight_at_most: 1000, call: [100, 0, 10, 0, 0, 0] }    
2021-05-16 16:01:48  [Parachain] Relay transact sent success!  

2021-05-16 16:01:50  [Relaychain] 💤 Idle (4 peers), best: #939 (0xdc19…668f), finalized #936 (0xee40…7ea9), ⬇ 0.9kiB/s ⬆ 3.4kiB/s    
2021-05-16 16:01:50  [Parachain] 💤 Idle (0 peers), best: #299 (0x91c2…12b2), finalized #297 (0xd553…92a3), ⬇ 0 ⬆ 0    

which demonstrate parachain is successfully registered to relay chain and transact are wrapped and sent successfully

the relay chain pallet will update storage and emit event as following:

https://github.com/yrong/polkadot/blob/b70b0af3f5d1226ae31bd3e5c3ced2ebfa105380/template/src/lib.rs#L79-L82

from relay chain event we can see:

image

which demonstrate relaychain finish the dispatch call successfully

@yrong
Copy link
Owner Author

yrong commented May 17, 2021

some notes:

@yrong
Copy link
Owner Author

yrong commented May 17, 2021

challenge:

  • currently the transact call is async and not safe guaranted, execution in parachain side will always be successful even if the call is failed in relay chain side. there are some issues tracking and seems still some infrastruct code lacking

paritytech#206
polkadot-fellows/xcm-format#22

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant