Skip to content

Commit

Permalink
Merge branch 'beos-core-issue-2-3' into 'beos-initial-release'
Browse files Browse the repository at this point in the history
Fix for issue #2 and #3. Fix for cmake issues with targets

See merge request blocktrades/beos-core!11
  • Loading branch information
vogel76 committed Nov 8, 2018
2 parents 8c537d1 + ce9e3c6 commit 16e4559
Show file tree
Hide file tree
Showing 12 changed files with 185 additions and 502 deletions.
27 changes: 15 additions & 12 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,30 @@ build:
- which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )
- eval $(ssh-agent -s)
- ssh-add <(echo "$SSH_PRIVATE_KEY")
- git submodule update --init --recursive
- pwd
- pip3 install distro
- cd cd-scripts
- cp config-ci.py config.py
- ./deploy.py --build-beos
- ./deploy.py --initialize-beos
#only:
# - beos-initial-release
cache: {}
tags:
- ryzen
allow_failure: false


run:
stage: run
script:
- cd cd-scripts
- cp config-ci.py config.py
- ./deploy.py --initialize-beos
#only:
#- beos-initial-release
when: manual
tags:
- ryzen
allow_failure: false
#run:
# stage: run
# script:
# - cd cd-scripts
# - cp config-ci.py config.py
# - ./deploy.py --initialize-beos
# #only:
# #- beos-initial-release
# when: manual
# tags:
# - ryzen
# allow_failure: false
98 changes: 98 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -284,3 +284,101 @@ install(FILES libraries/fc/src/network/LICENSE.go DESTINATION ${CMAKE_INSTALL_FU

include(package)
include(doxygen)

if ("${PROXY_ASSET_NAME}" STREQUAL "")
set(PROXY_ASSET_NAME "PXBTS")
endif()

if ("${PROXY_ASSET_PRECISION}" STREQUAL "")
set(PROXY_ASSET_PRECISION "4")
endif()

if ("${PROXY_INITIAL_AMOUNT}" STREQUAL "")
set(PROXY_INITIAL_AMOUNT "100000.0000")
endif()

if ("${BEOS_SYMBOL_PRECISION}" STREQUAL "")
set(BEOS_SYMBOL_PRECISION "10000")
endif()

if ("${CORE_INITIAL_AMOUNT}" STREQUAL "")
set(CORE_INITIAL_AMOUNT "100000.0000")
endif()

if ("${INIT_RAM}" STREQUAL "")
set(INIT_RAM "1000000")
endif()

if ("${STARTING_BLOCK_FOR_INITIAL_WITNESS_ELECTION}" STREQUAL "")
set(STARTING_BLOCK_FOR_INITIAL_WITNESS_ELECTION "100")
endif()

if ("${STARTING_BLOCK_FOR_BEOS_DISTRIBUTION}" STREQUAL "")
set(STARTING_BLOCK_FOR_BEOS_DISTRIBUTION "days(7).to_seconds() * 2")
endif()

if ("${ENDING_BLOCK_FOR_BEOS_DISTRIBUTION}" STREQUAL "")
set(ENDING_BLOCK_FOR_BEOS_DISTRIBUTION "days(98).to_seconds() * 2")
endif()

if ("${DISTRIBUTION_PAYMENT_BLOCK_INTERVAL_FOR_BEOS_DISTRIBUTION}" STREQUAL "")
set(DISTRIBUTION_PAYMENT_BLOCK_INTERVAL_FOR_BEOS_DISTRIBUTION "hours(1).to_seconds() * 2")
endif()

if ("${AMOUNT_OF_REWARD_BEOS}" STREQUAL "")
set(AMOUNT_OF_REWARD_BEOS "asset().symbol.precision()")
endif()

if ("${STARTING_BLOCK_FOR_RAM_DISTRIBUTION}" STREQUAL "")
set(STARTING_BLOCK_FOR_RAM_DISTRIBUTION "days(7).to_seconds() * 2")
endif()

if ("${ENDING_BLOCK_FOR_RAM_DISTRIBUTION}" STREQUAL "")
set(ENDING_BLOCK_FOR_RAM_DISTRIBUTION "days(280).to_seconds() * 2")
endif()

if ("${DISTRIBUTION_PAYMENT_BLOCK_INTERVAL_FOR_RAM_DISTRIBUTION}" STREQUAL "")
set(DISTRIBUTION_PAYMENT_BLOCK_INTERVAL_FOR_RAM_DISTRIBUTION "hours(1).to_seconds() * 2")
endif()

if ("${AMOUNT_OF_REWARD_RAM}" STREQUAL "")
set(AMOUNT_OF_REWARD_RAM "5000000")
endif()

if ("${STARTING_BLOCK_FOR_TRUSTEE_DISTRIBUTION}" STREQUAL "")
set(STARTING_BLOCK_FOR_TRUSTEE_DISTRIBUTION "days(7).to_seconds() * 2")
endif()

if ("${ENDING_BLOCK_FOR_TRUSTEE_DISTRIBUTION}" STREQUAL "")
set(ENDING_BLOCK_FOR_TRUSTEE_DISTRIBUTION "days(98).to_seconds() * 2")
endif()

if ("${DISTRIBUTION_PAYMENT_BLOCK_INTERVAL_FOR_TRUSTEE_DISTRIBUTION}" STREQUAL "")
set(DISTRIBUTION_PAYMENT_BLOCK_INTERVAL_FOR_TRUSTEE_DISTRIBUTION "hours(1).to_seconds() * 2")
endif()

if ("${AMOUNT_OF_REWARD_TRUSTEE}" STREQUAL "")
set(AMOUNT_OF_REWARD_TRUSTEE "asset().symbol.precision()")
endif()

if ("${STAKE_NET_QUANTITY}" STREQUAL "")
set(STAKE_NET_QUANTITY "10000.0000")
endif()

if ("${STAKE_CPU_QUANTITY}" STREQUAL "")
set(STAKE_CPU_QUANTITY "10000.0000")
endif()

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/contracts/eosio.init/eosio.init.hpp.in ${CMAKE_CURRENT_BINARY_DIR}/contracts/eosio.init/eosio.init.hpp)

if ("${NODEOS_HTTP_SERVER_PORT}" STREQUAL "")
set(NODEOS_HTTP_SERVER_PORT "http://127.0.0.1:8888")
endif()

if ("${SIGNATURE_PROVIDER}" STREQUAL "")
set(SIGNATURE_PROVIDER "${EOSIO_ROOT_KEY}=KEOSD:http://127.0.0.1:8900/v1/wallet/sign_digest")
endif()

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cd-scripts/resources/config.ini.in ${CMAKE_CURRENT_BINARY_DIR}/resources/config.ini @ONLY)

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cd-scripts/resources/genesis.json.in ${CMAKE_CURRENT_BINARY_DIR}/resources/genesis.json)
12 changes: 6 additions & 6 deletions cd-scripts/config-ci.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
LOG_LEVEL = INFO

