Commit a4d77305 authored by Victor Khilin's avatar Victor Khilin
Browse files

Merge branch 'multi-nodes' into 'master'

Multi nodes

See merge request !1
parents e6bc0ad8 d8c8ae90
FROM anapsix/alpine-java:8_server-jre
#ARG node_version=1.0.2
ARG node_version=we1.0
COPY Dockerfile_content/accounts_template.conf /node/
COPY Dockerfile_content/generate.sh /node/
COPY ./generator.jar /node/generator.jar
COPY tmp/jcp-*.tar.gz /node/jcp/
RUN chmod +x /node/generate.sh && \
apk update && \
apk add wget gettext bash libxext libxrender libxtst libxi && \
mkdir -p /node/jcp && \
wget https://artifacts.vostokservices.com/repository/fileshare/node_build/jcp-2.0.39014.tar.gz -O /node/jcp/jcp-2.0.39014.tar.gz
# wget -q https://github.com/vostokplatform/Vostok-Releases/releases/download/${node_version}/generators-${node_version}.jar -O /node/generator.jar || true
wget -q https://artifacts.vostokservices.com/repository/fileshare/node_build/generators-${node_version}.jar -O /node/generator.jar
ENTRYPOINT "/node/generate.sh"
#!/bin/bash
tar xvfz /node/jcp/jcp* --directory /node/jcp
rm /node/jcp/jcp*.gz
cd /node/jcp
tar xfz /node/jcp/jcp* -C /node/jcp/ 2>/dev/null && rm -rf /node/jcp/jcp*gz
cd /node/jcp/jcp-2.0.40035/ || cd /node/jcp/
/bin/sh setup_console.sh /opt/jdk1.8.0_202 -force -en -install -jcp -jcryptop
cd /node
java ru.CryptoPro.JCP.Random.BioRandomConsole
......
First:
python3 -m pip install -r requirements.txt
Usage:
-c Seed letter A-Z
-w Waves chain (yes/no)
-a Count of keys to generate
-p Wallet password
--create-configmap [yes|no] (default: yes), generates configmap with config and wallet inside
--existing-genesis [yes|no] (default: no), use genesis from previous generation if genesis_backup.conf exists.
Example:
./launcher.py -c A -w no -a 3 -p <wallet password>
Usage:
-c Seed letter A-Z
-w Waves chain (yes/no)
-a Count of keys to generate
-p Wallet password
-e Evolved. N if it's old (not WE release) node. Y if it is (WE release 1.0 or higher).
--create-configmap [yes|no] (default: yes), generates configmap with config and wallet inside
--existing-genesis [yes|no] (default: no), use genesis from previous generation if genesis_backup.conf exists.
Example:
./launcher.py -c A -w no -a 3 -e Y -p <wallet password>
......@@ -16,6 +16,7 @@ import re
import yaml
import base64
import time
import fileinput
def randomString(stringLength=10):
letters = string.ascii_lowercase
......@@ -55,6 +56,7 @@ if __name__=="__main__":
parser.add_option("-p", "--password", type="string", dest="password", default=randomString(), help="wallet password(default: autogenerated)")
parser.add_option("--create-configmap", type="string", dest="kuber_config", default="yes", help="Generate kubernetes configmap for nodes (yes/no)")
parser.add_option("--existing-genesis", type="string", dest="use_existing_genesis", default="no", help="Use existing genesis from genesis_backup.conf if exist?")
parser.add_option("-e", "--node_evolved", type="string", dest="node_evolved", default="Y", help="Y is it is release-we1.0 or higher and N in another case")
options, args = parser.parse_args()
if os.path.exists('/usr/bin/docker'):
docker = '/usr/bin/docker'
......@@ -69,16 +71,17 @@ if __name__=="__main__":
options.use_existing_genesis = 'no'
jcp_name = 'jcp-2.0.39014.tar.gz'
jcp_name = {'N' : 'jcp-2.0.39014.tar.gz', 'Y' : 'jcp-2.0.40035.tar.gz'}
dst_jcp = './tmp/'
if not os.path.exists(dst_jcp):
os.mkdir(dst_jcp)
if os.path.exists(dst_jcp):
shutil.rmtree(dst_jcp)
os.mkdir(dst_jcp)
r = requests.get('https://artifacts.vostokservices.com/repository/fileshare/node_build/jcp-2.0.39014.tar.gz')
with open('{}/{}'.format(dst_jcp,jcp_name), 'wb') as f:
r_url = 'https://artifacts.vostokservices.com/repository/fileshare/node_build/' + jcp_name[options.node_evolved]
r = requests.get(r_url)
with open('{}/{}'.format(dst_jcp,jcp_name[options.node_evolved]), 'wb') as f:
f.write(r.content)
build_image_cmd = [docker, 'build', '-t', 'node_config_generator', '.']
subprocess.run(build_image_cmd)
......@@ -102,12 +105,17 @@ if __name__=="__main__":
shutil.rmtree(dst_jcp)
#generate config template
conf = ConfigFactory.parse_file('{}/node_config_templates/main.conf'.format(get_current_path()))
conf['vostok']['wallet']['password'] = options.password
conf['vostok']['blockchain']['custom']['address-scheme-character'] = options.chain_id
if options.node_evolved == 'N':
conf = ConfigFactory.parse_file('{}/node_config_templates/main.conf'.format(get_current_path()))
vostok = 'vostok'
if options.node_evolved == 'Y':
conf = ConfigFactory.parse_file('{}/node_config_templates/we_main.conf'.format(get_current_path()))
vostok = 'node'
conf[vostok]['waves-crypto'] = options.waves_crypto
conf[vostok]['wallet']['password'] = options.password
conf[vostok]['blockchain']['custom']['address-scheme-character'] = options.chain_id
initial_balance = conf['vostok']['blockchain']['custom']['genesis']['initial-balance']
initial_balance = conf[vostok]['blockchain']['custom']['genesis']['initial-balance']
initial_balance_remain = initial_balance
keys_remain = options.amount
......@@ -119,41 +127,65 @@ if __name__=="__main__":
keys_remain = keys_remain - 1
conf_transactions = ConfigFactory.from_dict(transactions)
conf['vostok']['blockchain']['custom']['genesis']['transactions'] = conf_transactions
conf[vostok]['blockchain']['custom']['genesis']['transactions'] = conf_transactions
network_participants = []
for key in keys:
network_participants.append({'public-key': key[1], 'roles': ['miner', 'permissioner', 'connection_manager']})
conf_network_participants = ConfigFactory.from_dict(network_participants)
conf['vostok']['blockchain']['custom']['genesis']['network-participants'] = conf_network_participants
conf[vostok]['blockchain']['custom']['genesis']['network-participants'] = conf_network_participants
conf['vostok']['blockchain']['custom']['genesis']['timestamp'] = int(time.time())*1000
conf['vostok']['blockchain']['custom']['genesis']['block-timestamp'] = (int(time.time())+20)*1000
conf[vostok]['blockchain']['custom']['genesis']['timestamp'] = int(time.time())*1000
conf[vostok]['blockchain']['custom']['genesis']['block-timestamp'] = (int(time.time())+20)*1000
f = open('{}/output/presign_genesis.conf'.format(get_current_path()), 'w')
f.write(HOCONConverter.convert(conf, 'hocon'))
f.close()
#replace '=' to ':' in signature and genesis-public-key-base-58
with open('output/presign_genesis.conf', 'r') as file:
filedata = file.read()
filedata = filedata.replace('signature = ""', 'signature: "qwertyuio"')
filedata = filedata.replace('genesis-public-key-base-58 = ""', 'genesis-public-key-base-58: "asdfghjk"')
filedata = filedata.replace('average-block-delay = ', 'average-block-delay: ')
filedata = filedata.replace('initial-base-target = ', 'initial-base-target: ')
filedata = filedata.replace('timestamp = ', 'timestamp: ')
filedata = filedata.replace('block-timestamp = ', 'block-timestamp: ')
filedata = filedata.replace('initial-balance = ', 'initial-balance: ')
filedata = filedata.replace('recipient = ', 'recipient: ')
filedata = filedata.replace('amount = ', 'amount: ')
filedata = filedata.replace('public-key = ', 'public-key: ')
filedata = filedata.replace('roles = ', 'roles: ')
with open('output/presign_genesis.conf', 'w') as file:
file.write(filedata)
file.close()
# with fileinput.FileInput('output/presign_genesis.conf', inplace=True, backup='.bak') as file:
# for line in file:
# print (line.replace('signature = ', 'signature: '), end='')
# print (line.replace('genesis-public-key-base-58 = ', 'genesis-public-key-base-58: '), end='')
#set genesis block
if options.use_existing_genesis == 'yes':
genesis_yaml = ConfigFactory.parse_file('{}/genesis_backup.conf'.format(get_current_path()))
signed_template_yaml = ConfigFactory.parse_file('{}/output/presign_genesis.conf'.format(get_current_path()))
signed_template_yaml['vostok']['blockchain']['custom']['genesis'] = genesis_yaml
signed_template_yaml[vostok]['blockchain']['custom']['genesis'] = genesis_yaml
else:
subprocess.run(['docker', 'run', '-it', '--rm', '-v', '{}/output:/output'.format(os.getcwd()), '-e', 'SIGN_GENESIS=1', '-e', 'NODE_CONFIG=/output/presign_genesis.conf', 'node_config_generator' ])
signed_template_yaml = ConfigFactory.parse_file('{}/output/presign_genesis.conf'.format(get_current_path()))
signed_template_yaml = ConfigFactory.parse_file('{}/output/presign_genesis.conf'.format(get_current_path()), )
f = open('{}/genesis_backup.conf'.format(get_current_path()), 'w')
f.write(HOCONConverter.convert(signed_template_yaml['vostok']['blockchain']['custom']['genesis'], 'hocon'))
f.write(HOCONConverter.convert(signed_template_yaml[vostok]['blockchain']['custom']['genesis'], 'hocon'))
f.close()
#generate config for nodes
for i in range(len(keys)):
signed_template_yaml['vostok']['owner-address'] = keys[i][0]
signed_template_yaml['vostok']['miner']['quorum'] = len(keys)-1
signed_template_yaml['vostok']['docker-engine']['node-rest-api'] = "https://${EXTERNAL_ENDPOINT}/node-" + str(i)
signed_template_yaml['vostok']['privacy']['storage']['url'] = "jdbc:postgresql://node-" + str(i) + "-${PG_HOST_NODE}:5432/dcp_privacy_node_" + str(i) + "?user=user_dcp_privacy_node_" + str(i) + "&password=${PG_PASS_NODE}&sslmode=require"
signed_template_yaml[vostok]['owner-address'] = keys[i][0]
signed_template_yaml[vostok]['miner']['quorum'] = len(keys)-1
signed_template_yaml[vostok]['docker-engine']['node-rest-api'] = "https://${EXTERNAL_ENDPOINT}/node-" + str(i)
signed_template_yaml[vostok]['privacy']['storage']['url'] = "jdbc:postgresql://node-" + str(i) + "-${PG_HOST_NODE}:5432/dcp_privacy_node_" + str(i) + "?user=user_dcp_privacy_node_" + str(i) + "&password=${PG_PASS_NODE}&sslmode=require"
f = open("./output/node-{}.conf".format(i), "w")
f.write(HOCONConverter.convert(signed_template_yaml, 'hocon'))
f.close()
......
node {
wallet {
file = "wallet"
password = "svupkey"
}
owner-address = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
privacy.storage.url = "jdbc:postgresql://example.com:5432/database_name?user=username&password=password&sslmode=require"
}
node {
network.enable-blacklisting = no
synchronization.synchronization-timeout = 3m
waves-crypto = no
logging-level = DEBUG
directory = "/node/data/"
data-directory = "/node/data/data"
ntp.fatal-timeout = "1 minute"
ntp.server = "0.ru.pool.ntp.org"
blockchain {
fees {
genesis = 0
genesis-permit = 0
issue = 0
transfer = 0
reissue = 0
burn = 5000000
exchange = 500000
lease = 1000000
lease-cancel = 1000000
create-alias = 0
mass-transfer = 5000000
data = 0
set-script = 50000000
sponsor-fee = 100000000
set-asset-script = 100000000
permit = 0
create-contract = 0
call-contract = 0
executed-contract = 0
disable-contract = 1000000
update-contract = 0
register-node = 0
create-policy = 0
update-policy = 0
policy-data-hash = 0
additional {
mass-transfer = 1000000
data = 1000000
}
}
type = CUSTOM
consensus {
type = poa
round-duration = 10s
sync-duration = 1s
ban-duration-blocks = 20
warnings-for-ban = 5
max-bans-percentage = 30
}
custom {
address-scheme-character = ""
functionality {
feature-check-blocks-period = 15000
blocks-for-feature-activation = 10000
pre-activated-features = {
2 = 0
3 = 0
4 = 0
5 = 0
6 = 0
7 = 0
9 = 0
10 = 0
}
}
genesis {
average-block-delay: 40s
initial-base-target: 10000000000
timestamp: 1565783396000
block-timestamp: 1565783396000
initial-balance: 100000000000000000
genesis-public-key-base-58: ""
signature: ""
transactions = [
]
network-participants = [
]
}
}
}
transaction-rebroadcaster {
enable = no
delay = 0s
types = []
}
miner {
quorum = 1
interval-after-last-block-then-generation-is-allowed = 35d
micro-block-interval = 2s
min-micro-block-age = 3s
max-transactions-in-micro-block = 500
minimal-block-generation-offset = 200ms
}
privacy {
# Node privacy settings (allow all nodes to join or not)
allow-all-nodes = false
# DB connection config
storage {
enabled = true
driver = "org.postgresql.Driver"
profile = "slick.jdbc.PostgresProfile$"
connectionPool = HikariCP
connectionTimeout = 5000
connectionTestQuery = "SELECT 1"
queueSize = 10000
numThreads = 10
schema = "public"
migration-dir = "db/migration"
}
}
docker-engine {
docker-host = "http://proxy-to-dockerhost:8081"
enable = yes
node-rest-api = "https://${EXTERNAL_ENDPOINT}/node-0"
allow-net-access = yes
check-image-hash = no
execution-limits {
timeout = 10s
memory = 512
memory-swap = 512
}
}
network {
# Network address
bind-address = "0.0.0.0"
# Port number
port = 6864
# Node name to send during handshake. Comment this string out to set random node name.
# String with IP address and port to send as external address during handshake. Could be set automatically if uPnP is enabled.
declared-address = "0.0.0.0:6864"
known-peers = ["node-0:6864", "node-1:6864", "node-2:6864"]
}
rest-api {
enable = yes
bind-address = "0.0.0.0"
port = 6862
auth {
type: "api-key"
api-key-hash = DACAEAAK1MosP6Jjjhff2TVNDkBBszgqssD32GfU4iBf
privacy-api-key-hash = DACAEAAK1MosP6Jjjhff2TVNDkBBszgqssD32GfU4iBf #svupkey
}
}
}
include "we_local_template.conf"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment