Sign inSign up

hdac/bridgenode

By hdac

•Updated over 7 years ago

This is HDAC Bridge Node service repository

Image
0

753

hdac/bridgenode repository overview

⁠HDAC Bridge node Service

⁠Introduction

This is HDAC Bride Node Service, which provides nodes to provide contract services for issuing and managing tokens based on HDAC Mainnet. The initial version consists of four basic modules, Web Server, Anchoring, Contract and Database, and you could check the contents to be updated here on Docker Hub and GitHub.

⁠Version History

  1. Initial version, V 0.8
  2. update version v0.9 (See lower 'version description(v0.9)' for details)

⁠Image Description

Our services consist of four modules, and the description of each module is as follows:

  • Webserver service :
    This is a web server module, composed of Apache and Tomcat servers, and it provides some client webpages.
    Moreover, it provides two types of chains, one synchronized with HDAC Mainnet and the other standalone HDAC chain.
  • Anchoring service :
    This is a verification service module, a JAVA application operated periodically through CRONTAB.
    It provides functions to insert the block hash data from the side chain and transmit the transactions to the main chain.
  • Database service :
    This is a basic database service, composed of Maria DB, which saves information on tokens and anchoring history, etc.
  • Contract service :
    This provides functions to convert HDAC coins to tokens and refund them and it operates on CRONTAB.

⁠Instructions for Use

⁠1. How to run images

All instructions are based on Centos.

  1. Install Docker
 $ sudo yum update  
 $ sudo yum install yum-util device-mapper-persistent-data lvm2  
 $ sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo  
 $ sudo yum install docker-ce
 $ sudo systemctl enable docker
 $ sudo systemctl start docker
  1. Install Docker Compose
 $ sudo curl -L https://github.com/docker/compose/releases/download/1.23.1/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose  
 $ sudo chmod +x /usr/local/bin/docker-compose
  1. Make compose file
    Make the compose file as follows. (All containers are executed in the same server.)
    File name : docker-compose.yml
   version: '2'
   services:
     webserver:
      image: 'hdac/bridgenode:webserver_v08'
      privileged: true
      tty: true
      network_mode: "host"
      container_name: webserver
      command: init
      working_dir: /opt
      depends_on:
       - databases
     databases:
      image: 'hdac/bridgenode:database_v08'
      privileged: true
      tty: true
      network_mode: "host"
      container_name: databases
      command: init
      working_dir: /home
     anchor:
      image: 'hdac/bridgenode:anchoring_v08'
      stdin_open: true
      privileged: true
      network_mode: "host"
      tty: true
      container_name: anchoring
      command: init
      working_dir: /opt
      depends_on:
       - webserver
     contract:
      image: 'hdac/bridgenode:contract_v08'
      privileged: true
      network_mode: "host"
      tty: true
      container_name: contract
      command: init
      working_dir: /opt
      depends_on:
       - webserver  
  1. Execute Docker Compose and set the initial configuration
 $ sudo docker-compose up -d  

After running, make sure that some port numbers do not overlap.
The port numbers used are as follows.
The network modes for all containers are based on the hosts, therefore, each container is connected to its local IP.

80(Apache), 3306(DB), 8822(Main chain rpc), 16001(Side chain rpc), 8309/8209(Java AJP/1.3)  

If you would like to change the port used in the container, you have to modify the internal configuration file as explained below.
As all containers access the DB, you have to change the port in all of the containers in the case of changing the Database port.

 $ sudo docker exec -it [container name] bash  
 Apache port setting : webserver container | path : /etc/httpd/conf/httpd.conf | apply : httpd service restart  
 Chain port setting : webserver container | path : /root/.hdac/hdac or sideChain/param.dat  | apply : runmain and runside service start
 Java port setting : webserver container | path :  /usr/local/tomcat1 or tomcat2/conf/server.xml | apply : tomcat-1 or tomcat-2 service restart  
 DB port setting : database container | path : /etc/my.cnf | apply : mysqld service restart  