# directory where all sources will be downloaded
SOURCES_DOWNLOAD_DIR = os.environ["HOME"] + "/ci"
SOURCES_DOWNLOAD_DIR = os.environ["HOME"] + "/ci/sources"
# beos main directory
BEOS_DIR = SOURCES_DOWNLOAD_DIR + "/beos-core"
BEOS_DIR = os.environ["CI_PROJECT_DIR"]
# path to beos sources repository
BEOS_REPOSITORY_PATH = "git@gitlab.syncad.com:blocktrades/beos-core.git"
BEOS_REPOSITORY_BRANCH = 'beos-initial-release'
#
# eosio build directory - here will land final build
BEOS_BUILD_DIR = os.environ["HOME"] + "/ci/build/beos-autobuild2"
BEOS_BUILD_DIR = os.environ["HOME"] + "/ci/build/beos-autobuild"

MAIN_LOG_PATH = os.path.dirname(os.path.abspath(__file__)) + "/beos_deploy_main.log"
ERROR_LOG_PATH = os.path.dirname(os.path.abspath(__file__)) + "/beos_deploy_main.log"
Expand Down Expand Up @@ -136,11 +136,11 @@
COMMON_SYSTEM_ACCOUNT_ACTIVE_PRIVATE_KEY
]
# source file for beos config
BEOS_CONFIG_FILE_SRC = os.path.dirname(os.path.abspath(__file__)) + "/resources/beos.config.ini"
BEOS_CONFIG_FILE_SRC = BEOS_BUILD_DIR + "/resources/config.ini"
# beos config file name
BEOS_CONFIG_FILE = "beos.config.ini"
BEOS_CONFIG_FILE = "config.ini"
# source file for genesis file
GENESIS_JSON_FILE_SRC = os.path.dirname(os.path.abspath(__file__)) + "/resources/genesis.json"
GENESIS_JSON_FILE_SRC = BEOS_BUILD_DIR + "/resources/genesis.json"
# genesis json file name
GENESIS_JSON_FILE = "genesis.json"
#starting node index
Expand Down
6 changes: 3 additions & 3 deletions cd-scripts/config-example.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,11 @@
COMMON_SYSTEM_ACCOUNT_ACTIVE_PRIVATE_KEY
]
# source file for beos config
BEOS_CONFIG_FILE_SRC = os.path.dirname(os.path.abspath(__file__)) + "/resources/beos.config.ini"
BEOS_CONFIG_FILE_SRC = BEOS_BUILD_DIR + "/resources/config.ini"
# beos config file name
BEOS_CONFIG_FILE = "beos.config.ini"
BEOS_CONFIG_FILE = "config.ini"
# source file for genesis file
GENESIS_JSON_FILE_SRC = os.path.dirname(os.path.abspath(__file__)) + "/resources/genesis.json"
GENESIS_JSON_FILE_SRC = BEOS_BUILD_DIR + "/resources/genesis.json"
# genesis json file name
GENESIS_JSON_FILE = "genesis.json"
#starting node index
Expand Down
87 changes: 21 additions & 66 deletions cd-scripts/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
logger.addHandler(ch)
logger.addHandler(fh)

