English
Search
⌃K
Links

SALP Contribution & Confirmation

SALP Contribution & Confirmation Workflow

Step 1: Users use XMP-DMP cross-in their KSM to Bifrost Parachian.
Step 2: Users call the SALP-contribute to a Crowdloan, the contribution will be executed by XCM-UMP transact.
Step 3: Subql Multisig nodes comfrim the contributed events on Kusama Relay chain, and send the result back to Bifrost parachain.
Step 4: Bifrost SALP receive the result, issue/or not issue derivatives vsKSM & vsBond for users.

Contribute-UMP Transact

Crowdloan contribution is proxy called by Bifrost Parachain account with UMP Transact

Encode Call

#[derive(Encode, Decode)]
pub enum CrowdloanContributeCall<BalanceOf> {
#[codec(index = 73)]
CrowdloanContribute(ContributeCall<BalanceOf>),
}
#[derive(Encode, Decode)]
pub enum ContributeCall<BalanceOf> {
#[codec(index = 1)]
Contribute(Contribution<BalanceOf>),
}
#[derive(Debug, PartialEq, Encode, Decode)]
pub struct Contribution<BalanceOf> {
#[codec(compact)]
pub index: ParaId,
#[codec(compact)]
pub value: BalanceOf,
pub signature: Option<MultiSignature>,
}
let call = CrowdloanContributeCall::CrowdloanContribute(
ContributeCall::Contribute(Contribution { index, value, signature: None }),
)
.encode()
.into();

Construct Transact

let message = Xcm::WithdrawAsset {
assets: vec![MultiAsset::ConcreteFungible {
id: MultiLocation::Null,
amount: WeightToFee::calc(transact_weight+transact_debt)),
}],
effects: vec![Order::BuyExecution {
fees: MultiAsset::All,
weight: transact_weight,
debt: transact_debt,
halt_on_error: true,
xcm: vec![Xcm::Transact {
origin_type: OriginKind::SovereignAccount,
require_weight_at_most: Unlimited,
call:call,
}],
}],
};

Weight Calculation

Fee Calculation&Compensation

  • use weightToFee from relaychain
  • extend pallet_transaction_payment with OnChargeTransaction
impl pallet_transaction_payment::Config for Runtime {
type OnChargeTransaction = FlexibleFee;
...
}
T::MiscFeeHandler::deduct_fee(who, &T::TreasuryAccount::get(), call).map_err(
|_| TransactionValidityError::Invalid(InvalidTransaction::Custom(77u8)),
)?;

XCM Confirmation

XCM essentially is asynchronous&asymetric and in current XCM version you can not tell if the remote call is successful or not in relaychain. To achieve it we deply salp-confirm-service to confirm the contribution with multisig mechanism
  • generate xcm messageId

Challenges&Issues

TODO

  • Migrate to V2 and remove confirm-service with fully decentralized Xcm notify&query