POA Forum

Update the xDai bridge contracts and oracles to start earning the interest with Chai

The goal of this manual is to provide a help to the xDai bridge validators with update of the TokenBridge contracts. The new version of the bridge contract supports usage of the Dai Savings Rate contract through the Chai token to earn the interest for tokens deposited on the bridge balance.

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.

Upgrade of the oracle software is mandatory due to the following changes on the bridge contracts:

  • a new approach to encode the list of signatures to confirm withdraw operations (xDai to Dai transfers).
  • a new worker is implemented to swap Dai tokens to Chai tokens as soon as they appeared on the bridge balance.

The automation script used in the the instructions below hides the following actions and by doing so simplifies the upgrade process significantly:

  • generate the new new docker compose environment to introduce new worker
  • pull the new TokenBridge oracle docker image

The instructions for upgrade:

  1. Login to the node where the TokenBridge oracle serving the xDai bridge is run. The next actions will assume that the user is able to run commands with the privileged permissions (either the user is root or it is able to call sudo).
  2. Stop the poabridge service:
    systemctl stop poabridge
    
  3. Download and invoke the upgrade script, checks that no issues appears during the script execution:
    curl -sSfL https://github.com/poanetwork/tokenbridge/releases/download/2.0.0/oracle-upgrade-1.2.0-to-2.0.0.sh | sudo bash
    
  4. Start the service:
    systemctl start poabridge
    

Wait for 3-5 minutes and check the logs of the oracle’s components (e.g. /var/log/docker/transfer_1/docker.log). Make sure that there are no errors and restarts.

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

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

Please pay attention that you need to upgrade the oracle as well.

Thanks!

2 Likes

Hey there. I mixed up a bit and completed a step for initiator. But then I completed the steps for confirmatories also. I’ve updated my bridge and it works without any errors, but I’m still not sure if it’s okay or not.

2 Likes

@akolotov Can you confirm what keys we are supposed to use for HOME_PRIVKEY and FOREIGN_PRIVKEY with the private key that corresponds to the account registered in the multisig wallet (Ethereum Mainnet, xDai chain)

I dont see any keys that i hold in the ETH multisig and i can’t seem to find where the addresses are in the xDAI contract…

Should i just use my miningkey for both?

1 Like

Hi! Seems that 0xc073C8E5ED9Aa11CF6776C69b3e13b259Ba9F506 is yours. It is the same as used on the bridge oracle.

2 Likes

Ok so I can use this key for both…?

Yes, the same key is for the oracle and for the multisig. When are you able to perform the steps? We need the contracts and the oracle upgraded till April, 1.

If we don’t upgrade this time, the bridge users will not be able to swap Dai to xDai since the xDai chain after the POSDAO activation will use another contract address for the Block Reward contract which is used by the bridge to mint xDai appeared in the network as part of relay requests. Moreover it will lead to imbalance of the bridge – in order to fix it a modification of consensus contracts on the xDai side will be required.

2 Likes

We will make sure it happens tomorrow… and if there is any issue we will report here asap

Do you know exact time? As so I can be here and assist you if something goes wrong?

2 Likes

Giveth Validator has been updated. Everything looked ok, except at the end of the oracle update script it told me

Checking that DB is accessible
the input device is not a TTY
An error with getting access to DB

but it did update redis, so idk if that’s relevant.

The first time the service started, but failed after a few minutes. Then I updated the system and rebooted. Service runs fine now since a few minutes.

Curently checking logs - they look fine. Maybe updating and restarting helped the service to run stable?

@akolotov Can you check on your end if it works correctly?

I am here. Need some time to confirm.

1 Like

It seems that the Redis DB was not reset to needed block. The rest part looks OK after the steps you performed.

In order to reset DB, could you perform the following:

  1. systemctl stop poabridge
  2. cd /home/poadocker/bridge/oracle
  3. start the DB:
    sudo -H -u poadocker docker-compose -f docker-compose-erc-native.yml up -d redis
    
  4. reset the block:
    docker-compose -f docker-compose-erc-native.yml exec redis /usr/local/bin/redis-cli set erc-native-transfer:lastProcessedBlock 9130276
    
  5. check that the block is actually updated:
    docker-compose -f docker-compose-erc-native.yml exec redis /usr/local/bin/redis-cli get erc-native-transfer:lastProcessedBlock
    
  6. stop the DB:
    sudo -H -u poadocker docker-compose -f docker-compose-erc-native.yml down
    
  7. systemctl start poabridge

Thanks in advance

1 Like

I ran through the steps - Almost everything looked fine, removed and added redis.

In execution it did not throw an error, but a warning:

WARNING: The ORACLE_VALIDATOR_ADDRESS variable is not set. Defaulting to a blank string.
WARNING: The ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY variable is not set. Defaulting to a blank string.

I did check for the root key and it is there and sets those values - also the service seems to run fine

the transfer watcher is restarting continuously now. Which RPC node are you using to reach the xDai chain?

We use a standard install (which I did not perform) -> Parity

@savdao

In order to perform the upgrade of the bridge validator please do the following:

  1. Login to the node where the TokenBridge oracle serving the xDai bridge is run. The next actions will assume that the user is able to run commands with the privileged permissions (either the user is root or it is able to call sudo).
  2. Stop the poabridge service:
    systemctl stop poabridge
    
  3. Download and invoke the upgrade script, checks that no issues appears during the script execution:
    curl -sSfL https://github.com/poanetwork/tokenbridge/releases/download/2.0.0/oracle-upgrade-1.2.0-to-2.0.0.sh | sudo bash
    
  4. Start the service:
    systemctl start poabridge
    
  5. Wait for 3-5 minutes and check the logs of the oracle’s components (e.g. /var/log/docker/transfer_1/docker.log). Make sure that there are no errors and restarts.
1 Like

This is now done.

Apologies for the delay, I got my notifications mixed up

thanks, everything works now.