def run_command(parameters, working_dir):
ret = subprocess.run(parameters, cwd = working_dir, stdout=config.log_main, stderr=config.log_main)
def run_command(parameters, working_dir, run_shell = False):
ret = subprocess.run(parameters, cwd = working_dir, shell = run_shell, stdout=config.log_main, stderr=config.log_main)
retcode = ret.returncode
if retcode == 0:
logger.debug("Executed with ret: {0}".format(ret))
Expand Down Expand Up @@ -282,6 +282,23 @@ def build_eosio(c_compiler, cxx_compiler):
"-DEOSIO_ROOT_KEY={0}".format(config.EOSIO_PUBLIC_KEY),
"-DGATEWAY_ROOT_KEY={0}".format(config.BEOS_GATEWAY_PUBLIC_KEY),
"-DDISTRIBUTION_ROOT_KEY={0}".format(config.BEOS_DISTRIB_PUBLIC_KEY),
"-DPROXY_ASSET_PRECISION={0}".format(config.PROXY_ASSET_PRECISION),
"-DPROXY_ASSET_NAME={0}".format(config.PROXY_ASSET_NAME),
"-DSTARTING_BLOCK_FOR_INITIAL_WITNESS_ELECTION={0}".format(config.STARTING_BLOCK_FOR_INITIAL_WITNESS_ELECTION),
"-DSTARTING_BLOCK_FOR_BEOS_DISTRIBUTION={0}".format(config.STARTING_BLOCK_FOR_BEOS_DISTRIBUTION),
"-DENDING_BLOCK_FOR_BEOS_DISTRIBUTION={0}".format(config.ENDING_BLOCK_FOR_BEOS_DISTRIBUTION),
"-DDISTRIBUTION_PAYMENT_BLOCK_INTERVAL_FOR_BEOS_DISTRIBUTION={0}".format(config.DISTRIBUTION_PAYMENT_BLOCK_INTERVAL_FOR_BEOS_DISTRIBUTION),
"-DAMOUNT_OF_REWARD_BEOS={0}".format(config.AMOUNT_OF_REWARD_BEOS),
"-DSTARTING_BLOCK_FOR_RAM_DISTRIBUTION={0}".format(config.STARTING_BLOCK_FOR_RAM_DISTRIBUTION),
"-DENDING_BLOCK_FOR_RAM_DISTRIBUTION={0}".format(config.ENDING_BLOCK_FOR_RAM_DISTRIBUTION),
"-DDISTRIBUTION_PAYMENT_BLOCK_INTERVAL_FOR_RAM_DISTRIBUTION={0}".format(config.DISTRIBUTION_PAYMENT_BLOCK_INTERVAL_FOR_RAM_DISTRIBUTION),
"-DAMOUNT_OF_REWARD_RAM={0}".format(config.AMOUNT_OF_REWARD_RAM),
"-DSTARTING_BLOCK_FOR_TRUSTEE_DISTRIBUTION={0}".format(config.STARTING_BLOCK_FOR_TRUSTEE_DISTRIBUTION),
"-DENDING_BLOCK_FOR_TRUSTEE_DISTRIBUTION={0}".format(config.ENDING_BLOCK_FOR_TRUSTEE_DISTRIBUTION),
"-DDISTRIBUTION_PAYMENT_BLOCK_INTERVAL_FOR_TRUSTEE_DISTRIBUTION={0}".format(config.DISTRIBUTION_PAYMENT_BLOCK_INTERVAL_FOR_TRUSTEE_DISTRIBUTION),
"-DAMOUNT_OF_REWARD_TRUSTEE={0}".format(config.AMOUNT_OF_REWARD_TRUSTEE),
"-DNODEOS_HTTP_SERVER_PORT={0}".format("http://{0}:{1}".format(config.NODEOS_IP_ADDRESS, config.NODEOS_PORT)),
"-DSIGNATURE_PROVIDER={0}".format("{0}=KEOSD:http://{1}:{2}/v1/wallet/sign_digest".format(config.EOSIO_PUBLIC_KEY, config.KEOSD_IP_ADDRESS, config.KEOSD_PORT)),
config.BEOS_DIR
]
logger.info("Running cmake with params {0}".format(" ".join(params)))
Expand All @@ -295,71 +312,15 @@ def build_eosio(c_compiler, cxx_compiler):
run_command(params, config.BEOS_BUILD_DIR)

