[Referendum: 85] Recover DOT from Wrongly Built XCM Message

Polkassembly post

TL:DR

Send DOTs out of Moonbeam’s Sovereign account that were locked there due to a wrongly built XCM message for an xcDOT → DOT transfer.

Summary

On block 1,857,847 there was a wrongly built XCM message sent to Polkadot to transfer/convert 138.0586102303 xcDOT to DOT.

The user used an application that crafted the XCM message with an incorrect destination multilocation. The consequence of this was that the balance was correctly withdrawn from Moonbeam’s Sovereign Account, but it was then immediately deposited back, minus some fees.

Moreover, the wrongly built multilocation resulted in Polkadot sending an XCM back to Moonbeam to transfer the assets back (because the multilocation included a ParachainId: 2004). So, in the execution of that XCM message, another 0.0009028184 DOT were used for fees.

The amount that was deposited back in Polkadot was 138.0116684851 DOT, and the fees paid for the XCM message sent from Polkadot to Moonbeam was 0.0009028184 DOT. Therefore, this proposal will send an XCM message that will take 138.0107656667 DOT out of Moonbeam’s Sovereign account, pay for fees, and deposit the rest to the account set in the original XCM message.

According to the estimations, the XCM fee will be 0.0306485226 DOT, so the user should receive 137.9801171441 DOT.

Proposal

Proposal #20 with the following hash: 0xcc3d9ac490b5715c85bf9953021880618c967abb3745041f6124e728c550484f

Technical details:

The incorrect destination multilocation was the following:

{ "parents": 1, 
  "interior": 
    { "X2": [
      { "Parachain": 2004},
      {"AccountId32":
        {"network": "Any",
        "key": "0x681abe229de77e92d4f4c82ea282553a50eea781ae46c5200b0dcd34d17ccf14"
        }
      }
    }
  }

In this multilocation, the parachain ID is not needed. Therefore, the correct multilocation would be:

{ "parents": 1, 
  "interior": 
    { "X1": 
      {"AccountId32":
        {"network": "Any",
        "key": "0x681abe229de77e92d4f4c82ea282553a50eea781ae46c5200b0dcd34d17ccf14"
        }
      }
    }
  }

The consequence of this was that the balance was correctly withdrawn from Moonbeam’s Sovereign Account, but it was then immediately deposited back, minus some fees.

Another XCM message was sent from Polkadot to Moonbeam, which failed to execute on Moonbeam as the account format set was not correct. Because this failed while executing the DepositAsset instruction, the asset is taken away from the holding registry and minted into the user’s provided account (which is the part that fails). No assets are trapped on Moonbeam, meaning that the user has is assets locked in Moonbeam’s Sovereign account on Polkadot.

This was replicated on Moonbase Alpha, with the same happening on its Relay Chain.

The amount that was deposited back in Polkadot was 138.0116684851 DOT, and the fees paid for the XCM message sent from Polkadot to Moonbeam was 0.0009028184 DOT. Therefore, this proposal will send an XCM message with the following three instructions:

  • WithdrawAsset: will take 138.0107656667 DOT from Moonbeam’s Sovereign Account
  • BuyExecution: will use the withdrawn fund to buy enough execution time in Polkadot to execute the XCM message
  • DepositAsset: will deposit whatever assets are left to a provided account, which will be the same as in the original XCM message

According to the estimations, the XCM fee will be 0.0306485226 DOT, so the user should receive 137.9801171441 DOT.

The SCALE-encoded call data for the XCM message is the following:

0x6700010100020c0004000000000bdb9dd354410113000000000bdb9dd3544101000d01000400010100681abe229de77e92d4f4c82ea282553a50eea781ae46c5200b0dcd34d17ccf14

This process was tested successfully in internal networks that replicate Moonbeam-Polkadot.

7 Likes

It seems very good to me that these tokens are returned

Is there a way to prevent this from happening again?

it’s not something that is very efficient to have to do this every time :sweat_smile:

3 Likes

Hey José!

I’m afraid there is no way to prevent this in the future. This XCM message was wrongly built and it created a very undesirable outcome. I agree with you that this is not really scalable but this is just the first case in many months of XCM being enabled.

If it becomes a problem then we will have to see how to improve this process, or have the developers of the application submit the proof and proposal for the community to vote on.

3 Likes

I support this proposal and voted accordingly using Polkassembly

2 Likes