POA Forum

Claim Sai tokens from the bridge contract before the Emergency Shutdown of Sai

The goal of this manual is to provide a help to the xDai bridge validators with upgrade of the TokenBridge contract on the Ethereum Mainnet side. The new version of the bridge contract intends to address the inbalance issue appeared after setting by MakerDAO the Migration contract debt ceiling to zero in preparation for the Shutdown of Single Collateral Dai.

At that moment the xDai bridge balance was 49.938645266079271041 Sai that could not be coverted to Dai. It means that it will not be possible to withdrawn all xDai from the xDai side.

Here is a proof of that balance availability: we disabled the Sai token in the xDai bridge on the block 9882928 (0x96cd30). So the getting the balance of the birdge for the block before 0x96cd30 will display the amount of Sai tokens relayed to the xDai side:

curl https://mainnet-nethermind.blockscout.com -X POST \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","method":"eth_call","params": [{"to":"0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359","data":"0x70a082310000000000000000000000004aa42145Aa6Ebf72e164C9bBC74fbD3788045016"}, "0x96cd2f"],"id":1}'

The urgency of this upgrade is caused by ES of Sai the MakerDAO scheduled for today. We would like to keep the value of tokens managed by the bridge.

As part of this upgrade the following actions will be done:

  • All available balance of Sai tokens owned by the xDai bridge will be sent to Igor’s address: 0x64631b5d259eAD889E8B06D12C8B74742804E5F1. Igor has promised to refund all Sai tokens appeared after the Sia token disabling in the bridge.
  • Internal variable which reflects amount of Dai tokens owned by the bridge and invested in Chai token, will be increased by 49.938645266079271041. The corresponding transaction to top up the the bridge balance in the Chai token contract is 0x3deb88067b7bef709af1a51a73174293a8fab56fb22370190418785921be0e3d.

It is important to note that the new bridge contract had no external security audit. The new bridge contracts has been reviewed by the POA Network R&D team only.

You can find and review the delta between the current and new implementations here: https://www.diffchecker.com/7sN1Osrs

Short description of the changes:

  1. the line 1221 adds an identificator for the storage slot which is responsible for managing that the transaction to claim tokens happens only once.
  2. the lines 1275-1282 introduce a new method which will be called during the upgrade. The new method performs the actions described above: increade the variable with the amount of invested Dai and send Sai tokens to the dedicated account (it is specified in the config file).

The manual assumes that the new implementation of the bridge contract that will be used for the bridge update, already deployed to the Ethereum Mainnet:

Since the current bridge ownership belongs to a mulisig wallet, during the update process it will be two roles: leader and confirmatory.

Leader (only one account) will initialize transactions in the multisig wallet contract, confirmatories (rest of accounts owned the multisig wallet) will confirm these transactions. The last account sending confirmation will initiate the actual call to the bridge contracts performing one of actions related to the update.

The instructions below will be split on two parts reflecting the steps for leader, the steps for confirmatories and common steps for the oracle upgrade. It is assumed that Docker is installed on the system and the user is allowed to run the docker command without invoking sudo mediation.

Pay attention that non-official version of the docker image is used. The tag of the version is claimSai.

Steps for leader:

  1. Most probably you don’t need to performs steps for the leader since they have already done.

  2. Pull the docker image:

    docker pull poanetwork/tokenbridge-contracts:claimSai
    
  3. Prepare a file with configuration of the update process (e.g. .env.init). Fill FOREIGN_PRIVKEY with the private key that corresponds to the account registered in the multisig wallet (Ethereum Mainnet):

    FOREIGN_RPC_URL=https://mainnet.infura.io/v3/809cc8d14e6d41ae889a4c01705c02fa
    FOREIGN_PRIVKEY=0x...
    FOREIGN_BRIDGE_ADDRESS=0x4aa42145Aa6Ebf72e164C9bBC74fbD3788045016
    FOREIGN_START_BLOCK=10050652
    # 21 gwei
    FOREIGN_GAS_PRICE=21000000000
    
    # leader or confirm
    # the leader must change it "leader" -- "confrm" was left here intentionally to get rid of mistakes 
    ROLE=confirm
    
    NEW_IMPLEMENTATION_ETH_BRIDGE=0x7e7669bdff02f2ee75b68b91fb81c2b38f9228c2
    SAI_TOKENS_RECEIVER=0x64631b5d259eAD889E8B06D12C8B74742804E5F1
    
  4. Request the bridge contract update on the Ethereum Mainnet:

    docker run -it --rm --workdir /contracts/upgrade --env-file .env.init \
      poanetwork/tokenbridge-contracts:claimSai npm run upgradeBridgeOnForeign
    

    it should report with success at the end:

    Submission status: true - Tx Hash: 0x....
    
  5. Now it is necessary to communicate with confirmatories to approve the requests.

Steps for confirmatories:

  1. Wait for the notification from the leader that the requests were sent to the multisig wallet contract.

  2. Pull the docker image:

    docker pull poanetwork/tokenbridge-contracts:claimSai
    
  3. Prepare a file with configuration of the update process (e.g. env.confirm). Fill FOREIGN_PRIVKEY with the private key that corresponds to the account registered in the multisig wallet (Ethereum Mainnet):

    FOREIGN_RPC_URL=https://mainnet.infura.io/v3/809cc8d14e6d41ae889a4c01705c02fa
    FOREIGN_PRIVKEY=0x...
    FOREIGN_BRIDGE_ADDRESS=0x4aa42145Aa6Ebf72e164C9bBC74fbD3788045016
    FOREIGN_START_BLOCK=10050652
    # 21 gwei
    FOREIGN_GAS_PRICE=21000000000
    
    # leader or confirm
    ROLE=confirm
    
    NEW_IMPLEMENTATION_ETH_BRIDGE=0x7e7669bdff02f2ee75b68b91fb81c2b38f9228c2
    SAI_TOKENS_RECEIVER=0x64631b5d259eAD889E8B06D12C8B74742804E5F1
    
  4. Confirm the bridge contract update on the Ethereum Mainnet:

    docker run -it --rm --workdir /contracts/upgrade --env-file .env.confirm \
      poanetwork/tokenbridge-contracts:claimSai npm run upgradeBridgeOnForeign
    

    it should report with success at the end:

    Confirmation status: true - Tx Hash: 0x....
    
3 Likes

@geleeroyale/@GriffGreen @ArseniiPetrovich/@mgarcia @mariano.conti/@savdao

@igorbarinov has initiated the process of updating the xDai bridge contract by performing first actions from the leader role. Could you confirm the upgrade request by performing the steps described in the Steps for confirmatories section?

Thanks!

2 Likes

The claim has been confirmed: https://etherscan.io/tx/0x0f8ee640cb733e48ef1011554cb36945492f8cd40b5111417d1f54f30633f986. Thanks!

Regarding any unclaimed Sai, please see the following post for claiming instructions.

1 Like