Skip to content

Commit

Permalink
Merge pull request #168 from SophiaTX/rc_1_1_0
Browse files Browse the repository at this point in the history
Rc 1 1 0
  • Loading branch information
ejossev authored Nov 26, 2018
2 parents 460ff4d + 44a54da commit 21ed231
Show file tree
Hide file tree
Showing 131 changed files with 8,343 additions and 37,635 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
.idea
libraries/manifest/sophiatx_manifest/__pycache__/
ciscripts/deploy/ansible/playbooks/deploy-node.retry
cmake-build-debug
CMakeCache.txt
CMakeFiles
*.user
cmake-build-release/

30 changes: 17 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
# Defines SophiaTX library target.

find_program(CCACHE_PROGRAM ccache)
if(CCACHE_PROGRAM)
MESSAGE(STATUS "Building with ccache")
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}")
endif()

project( SophiaTX )
cmake_minimum_required( VERSION 3.2 )

Expand Down Expand Up @@ -105,10 +112,12 @@ if( SKIP_BY_TX_ID )
endif()

OPTION( SOPHIATX_STATIC_BUILD "Build sophiatxd as a static library (ON or OFF)" OFF )

if( SOPHIATX_STATIC_BUILD AND ( ( MSVC AND NOT MINGW ) OR APPLE ) )
MESSAGE( STATUS "Statuc build is not available on Windows or OS X" )
MESSAGE( STATUS "Static build is not available on Windows or OS X" )
SET( SOPHIATX_STATIC_BUILD OFF )
endif()

MESSAGE( STATUS "SOPHIATX_STATIC_BUILD: ${SOPHIATX_STATIC_BUILD}" )

OPTION( PRIVATE_NET "Building as private net (ON OR OFF)" OFF)
Expand Down Expand Up @@ -160,7 +169,7 @@ IF( WIN32 )
ENDIF(WIN32)


FIND_PACKAGE(Boost 1.60 REQUIRED COMPONENTS ${BOOST_COMPONENTS})
FIND_PACKAGE(Boost 1.65 REQUIRED COMPONENTS ${BOOST_COMPONENTS})

