# Kusama -> Polkadot bridge local demo ## Prerequisites: 1. Start `kusama-local` and `polkadot-local` chains. In this configuration `//Alice` is the bridges "pallet owner" on both chains 2. Build `substrate-relay` from [`parity-bridges-common` repository](https://github.com/paritytech/parity-bridges-common): `cargo build -p substrate-relay`. Alternatively, we have a docker image: https://hub.docker.com/r/paritytech/substrate-relay ## Bridge startup: 1. Initialize Kusama-to-Polkadot headers bridge: ```sh substrate-relay init-bridge kusama-to-polkadot\ --source-host=$KUSAMA_HOST\ --source-port=$KUSAMA_PORT\ --target-host=$POLKADOT_HOST\ --target-port=$POLKADOT_PORT\ --target-signer=//Alice ``` 2. Initialize Polkadot-to-Kusama headers bridge: ```sh substrate-relay init-bridge polkadot-to-kusama\ --source-host=$POLKADOT_HOST\ --source-port=$POLKADOT_PORT\ --target-host=$KUSAMA_HOST\ --target-port=$KUSAMA_PORT\ --target-signer=//Alice ``` 3. Start Kusama <> Polkadot relay: ```sh substrate-relay relay-headers-and-messages kusama-polkadot --create-relayers-fund-accounts\ --kusama-host=$KUSAMA_HOST\ --kusama-port=$KUSAMA_PORT\ --kusama-signer=//Bob\ --kusama-messages-pallet-owner=//Alice\ --polkadot-host=$POLKADOT_HOST\ --polkadot-port=$POLKADOT_PORT\ --polkadot-signer=//Bob\ --polkadot-messages-pallet-owner=//Alice\ --lane=00000000\ ``` ## Preparations on the Kusama side 1. Send some KSM to account that will pay for the Kusama -> Polkadot messages. Let it be `J68sWANWt2QLs2ww1Ftuo9UVCQD4fcbJC3s4vEqG352XoRE` 2. Configure messages pallet at Kusama to use this account for payment by sending `bridgePolkadotMessages.updateParameter(AllowedMessageSender, J68sWANWt2QLs2ww1Ftuo9UVCQD4fcbJC3s4vEqG352XoRE)` transaction using `//Alice` account: ![](https://i.imgur.com/yuyY49E.png) ## Preparations on the Polkadot side: 1. "Derive" Polkadot account from the pre-generated Kusama account from previous paragraph: ```sh docker run paritytech/substrate-relay:latest\ derive-account kusama-to-polkadot\ J68sWANWt2QLs2ww1Ftuo9UVCQD4fcbJC3s4vEqG352XoRE Source address: J68sWANWt2QLs2ww1Ftuo9UVCQD4fcbJC3s4vEqG352XoRE (Kusama) ->Corresponding (derived) address: 1cfYSBS5fhDvwzYAsMDSaupY8M3YzgszuPSJ9Ks6CNkSUa9 (Polkadot) ``` 2. Send some DOTs (the idea is that DOTs will be sent from Polkadot treasury) to this account. Since now, Kusama account `J68sWANWt2QLs2ww1Ftuo9UVCQD4fcbJC3s4vEqG352XoRE` may spent DOTs of `1cfYSBS5fhDvwzYAsMDSaupY8M3YzgszuPSJ9Ks6CNkSUa9` using the bridge ## Kusama council actions: 1. Add council member(s). I did that by recompiling `polkadot` binary with council members set to initial authorites (`Alice` and `Bob`) - you may just reapply [this commit](https://github.com/paritytech/polkadot/commit/f56079c59a69c21dbbadab177b03abe091d36294) to your local polkadot version. Pretty sure there are other options, but this one is the easiest for me 2. Encode Polkadot `balances::transfer` call to spent DOTs of `1cfYSBS5fhDvwzYAsMDSaupY8M3YzgszuPSJ9Ks6CNkSUa9`. Let the encoded call will be `0x050000ee702013462cc7880f7dcef6917fd920a01b2310fbdffe5b04a4a3df9b5644040700e8764817`: ![](https://i.imgur.com/0YAdJGz.png) 3. At Kusama, prepare a council motion to spend DOTs using encoded call from above. The motion should be: `bridgePolkadotMessages.sendMessage(lane_id=00000000, payload: { specVersion: 9180, weight: 200000000, origin: SourceAccount(J68sWANWt2QLs2ww1Ftuo9UVCQD4fcbJC3s4vEqG352XoRE), dispatchFeePayment: AtSourceChain, call: 0x050000ee702013462cc7880f7dcef6917fd920a01b2310fbdffe5b04a4a3df9b5644040700e8764817 }, deliveryAndDispatchFee: 500000000000)`. Change `specVersion` to the actual Polkadot chain spec version: ![](https://i.imgur.com/aX0wLSs.png) 4. Let councilors vote if threshold is larger than 1 5. At Kusama, verify that DOTs have been sent from `1cfYSBS5fhDvwzYAsMDSaupY8M3YzgszuPSJ9Ks6CNkSUa9` to the account, encoded in `balances::transfer` call above: ![](https://i.imgur.com/90lI2Wy.png)