After the setting, you may access the user wizard page through a browser like chrome.

 (Your server IP)123.456.78.999:(Apache port)80/main.do  
⁠2. How to create chain node

The Web Server Container provides two default cores, the Mainnet and a side chain. Therefore, you may use the default side chain or create a chain with a different name and use it.

  1. In case of using the default “SideChain” (not changing the core configuration)
    The chain operation is executed through two specific services, “Runmain” and “Runside.” Thus, it is possible to operate the chain by executing the two services. In the case of Mainnet, it may take minimum 30 minutes to maximum 2 hours to synchronize.
 $ Systemctl enable runmain.service  
 $ Systemctl start runmain.service  
 $ Systemctl enable runside.service  
 $ Systemctl start runside.service  
  1. In case of using the default “SideChain” (changing the core configuration)
    You have to change the configuration before the service starts.
  • If you would like to change the core configuration, modify the file in the path below, and then start the service.
 /root/.hdac/sideChain/params.dat  
  • If you would like to change the RPC parameter, modify the file in the path below, and then start the service.
 /root/.hdac/hdac/hdac.conf (main chain)  
 /root/.hdac/sideChain/hdac.conf (side chain)  
  1. In case of creating a chain with a new name.
  • Chain with a new name
 $ cd /opt/chain_side  
 $ ./hdac-util create (new chain name)  
 You can find out new folder maked under path /root/.hdac
  • Change the configuration
 $ cp /root/.hdac/sideChain/params.dat /root/.hdac/(new chain name)  
 $ vi params.dat (have to change chain name, not 'sideChain')  
 $ cp /root/.hdac/sideChain/hdac.conf /root/.hdac/(new chain name)  
 $ vi hdac.conf (change RPC configuration if you want)  

In this case, change the chain name of the “Runside” service script to the newly created name, and then start the service.

 $ vi /usr/lib/systemd/system/runside.service
⁠3. How to operate Anchoring Service

The Anchoring Service is a standalone service connected to each chain, executed after running the Web Server and the Database. The process for executing the service is as follows.

 $ sudo docker exec -it anchoring bash  
 $ cd anchor/config  
 Modify anchor.properties (Description of each property is on the code)  
 After modifying, crond service start. $ systemctl start crond  
 You can check the log file /opt/anchor/anchorLog.log  

The Anchor.properties file must be changed before executing the said service. Changing the properties during the operation of service may lead to wrong verification results.

⁠4. How to operate Web Service

After running the Web Server Container, you may access some webpages that we provide.

 123.456.78.9 (your IP):80 (your apache port)/main.do  

In order to implement contract services such as issuing the tokens, you have to deposit some coins in the three addresses you see on the main page.
You can also use three menus, Contract Info, Issue Token and Verify Transaction. Among these three, the Issue Token menu may be accessed from specific IPs in the configuration file of the Web Server Container.

 $ docker exec -it webserver bash  
 $ cd /opt/tomcat1/myapp/WEB-INF/classes/config (same in tomcat2)  
 $ vi access-ip.propertoes  

If you would like to access the menu from all IPs, do not put in any IP on the properties file. However, if you put in a specific IP on the file, you may access the Issue Token menu from that IP only.
Each menu is briefly described as follows.

  • Contract Info: You may check the information on the issued tokens.
  • Issue Token: You may issue tokens by inserting some conditions. Only specific persons may access this menu as indicated above.
  • Verify Transaction: You may verify transactions created in the side chain. This service is operated based on the Anchoring Service.
⁠5. How to operate Contract Service

In the case of contract services, three modules are running in the Container, i.e. Grab, Handle and Refund.

  • Grab Module: It locates the transactions to be exchanged or refunded in the contract address from the Main and the Side and saves them on the Database.
  • Handle Module: It exchanges the data saved on Grab to tokens.
  • Refund Module: It deals with refunds based on the data saved on Grab.

Each module is operated through CRONTAB, and the change of script and period is done as follows.

 $ docker exec -it contract bash  
 $ cd contract  
 $ crontab -e (change period of each script)  
 $ systemctl start crond (start CRONTAB service after change period)