find_package(JNI)
if(JNI_FOUND AND (NOT ABAP_INTERFACE))
Expand Down Expand Up @@ -214,19 +223,13 @@ if( WIN32 )
# Optimization flag apparently needed to get rid of "File too big" assembler errors when compiling in Debug mode
# See: https://stackoverflow.com/questions/14125007/gcc-string-table-overflow-error-during-compilation/14601779#29479701
SET(CMAKE_CXX_FLAGS_DEBUG "-O2")
if ( FULL_STATIC_BUILD )
if ( SOPHIATX_STATIC_BUILD )
set( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libstdc++ -static-libgcc")
endif ( FULL_STATIC_BUILD )
endif ( SOPHIATX_STATIC_BUILD )
endif( MSVC )

else( WIN32 ) # Apple AND Linux

find_library(READLINE_LIBRARIES NAMES readline)
find_path(READLINE_INCLUDE_DIR readline/readline.h)
#if(NOT READLINE_INCLUDE_DIR OR NOT READLINE_LIBRARIES)
# MESSAGE(FATAL_ERROR "Could not find lib readline.")
#endif()

if( APPLE )
# Apple Specific Options Here
message( STATUS "Configuring SophiaTX on OS X" )
Expand All @@ -237,14 +240,15 @@ else( WIN32 ) # Apple AND Linux
set( CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -std=c++11 -Wall" )
set( rt_library rt )
set( pthread_library pthread)
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
if ( NOT DEFINED crypto_library )
# I'm not sure why this is here, I guess someone has openssl and can't detect it with find_package()?
# if you have a normal install, you can define crypto_library to the empty string to avoid a build error
set( crypto_library crypto)
endif ()
if ( FULL_STATIC_BUILD )
if ( SOPHIATX_STATIC_BUILD )
set( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libstdc++ -static-libgcc")
endif ( FULL_STATIC_BUILD )
endif ( SOPHIATX_STATIC_BUILD )
endif( APPLE )

if(BUILD_PIC)
Expand All @@ -261,7 +265,7 @@ else( WIN32 ) # Apple AND Linux
endif()
endif()

set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG")
set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG -ftemplate-backtrace-limit=0")

# based on http://www.delorie.com/gnu/docs/gdb/gdb_70.html
# uncomment this line to tell GDB about macros (slows compile times)
Expand Down
20 changes: 14 additions & 6 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pipeline {
BUILD_TYPE = "Debug"
}
}
sh "cmake -DUSE_PCH=ON -DBOOST_ROOT=${BOOST_160} -DOPENSSL_ROOT_DIR=${OPENSSL_102} -DFULL_STATIC_BUILD=ON -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DCMAKE_INSTALL_PREFIX=install -DSOPHIATX_EGENESIS_JSON=${GENESIS_FILE} -DBUILD_SOPHIATX_TESTNET=${params.build_as_testnet}"
sh "cmake -DUSE_PCH=ON -DBOOST_ROOT=${BOOST_167} -DOPENSSL_ROOT_DIR=${OPENSSL_111} -DSOPHIATX_STATIC_BUILD=ON -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DCMAKE_INSTALL_PREFIX=install -DSOPHIATX_EGENESIS_JSON=${GENESIS_FILE} -DBUILD_SOPHIATX_TESTNET=${params.build_as_testnet}"
sh 'make -j4'
}
}
Expand All @@ -38,6 +38,7 @@ pipeline {
script {
if( !params.build_as_testnet ) {
sh './tests/chain_test'
sh './tests/plugin_test'
}
}
}
Expand All @@ -56,15 +57,22 @@ pipeline {
archiveArtifacts '*.gz'
}
dir('bin') {
sh 'rm -f test*' //remove test binaries

script {
if( !params.build_as_debug ) {
sh 'strip -s *' //strip symbols
}

if( params.build_as_testnet ) {
sh 'cp ${WORKSPACE}/contrib/testnet_config.ini .'//copy config
sh 'tar -czf ${ARCHIVE_NAME} alexandria_deamon cli_wallet sophiatxd testnet_config.ini' //create tar file
} else {
sh 'cp ${WORKSPACE}/contrib/fullnode_config.ini .'//copy configs
sh 'cp ${WORKSPACE}/contrib/witness_config.ini .'//copy configs
sh 'tar -czf ${ARCHIVE_NAME} alexandria_deamon cli_wallet sophiatxd fullnode_config.ini witness_config.ini' //create tar file
}
}
sh 'rm -f test*' //remove test binaries
sh 'cp ${WORKSPACE}/contrib/fullnode_config.ini .'//copy configs
sh 'cp ${WORKSPACE}/contrib/witness_config.ini .'//copy configs
sh 'tar -czf ${ARCHIVE_NAME} alexandria_deamon cli_wallet sophiatxd fullnode_config.ini witness_config.ini' //create tar file
archiveArtifacts '*.gz'
}
}
Expand Down Expand Up @@ -117,4 +125,4 @@ def get_label_name() {
} else {
return 'linux'
}
}
}
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Introducing SophiaTX (beta)

SophiaTX is a Delegated Proof of Stake blockchain that uses a "Proof of Brain" social consensus algorithm for token allocation.
SophiaTX is a Delegated Proof of Stake blockchain.

# Public Announcement & Discussion

Expand Down Expand Up @@ -51,3 +51,4 @@ We provide a basic cli wallet for interfacing with `sophiatxd`. The wallet is se

