Oracle migration to a new server
Describes set of actions to migrate an existing setup of the TokenBridge oracle to a new server

Steps to follow

In short, the following procedure looks like this:
    create new server, check connection
    stop bridge oracle on the current server
    get last block numbers processed by the current server
    run ansible playbook on the new server and provide it with values from previous step, so that new service would start where current one stopped

Step 1: Create a new server

    1.
    Create a new server instance with your hosting provider (e.g. AWS, Digital Ocean, etc), you can use same specs as the current one (or at least 2 Core CPU, 4 GB RAM, Ubuntu 16.04 LTS, 32 GB Disk).
    Important: don’t stop or terminate your current server yet! We might need it to roll back if any errors occur. If you’re currently running both xDai bridge validator and xDai network validator on the same server, let us know and we’ll provide you with instructions on how to move network validator to your new server after bridge migration is completed successfully
    2.
    When you created new server, please note down its’ IP address and try to connect to it via ssh from your local computer to make sure that the server is accessible to you. When connected to the server, check that your user has sudo-privileges by running
    1
    sudo hostname
    Copied!
    It should complete without errors and not asking for password. Please copy your server’s hostname so that we can identify it later.
    Also note what is your username on the new server
    1
    whoami
    Copied!
    (most likely it’s ubuntu or root).
    When these checks are done, logout from your new server to return to your local computer
    1
    exit
    Copied!

Step 2: TokenBridge repo preparation

    1.
    Installation procedure of new oracle involves running an ansible playbook from your local computer. Ansible will connect to new server, install required dependencies, code of the oracle and start bridge service. To use ansible, you first need to install required dependencies and ansible itself on your local computer. They can be found here.
    2.
    After all the prerequisites are installed, download code of the new oracle to your local computer:
    1
    git clone --recursive https://github.com/poanetwork/tokenbridge
    2
    cd tokenbridge/deployment
    Copied!

Step 3: Getting the last processed block numbers

    1.
    Connect to your current bridge validator node.
    2.
    Stop the bridge docker containers:
    1
    sudo docker ps -q -f "name=oracle_bridge" | xargs sudo docker stop
    Copied!
    3.
    Connect to the redis container:
    1
    sudo docker exec -it oracle_redis_1 /bin/bash
    Copied!
    A new shell should appear, which is a shell running inside redis docker container. Shell prompt should look similar to this now:
    Copied!
    4.
    Connect to redis database via cli
    1
    redis-cli
    Copied!
    shell prompt should change one more time to something like this:
    1
    127.0.0.1:6379>
    Copied!
    5.
    Get the list of all entries in the database:
    1
    keys *
    Copied!
    You should get output similar to this one (order may differ):
    1
    1) "erc-native-signature-request:lastProcessedBlock"
    2
    2) "foreign:nonce"
    3
    3) "erc-native-collected-signatures:lastProcessedBlock"
    4
    4) "erc-native-affirmation-request:lastProcessedBlock"
    5
    5) "erc-native-half-duplex-transfer:lastProcessedBlock"
    6
    6) "home:nonce"
    7
    7) "erc-native-transfer:lastProcessedBlock"
    Copied!
    6.
    Run the following commands one-by-one to get current values of all *-request:lastProcessedBlock entries and copy the output somewhere, because we’ll need it later
    1
    get "erc-native-signature-request:lastProcessedBlock"
    2
    get "erc-native-affirmation-request:lastProcessedBlock"
    Copied!
    7.
    Run exit twice to get out of both the redis cli shell and redis container shell. You should now be back to the bash prompt on your current server.
    8.
    Stop current bridge service
    1
    sudo service poabridge stop
    Copied!

Step 4: New oracle deployment

You should still be in the .../tokenbridge/deployment folder of your local computer.
    1.
    Create and open hosts.yml configuration file in your favourite text editor.
    2.
    Paste the following into this file
    1
    ---
    2
    dai:
    3
    children:
    4
    oracle:
    5
    hosts:
    6
    1.1.1.1:
    7
    ansible_user: ubuntu
    8
    ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY: "..."
    9
    syslog_server_port: "udp://logs5.papertrailapp.com:33240"
    10
    ORACLE_HOME_START_BLOCK: 6123456
    11
    ORACLE_FOREIGN_START_BLOCK: 8123456
    Copied!
    Please check that whitespaces were pasted correctly! Padding is important in this configuration file.
    3.
    Set values of the following configuration options:
      1.1.1.1: replace it with real IP address of your new server
      ansible_user: change this to your username from the step 1 if it differs from ubuntu
      ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY: your private key (this value must be 64 characters long)
      ORACLE_HOME_START_BLOCK: use the value you get from the erc-native-signature-request:lastProcessedBlock redis key
      ORACLE_FOREIGN_START_BLOCK: use value from erc-native-affirmation-request:lastProcessedBlock
    4.
    Modify group_vars/dai.yml to reflect your own URL for COMMON_FOREIGN_RPC_URL. Also it makes sense to have a reasonable value for ORACLE_FOREIGN_RPC_POLLING_INTERVAL which should be slightly greater or equal of the average block mining time (e.g. for the Ethereum Mainnet it could be 15).
    5.
    Launch the playbook
    1
    ansible-playbook -i hosts.yml site.yml
    Copied!
    Playbook should complete without errors. In this case new oracle service is started automatically and upgrade procedure is finished.
Last modified 1yr ago
Export as PDF
Copy link