def install_beos(c_compiler, cxx_compiler):
configure_eosio_init()
install_eosio(c_compiler, cxx_compiler)

def build_beos(c_compiler, cxx_compiler):
configure_eosio_init()
#
configure_config_ini()
#
configure_genesis_json()
#
build_eosio(c_compiler, cxx_compiler)

def create_file_from_template(template_src, file_dst, template_dict):
dst = None
with open(template_src, "r", encoding = "utf-8") as in_f:
from string import Template
src = Template(in_f.read())
dst = src.substitute(template_dict)
with open(file_dst, "w", encoding = "utf-8") as out_f:
out_f.write(dst)

def configure_eosio_init():
eosio_init_opt = {
"PROXY_ASSET_PRECISION" : config.PROXY_ASSET_PRECISION,
"PROXY_ASSET_NAME" : config.PROXY_ASSET_NAME,
"STARTING_BLOCK_FOR_INITIAL_WITNESS_ELECTION" : config.STARTING_BLOCK_FOR_INITIAL_WITNESS_ELECTION,
"STARTING_BLOCK_FOR_BEOS_DISTRIBUTION" : config.STARTING_BLOCK_FOR_BEOS_DISTRIBUTION,
"ENDING_BLOCK_FOR_BEOS_DISTRIBUTION" : config.ENDING_BLOCK_FOR_BEOS_DISTRIBUTION,
"DISTRIBUTION_PAYMENT_BLOCK_INTERVAL_FOR_BEOS_DISTRIBUTION" : config.DISTRIBUTION_PAYMENT_BLOCK_INTERVAL_FOR_BEOS_DISTRIBUTION,
"AMOUNT_OF_REWARD_BEOS" : config.AMOUNT_OF_REWARD_BEOS,
"STARTING_BLOCK_FOR_RAM_DISTRIBUTION" : config.STARTING_BLOCK_FOR_RAM_DISTRIBUTION,
"ENDING_BLOCK_FOR_RAM_DISTRIBUTION" : config.ENDING_BLOCK_FOR_RAM_DISTRIBUTION,
"DISTRIBUTION_PAYMENT_BLOCK_INTERVAL_FOR_RAM_DISTRIBUTION" : config.DISTRIBUTION_PAYMENT_BLOCK_INTERVAL_FOR_RAM_DISTRIBUTION,
"AMOUNT_OF_REWARD_RAM" : config.AMOUNT_OF_REWARD_RAM,
"STARTING_BLOCK_FOR_TRUSTEE_DISTRIBUTION" : config.STARTING_BLOCK_FOR_TRUSTEE_DISTRIBUTION,
"ENDING_BLOCK_FOR_TRUSTEE_DISTRIBUTION" : config.ENDING_BLOCK_FOR_TRUSTEE_DISTRIBUTION,
"DISTRIBUTION_PAYMENT_BLOCK_INTERVAL_FOR_TRUSTEE_DISTRIBUTION" : config.DISTRIBUTION_PAYMENT_BLOCK_INTERVAL_FOR_TRUSTEE_DISTRIBUTION,
"AMOUNT_OF_REWARD_TRUSTEE" : config.AMOUNT_OF_REWARD_TRUSTEE
}