For a full web node, you need at least 110GB of disk space available. SophiaTXd uses a memory mapped file which currently holds 56GB of data and by default is set to use up to 80GB. The block log of the blockchain itself is a little over 27GB. It's highly recommended to run sophiatxd on a fast disk such as an SSD or by placing the shared memory files in a ramdisk and using the `--shared-file-dir=/path` command line option to specify where. At least 16GB of memory is required for a full web node. Seed nodes (p2p mode) can run with as little as 4GB of memory with a 24 GB state file. Any CPU with decent single core performance should be sufficient. SophiaTXd is constantly growing, so you may find you need more disk space to run a full node. We are also constantly working on optimizing SophiaTX's use of disk space.
```
131 changes: 131 additions & 0 deletions ciscripts/deploy/ansible/playbooks/deploy-node.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
---
- hosts: "{{ host }}"
remote_user: "{{ user }}"
become: yes
become_user: "{{ user }}"
vars:
source_dir: ~/sophiatx-binaries/
bc_data_dir: ~/sophiatx-binaries/bc-data/
config_file_name: testnet_config.ini

tasks:
- block:
- name: "Checking folders \"{{source_dir}}\", \"{{bc_data_dir}}\" if they exist"
stat:
path: "{{item}}"
register: folder_stats
with_items: ["{{source_dir}}", "{{bc_data_dir}}"]
- name: "Creating non-existing folders"
file:
path: "{{item.item}}"
state: directory
mode: 0755
group: "{{ user }}"
owner: "{{ user }}"
when: item.stat.exists == false
with_items: "{{folder_stats.results}}"


- name: Finding all existing *.old files
find:
paths: "{{ source_dir }}"
patterns: "*.old"
register: files_to_delete
- name: Deleting existing *.old files
file:
path: "{{ item.path }}"
state: absent
with_items: "{{ files_to_delete.files }}"


- block:
- name: Finding all existing *.gz files
find:
paths: "{{ source_dir }}"
patterns: "*.gz"
register: gz_files_to_rename
- name: Renaming files to *.gz.old files
command: mv "{{ item.path }}" "{{ item.path }}".old
with_items: "{{ gz_files_to_rename.files }}"

- name: Checking {{config_file_name}} file
stat:
path: "{{ source_dir }}{{config_file_name}}"
register: config_file_result
- name: Renaming {{config_file_name}} file to *.old
command: mv "{{ source_dir }}{{config_file_name}}" "{{ source_dir }}{{config_file_name}}".old
when: config_file_result.stat.exists == True



- name: Downloading source {{ sourceUrl }}
get_url:
url: "{{ sourceUrl }}"
dest: "{{ source_dir }}"
mode: 0440



- block:
- name: Installing unzip if not already installed
apt:
name: unzip
state: latest
- name: Unarchiving archive.zip
unarchive:
src: "{{ source_dir }}archive.zip"
dest: "{{ source_dir }}"
remote_src: yes
- name: Finding concrete unarchived sophiatx_#<...>.tar.gz file
find:
paths: "{{ source_dir }}/archive"
patterns: "sophiatx_*.tar.gz"
register: sophia_tar_file
- name: Moving found unarchived sophiatx_#<...>.tar.gz to the parent folder
command: mv "{{ item.path }}" "{{ source_dir }}"
with_items: "{{ sophia_tar_file.files }}"
- name: Deleting archive.zip and archive folder, which are not needed anymore
file:
state: absent
path: "{{item}}"
with_items: ["{{ source_dir }}archive.zip", "{{ source_dir }}archive"]
when: sourceUrl is match('.*\/archive\.zip$')


- find:
paths: "{{ source_dir }}"
patterns: "sophiatx_*.tar.gz"
register: sophia_tar_file
- name: Unarchiving sophiatx_#<NUM>.tar.gz
unarchive:
src: "{{ item.path }}"
dest: "{{ source_dir }}"
remote_src: yes
with_items: "{{ sophia_tar_file.files }}"


- name: Copying {{config_file_name}} to {{bc_data_dir}}
command: cp "{{ source_dir }}{{config_file_name}}" "{{bc_data_dir}}"config.ini


- name: Killing all screen sessions that are actually running
command: killall screen
ignore_errors: yes # ignore error when there are no running sessions


- name: Starting sophia demon with --replay-blockchain flag
command: screen -dmS sophia bash -c '{{ source_dir }}sophiatxd -d {{ source_dir }}bc-data/ --replay-blockchain; exec $SHELL'
when: replayBlockchain == "true"

- name: Starting sophia demon
command: screen -dmS sophia bash -c '{{ source_dir }}sophiatxd -d {{ source_dir }}bc-data/; exec $SHELL'
when: replayBlockchain == "false"


- name: Waiting 5 seconds for sophia demon to fully initialize and start.
pause:
seconds: 5


- name: Starting alexandria demon
command: screen -dmS alexandria bash -c '{{ source_dir }}alexandria_deamon -H0.0.0.0:9195 -C*; exec $SHELL'
43 changes: 43 additions & 0 deletions ciscripts/deploy/deploy-node.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash

while getopts "h:u:s:r" opt; do
case $opt in
h)
host="$OPTARG"
;;
u)
user="$OPTARG"
;;
s)
sourceUrl="$OPTARG"
;;
r)
replayBlockchain=true
;;
*)
esac
done


# check required variables
usageMessage="$0 -h host -u user [-s sourceUrl] [-r]"
[[ $# -eq 0 || -z $host ]] && { echo "-h host parameter is required ! Usage: \"$usageMessage\""; exit 1; }
[[ $# -eq 0 || -z $user ]] && { echo "-u user parameter is required ! Usage: \"$usageMessage\""; exit 1; }

# set default values for unset optional pars
if [[ -z $sourceUrl ]]
then
sourceUrl="https://jenkins.sophiatx.com/job/SophiaTX-develop/lastSuccessfulBuild/artifact/*zip*/archive.zip"
fi

if [[ -z $replayBlockchain ]]
then
replayBlockchain=false
fi

ansible-playbook ansible/playbooks/deploy-node.yml --extra-vars "host=$host user=$user sourceUrl=$sourceUrl replayBlockchain=$replayBlockchain" -i $host,

if [ $? -ne 0 ]; then
echo "ERROR while updating node on \"${host}\". Error code: $?"
exit 2
fi
45 changes: 45 additions & 0 deletions ciscripts/deploy/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Automatic node deploy

Script connects to the server and automatically deploys node binaries and stores previous version

Created file structure on server:

~ # home of specified user
├── ...
├── sophiatx-binaries # Binaries folder
│ ├── sophiatx_#<NUM>.tar.gz # SophiaTX archived binaries
│ ├── sophiatx_#<NUM>.tar.gz.old # Previous version of SophiaTX archived binaries
│ ├── testnet_config.ini # SophiaTX demon config file
│ ├── testnet_config.ini.old # Previous version of SophiaTX demon config file
│ ├── sophiatxd # SophiaTX demon
│ ├── alexandria_deamon # Alexandria demon
│ └── bc-data # Blokchain data folder
│ ├── config.ini # Copied testnet_config.ini
│ └── ...
└── ...


## Usage

./deploy-node.sh -h host -u user [-s sourceUrl] [-r]

####Arguments description:

-h host : host(server), where node binaries should be deployed into

-u user : user to be used to connect to the host. This user has to have id_rsa.pub imported on host

[-s sourceUrl] : sourceUrl from which are the the binaries downloaded. optional. In case it is not specified, latest binaries are downloaded.

[-r] : replay-blockain flag. It is used when starting sophiatxd. optional


## Requirements

For using automatic deploy script, you have to install Ansible on your machine:

$ sudo apt-get update
$ sudo apt-get install software-properties-common
$ sudo apt-add-repository ppa:ansible/ansible
$ sudo apt-get update
$ sudo apt-get install ansible
Loading

0 comments on commit 21ed231

Please sign in to comment.