Skip to content

Relay subcommand that performs token RLT <> MLAU token swap#1141

Merged
svyatonik merged 6 commits intomasterfrom
token-swap-relay
Sep 21, 2021
Merged

Relay subcommand that performs token RLT <> MLAU token swap#1141
svyatonik merged 6 commits intomasterfrom
token-swap-relay

Conversation

@svyatonik
Copy link
Copy Markdown
Contributor

@svyatonik svyatonik commented Sep 15, 2021

New subcommand illustration:

svyatonik@xwnotebook:~/dev/parity-bridges-common.test$ reset && RUST_LOG=bridge=trace ./bin/substrate-relay swap-tokens millau-to-rialto --source-host=127.0.01 --source-port=10944 --source-signer=//WithRialtoTokenSwap --target-host=127.0.0.1 --target-port=9944 --target-signer=//WithMillauTokenSwap --source-balance=8000000000 --target-balance=9000000000 no-lock
INFO bridge Starting swap: TokenSwap { swap_type: TokenSwapType::TemporaryTargetAccountAtBridgedChain, source_balance_at_this_chain: 8000000000, source_account_at_this_chain: 18ac67fc2e27eb643dc856aee5d6698ecbd8b56cb0d0c9976075e861652aa25e (5Cd4Dp9q...), target_balance_at_bridged_chain: 9000000000, target_account_at_bridged_chain: 3e96c805858b0ba5148b95ef1f449ebd10178f24a2d803a709fec4778d45b97a (5DUmcmGY...) }
INFO bridge Swap accounts: TokenSwapAccounts { source_account_at_this_chain: 18ac67fc2e27eb643dc856aee5d6698ecbd8b56cb0d0c9976075e861652aa25e (5Cd4Dp9q...), source_account_at_bridged_chain: f73221a9b67cafbc02d0abd1a79545ce6667aa81a3e12223c6f59252388363cb (5HepaQmV...), target_account_at_bridged_chain: 3e96c805858b0ba5148b95ef1f449ebd10178f24a2d803a709fec4778d45b97a (5DUmcmGY...), target_account_at_this_chain: 51b28434fa1fa11381e16602a710bca57ac29395a9f801d61f8b51ea1ce2947d (5DupmQ1t...), swap_account: d481aea213db42b0fdd736512c6b70164d5a8cbd8c0fbd465a16ae899cc71b0b (5GsLXq8g...) }
INFO bridge Initial account balances: TokenSwapBalances { source_account_at_this_chain_balance: Some(1125899906842624), source_account_at_bridged_chain_balance: None, target_account_at_bridged_chain_balance: Some(1125899906842624), target_account_at_this_chain_balance: None, swap_account_balance: None }
TRACE bridge Sent transaction to Millau node: 0xdd2978294413ae03a509d6a90bf39dfb30765d7f5ea38ba8345916ffbfe2069713f15ad46c50589d37068077b9cf72da1679a9d74c33ff21588c393b1f9d899b
TRACE bridge Received intermediate status of Millau transaction: Some(Ready)
TRACE bridge Received intermediate status of Millau transaction: Some(Broadcast(["12D3KooWRh4Z6iXMyAdJK7hXuMCjwL5uur6K4ZJpbdgUXBupZJJq", "12D3KooWPLkJk1s1JsMrfLqCN1mGcH65nebp9f6mPBbFT1DFJRu1", "12D3KooWPswsQgEo79j7rMMWiLJB7n5QjkHzXr7EiAtj1BqvsNBv", "12D3KooWM5LFR5ne4yTQ4sBSXJ75M4bDo2MAhAW2GhL3i8fe5aRb"]))
TRACE bridge Received intermediate status of Millau transaction: Some(InBlock(0xf391752a82e4b42fb365267036d505452259d56cb2195361590fa3286e919881fe7b7a660155f739fa6faf1c63e57c379f60ab3d8edb6bb0af8b35648d537519))
TRACE bridge Millau transaction has been finalized at block 0xf391…7519
INFO bridge Swap has been successfully started
INFO bridge Intermediate balances: TokenSwapBalances { source_account_at_this_chain_balance: Some(1124891781842271), source_account_at_bridged_chain_balance: None, target_account_at_bridged_chain_balance: Some(1125899906842624), target_account_at_this_chain_balance: None, swap_account_balance: Some(8000000000) }
TRACE bridge Waiting for token swap state change
TRACE bridge Inspecting Millau block 12/0xf391…7519
TRACE bridge Inspecting Millau block 13/0x070a…1b03
TRACE bridge Inspecting Millau block 14/0x287b…4475
TRACE bridge Inspecting Millau block 15/0x6b8f…2436
TRACE bridge Inspecting Millau block 16/0x2902…61ae
TRACE bridge Inspecting Millau block 16/0x2902…61ae
TRACE bridge Inspecting Millau block 17/0x5d8d…63e9
TRACE bridge Inspecting Millau block 18/0xb2ff…5af3
TRACE bridge Inspecting Millau block 19/0xb1cb…b3fc
TRACE bridge Inspecting Millau block 20/0x5cb7…632f
TRACE bridge Inspecting Millau block 21/0x323b…d26c
TRACE bridge Inspecting Millau block 21/0x323b…d26c
TRACE bridge Inspecting Millau block 22/0x6847…0499
TRACE bridge Inspecting Millau block 23/0x8fa2…194d
TRACE bridge Token swap state has been changed from TokenSwapState::Started to Some(TokenSwapState::Confirmed)
INFO bridge Transfer has been successfully dispatched at the target chain. Swap can be claimed
INFO bridge Intermediate balances: TokenSwapBalances { source_account_at_this_chain_balance: Some(1124891781842271), source_account_at_bridged_chain_balance: Some(9000000000), target_account_at_bridged_chain_balance: Some(1125890708601381), target_account_at_this_chain_balance: None, swap_account_balance: Some(8000000000) }
TRACE bridge Waiting for token swap state change
TRACE bridge Inspecting Millau block 24/0x252e…4424
INFO bridge Claiming the swap swap
TRACE bridge Sent transaction to Rialto node: 0x7bef0378d270294663b925ad5bcb15a2ee37bfed61b2253015fae2af7233ae37
TRACE bridge Received intermediate status of Rialto transaction: Some(Ready)
TRACE bridge Received intermediate status of Rialto transaction: Some(Broadcast(["12D3KooWCcwZswYzBdjQRUtQhLjLaMJRDE59yxrghKFcwVU2zXnN", "12D3KooWSEpHJj29HEzgPFcRYVc5X3sEuP3KgiUoqJNCet51NiMX", "12D3KooWMa6z3o1GB9B2grBEy7AipYYbLgRGfmFg1rXf1r1QoMa2", "12D3KooWCc5tkKC8ehK5NjiaNqGbXUdqdFao5nLUKx6wwNGnsBQ9"]))
TRACE bridge Received intermediate status of Rialto transaction: Some(InBlock(0xf3dfddee160670c01a960baa3d537838a5b4bef7752a6132d12e276d9144dd35))
TRACE bridge Rialto transaction has been finalized at block 0xf3df…dd35
TRACE bridge Waiting for token swap state change
TRACE bridge Inspecting Millau block 27/0xc94b…afd6
TRACE bridge Inspecting Millau block 28/0xe9fd…782d
TRACE bridge Inspecting Millau block 29/0x56df…7753
TRACE bridge Inspecting Millau block 30/0xd325…67a8
TRACE bridge Inspecting Millau block 31/0xfff4…e198
TRACE bridge Token swap state has been changed from TokenSwapState::Confirmed to None
INFO bridge Final account balances: TokenSwapBalances { source_account_at_this_chain_balance: Some(1124891781842271), source_account_at_bridged_chain_balance: Some(9000000000), target_account_at_bridged_chain_balance: Some(1124889320609909), target_account_at_this_chain_balance: Some(8000000000), swap_account_balance: None }