eosio_init_src = config.BEOS_DIR + "/contracts/eosio.init/eosio.init.hpp.in"
eosio_init_dst = config.BEOS_DIR + "/contracts/eosio.init/eosio.init.hpp"
create_file_from_template(eosio_init_src, eosio_init_dst, eosio_init_opt)

def configure_config_ini():
ini_opt = {
"HTTP_SERVER_PORT" : "http://{0}:{1}".format(config.NODEOS_IP_ADDRESS, config.NODEOS_PORT),
"EOSIO_PUBLIC_KEY" : config.EOSIO_PUBLIC_KEY,
"SIGNATURE_PROVIDER" : "{0}=KEOSD:https://{1}:{2}/v1/wallet/sign_digest".format(config.EOSIO_PUBLIC_KEY, config.KEOSD_IP_ADDRESS, config.KEOSD_PORT),
"WALLET_DIR" : config.DEFAULT_WALLET_DIR
}
ini_src = os.path.dirname(os.path.abspath(__file__)) + "/resources/config.ini.in"
ini_dst = os.path.dirname(os.path.abspath(__file__)) + "/resources/config.ini"
create_file_from_template(ini_src, ini_dst, ini_opt)

def configure_genesis_json():
json_opt = {
"INITIAL_KEY" : "{0}".format(config.EOSIO_PUBLIC_KEY)
}
json_src = os.path.dirname(os.path.abspath(__file__)) + "/resources/genesis.json.in"
json_dst = os.path.dirname(os.path.abspath(__file__)) + "/resources/genesis.json"
create_file_from_template(json_src, json_dst, json_opt)

def initialize_beos():
import eosio
keosd = None
nodeos = None
try:
keosd = eosio.run_keosd(config.KEOSD_IP_ADDRESS, config.KEOSD_PORT, config.DEFAULT_WALLET_DIR, False, True)
eosio.create_wallet("http://{0}:{1}".format(config.KEOSD_IP_ADDRESS, config.KEOSD_PORT), False)
Expand Down Expand Up @@ -554,16 +515,10 @@ def make_beos_plugin_test():
if options.make_beos_plugin_test:
make_beos_plugin_test()

if options.create_genesis_and_config:
configure_config_ini()
configure_genesis_json()

if options.clear_init_data:
clear_initialization_data(config.START_NODE_INDEX, "eosio")

if options.initialize_beos:
configure_config_ini()
configure_genesis_json()
initialize_beos()

# close loggers
Expand Down
16 changes: 15 additions & 1 deletion cd-scripts/eosio.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,21 @@ def run_nodeos(node_index, name, public_key, use_https = False):
if os.path.exists(working_dir):
rmtree(working_dir)
os.makedirs(working_dir)
copy(config.GENESIS_JSON_FILE_SRC, working_dir + config.GENESIS_JSON_FILE)
logger.info("Copying genesis file from {0} to {1}".format(config.GENESIS_JSON_FILE_SRC, working_dir + config.GENESIS_JSON_FILE))
if os.path.exists(config.GENESIS_JSON_FILE_SRC):
copy(config.GENESIS_JSON_FILE_SRC, working_dir + config.GENESIS_JSON_FILE)
else:
msg = "File {0} does not exists.".format(config.GENESIS_JSON_FILE_SRC)
logger.error(msg)
raise EOSIOException(msg)

logger.info("Copying config file from {0} to {1}".format(config.BEOS_CONFIG_FILE_SRC, working_dir + config.BEOS_CONFIG_FILE))
if os.path.exists(config.BEOS_CONFIG_FILE_SRC):
copy(config.BEOS_CONFIG_FILE_SRC, working_dir + config.BEOS_CONFIG_FILE)
else:
msg = "File {0} does not exists.".format(config.BEOS_CONFIG_FILE_SRC)
logger.error(msg)
raise EOSIOException(msg)

https_opts = [
"--signature-provider", "{0}=KEOSD:http://{1}:{2}/v1/wallet/sign_digest".format(public_key, config.KEOSD_IP_ADDRESS, config.KEOSD_PORT),
Expand Down
Loading

0 comments on commit 16e4559

Please sign in to comment.