At the time of operating the Contract Container, the RPC information and service configuration of the chain are operated based on the values on server config and service config table of the Database, therefore, in order to change any of them, access the Database and change the values on the table.

 $ docker exec -it databases bash  
 $ mysql -u root -p (password : hdac1234)  
 $ use test;  
 $ show tables;  
 If necessary, modify server_config, service_config table contents to adapt your running environment.  
⁠6. How to operate sub node service

We provide an additional node image that can be synchronized to another node. How to use the node image is as follows.
For subnode, use the same params as the node you want to connect to. So run on another server to avoid a port crash.

 $ docker run --privileged -d --net=host --name subnode hdac/bridgenode:subnode_v08 init  
 $ docker exec -it subnode bash  
 $ ./core.sh (Enter seed node information)     
 $ cd chain_util  
 $ ./hdac-cli [chain name] getinfo (Check node synchronization)
⁠7. How to test bridge node

We are providing KASSE to test the bridgenode. The win and osx versions are available and the download location is as follows.

⁠Version description (v0.9)

  1. Update contactLib when generating tokens
  2. Share all libraries between containers via nfs (new docker image nfsserver_v09 added)
  3. Anchoring service module operates through a package jar file
  4. Database table added (access_ip, anchor_config)
⁠How to run images (v0.9)

All shared libraries are managed by nfsserver and must be run first.
The nfsserver image should have an nfs server installed on the host that want to run.

 $ yum install nfs-utils nfs-utils-lib
 $ vi /etc/exports 
 /opt/shareLib/ *(rw,sync,no_root_squash) -> save share directory 
 $ systemctl start nfs
 $ systemctl stop firewalld  

Prepare the docker-compose as shown below and run the container.

version: '2'
services:
  nfs:
   image: 'hdac/bridgenode:nfsserver_v09'
   stdin_open: true
   privileged: true
   tty: true
   network_mode: "host"
   volumes:
    - /opt/shareLib:/opt/shareLib
   container_name: nfsserver
   working_dir: /opt
   command: init

After running the container, you can see that the /opt/shareLib directory on the host is created and the libraries are shared.
If the shared library has been created successfully, modify the compose file of other containers as shown below.

version: '2'
services:
  webserver:
   image: 'hdac/bridgenode:webserver_v09'
   privileged: true
   tty: true
   network_mode: "host"
   container_name: webserver
   command: init
   working_dir: /opt
   volumes:
    - lib-share:/opt/shareLib
   depends_on:
    - databases
  databases:
   image: 'hdac/bridgenode:database_v09'
   privileged: true
   tty: true
   network_mode: "host"
   container_name: databases
   command: init
   working_dir: /home
  anchor:
   image: 'hdac/bridgenode:anchoring_v09'
   stdin_open: true
   privileged: true
   network_mode: "host"
   tty: true
   container_name: anchoring
   command: init
   working_dir: /opt
   volumes:
    - lib-share:/opt/anchor/shareLib:ro
   depends_on:
    - webserver
  contract:
   image: 'hdac/bridgenode:contract_v09'
   privileged: true
   tty: true
   network_mode: "host"
   container_name: contract
   command: init
   working_dir: /opt
   volumes:
    - lib-share:/opt/contract/shareLib:ro
   depends_on:
    - webserver
volumes:
 lib-share:
  driver: local
  driver_opts:
    type: nfs
    o: "addr=127.0.0.1,rw"
    device: ":/opt/shareLib"

Settings for the nfs volume have been added and the nfs 'addr' value is set to the IP of the host that ran the nfsserver image.
If all containers have been run successfully, check the library sharing success for each container.

webserver : /opt/shareLib
contract : /opt/contract/shareLib
anchoring : /opt/anchor/shareLib  

⁠License

Copyright(c) 2018-2019 hdactech.com.
The original code is distributed based on the MIT software license.

Tag summary

Content type

Image

Digest

Size

205.7 MB

Last updated

over 7 years ago

docker pull hdac/bridgenode:nfsserver_v09