//

// prepare `Currency::transfer` call that will happen at the target chain
let bridged_currency_transfer: CallOf<Target> = pallet_balances::Call::transfer(
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a lot of code in this function - I've been trying to split it into several methods. But there's a problem - pallet calls are generic over runtime. So I need to pass runtime as generic arguments to these methods. But if this'll be extended to something behind Millau<>Rialto, then we won't have an access to the runtime => I've decided not to split it further.

I could also add call-craft functions to the select_bridge!() macro if that's unacceptable.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's leave it like that for now, I think it will soon be replaced by XCM anyway, so this should be just an example for now.

@svyatonik svyatonik marked this pull request as ready for review September 16, 2021 09:12
//

// prepare `Currency::transfer` call that will happen at the target chain
let bridged_currency_transfer: CallOf<Target> = pallet_balances::Call::transfer(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's leave it like that for now, I think it will soon be replaced by XCM anyway, so this should be just an example for now.

@svyatonik svyatonik merged commit ab83ba2 into master Sep 21, 2021
@svyatonik svyatonik deleted the token-swap-relay branch September 21, 2021 14:39
serban300 pushed a commit to serban300/parity-bridges-common that referenced this pull request Mar 27, 2024
…ch#1141)

* token swap relay

* token swap subcommand fixes

* fmt

* removed debug traces

* removed commented code
serban300 pushed a commit to serban300/parity-bridges-common that referenced this pull request Apr 8, 2024
…ch#1141)

* token swap relay

* token swap subcommand fixes

* fmt

* removed debug traces

* removed commented code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants