Skip to content

Commit

Permalink
Fix for issue #2 and #3. Fix for cmake issues with targets
Browse files Browse the repository at this point in the history
  • Loading branch information
Dariusz Kedzierski committed Nov 8, 2018
1 parent 8c537d1 commit a7350b9
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 429 deletions.
30 changes: 30 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -284,3 +284,33 @@ install(FILES libraries/fc/src/network/LICENSE.go DESTINATION ${CMAKE_INSTALL_FU

include(package)
include(doxygen)

set(PROXY_ASSET_NAME "PXBTS")
set(PROXY_ASSET_PRECISION 4)
set(PROXY_INITIAL_AMOUNT "100000.0000")
set(BEOS_SYMBOL_PRECISION 10000)
set(CORE_INITIAL_AMOUNT "100000.0000")
set(INIT_RAM "1000000")
set(STARTING_BLOCK_FOR_INITIAL_WITNESS_ELECTION "100")
set(STARTING_BLOCK_FOR_BEOS_DISTRIBUTION "days(7).to_seconds() * 2")
set(ENDING_BLOCK_FOR_BEOS_DISTRIBUTION "days(98).to_seconds() * 2")
set(DISTRIBUTION_PAYMENT_BLOCK_INTERVAL_FOR_BEOS_DISTRIBUTION "hours(1).to_seconds() * 2")
set(AMOUNT_OF_REWARD_BEOS "asset().symbol.precision()")
set(STARTING_BLOCK_FOR_RAM_DISTRIBUTION "days(7).to_seconds() * 2")
set(ENDING_BLOCK_FOR_RAM_DISTRIBUTION "days(280).to_seconds() * 2")
set(DISTRIBUTION_PAYMENT_BLOCK_INTERVAL_FOR_RAM_DISTRIBUTION "hours(1).to_seconds() * 2")
set(AMOUNT_OF_REWARD_RAM "5000000")
set(STARTING_BLOCK_FOR_TRUSTEE_DISTRIBUTION "days(7).to_seconds() * 2")
set(ENDING_BLOCK_FOR_TRUSTEE_DISTRIBUTION "days(98).to_seconds() * 2")
set(DISTRIBUTION_PAYMENT_BLOCK_INTERVAL_FOR_TRUSTEE_DISTRIBUTION "hours(1).to_seconds() * 2")
set(AMOUNT_OF_REWARD_TRUSTEE "asset().symbol.precision()")
set(STAKE_NET_QUANTITY "10000.0000")
set(STAKE_CPU_QUANTITY "10000.0000")
configure_file(${CMAKE_SOURCE_DIR}/contracts/eosio.init/eosio.init.hpp.in ${CMAKE_SOURCE_DIR}/contracts/eosio.init/eosio.init.hpp)

set(NODEOS_HTTP_SERVER_PORT "http://127.0.0.1:8888")
set(SIGNATURE_PROVIDER "${EOSIO_ROOT_KEY}=KEOSD:http://127.0.0.1:8900/v1/wallet/sign_digest")
set(WALLET_DIR "$ENV{HOME}/eosio-wallet")
configure_file(${CMAKE_SOURCE_DIR}/cd-scripts/resources/config.ini.in ${CMAKE_SOURCE_DIR}/cd-scripts/resources/config.ini @ONLY)

configure_file(${CMAKE_SOURCE_DIR}/cd-scripts/resources/genesis.json.in ${CMAKE_SOURCE_DIR}/cd-scripts/resources/genesis.json)
4 changes: 2 additions & 2 deletions cd-scripts/config-example.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,9 @@
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 = os.path.dirname(os.path.abspath(__file__)) + "/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 name
Expand Down
84 changes: 21 additions & 63 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 @@ -274,14 +274,32 @@ def build_eosio(c_compiler, cxx_compiler):
"-DWASM_ROOT={0}".format(config.WASM_INSTALL_DIR),
"-DCORE_SYMBOL_NAME={0}".format(config.CORE_SYMBOL_NAME),
"-DOPENSSL_ROOT_DIR={0}".format(config.OPENSSL_ROOT_DIR),
"-DBOOST_ROOT={0}".format(config.BOOST_INSTALL_DIR),
"-DBOOST_ROOT={0}".format(config.BOOST_INSTALL_PREFIX),
"-DBUILD_MONGO_DB_PLUGIN={0}".format(config.BUILD_MONGO_DB_PLUGIN),
"-DENABLE_COVERAGE_TESTING={0}".format(config.ENABLE_COVERAGE_TESTING),
"-DBUILD_DOXYGEN={0}".format(config.DOXYGEN),
"-DCMAKE_INSTALL_PREFIX={0}".format(config.EOSIO_INSTALL_PREFIX),
"-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)),
"-DWALLET_DIR={0}".format(config.DEFAULT_WALLET_DIR),
config.BEOS_DIR
]
logger.info("Running cmake with params {0}".format(" ".join(params)))
Expand All @@ -295,69 +313,11 @@ 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
try:
Expand Down Expand Up @@ -562,8 +522,6 @@ def make_beos_plugin_test():
clear_initialization_data(config.START_NODE_INDEX, "eosio")

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

# close loggers
Expand Down
1 change: 1 addition & 0 deletions cd-scripts/eosio.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ def run_nodeos(node_index, name, public_key, use_https = False):
rmtree(working_dir)
os.makedirs(working_dir)
copy(config.GENESIS_JSON_FILE_SRC, working_dir + config.GENESIS_JSON_FILE)
copy(config.BEOS_CONFIG_FILE_SRC, working_dir + config.BEOS_CONFIG_FILE)

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 a7350b9

Please sign in to comment.