Skip to content
This repository has been archived by the owner on Sep 13, 2022. It is now read-only.

Commit

Permalink
feat: add fabric devops scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
huwenchao committed Sep 22, 2019
1 parent ab0e102 commit fcdc25c
Show file tree
Hide file tree
Showing 7 changed files with 325 additions and 0 deletions.
50 changes: 50 additions & 0 deletions devtools/fabric/config-bft-1.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# crypto
privkey = "028590ad352d54387a9c8a0ecf7e180e68c4840c72f958fc5917657f506caa80"

# db config
data_path = "./devtools/chain/data"

[rpc]
address = "0.0.0.0:3030"
workers = 24
payload_size = 8388608

[network]
# private_key = "bcfa6d5fffa63edf3bd17b17422e416f9374d981322c4ccccf38de215e659b02"
bootstrap_addresses = []
listening_address = "0.0.0.0:1337"
max_connections = 40
send_buffer_size = 104857600
recv_buffer_size = 104857600

[txpool]
pool_size = 180000
until_block_limit = 10000
quota_limit = 1800000000

[consensus]
tx_limit = 60000
interval = 1000
verifier_list = [ "7899EE7319601cbC2684709e0eC3A4807bb0Fd74", "C5b874618a1E81C68bEb30A7A219Fee3f9839a01", "9Ad301Eb2A4938070ccda5e4b298C4f867812d6e", "64EC8878182F52af52611dDc575E267ABd012560" ]
# verifier_list = [ "7899EE7319601cbC2684709e0eC3A4807bb0Fd74", "C5b874618a1E81C68bEb30A7A219Fee3f9839a01", "9Ad301Eb2A4938070ccda5e4b298C4f867812d6e" ]
# verifier_list = [ "7899EE7319601cbC2684709e0eC3A4807bb0Fd74" ]
[synchronzer]
broadcast_status_interval = 180000

[rocksdb]
# 1024 * 8 (8 KB)
# block_size = 8192
# 1024 * 1024 * 8 (8 MiB)
# block_cache_size = 8388608
# 1024 * 1024 * 256 (256 MiB)
# max_bytes_for_level_base = 268435456
# 1024 * 1024 * 256 (256 MiB)
# max_bytes_for_level_multiplier = 268435456
# 1024 * 1024 * 64 (64 MiB)
write_buffer_size = 10737418240
# 1024 * 1024 * 64 (64 MiB)
# target_file_size_base = 67108864
# max_write_buffer_number = 4
# max_background_compactions = 2
# max_background_flushes = 2
# increase_parallelism = 3
49 changes: 49 additions & 0 deletions devtools/fabric/config-bft-2.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# crypto
privkey = "028590ad352d54387a9c8a0ecf7e180e68c4840c72f958fc5917657f506caa81"

# db config
data_path = "./devtools/chain/data"

[rpc]
address = "0.0.0.0:3030"
workers = 20
payload_size = 8388608

[network]
# private_key = "bcfa6d5fffa63edf3bd17b17422e416f9374d981322c4ccccf38de215e659b02"
bootstrap_addresses = ['192.168.0.35:1337']
listening_address = "0.0.0.0:1337"
max_connections = 40
send_buffer_size = 104857600
recv_buffer_size = 104857600

[txpool]
pool_size = 180000
until_block_limit = 10000
quota_limit = 1800000000

[consensus]
tx_limit = 60000
interval = 1000
verifier_list = [ "7899EE7319601cbC2684709e0eC3A4807bb0Fd74", "C5b874618a1E81C68bEb30A7A219Fee3f9839a01", "9Ad301Eb2A4938070ccda5e4b298C4f867812d6e", "64EC8878182F52af52611dDc575E267ABd012560" ]
# verifier_list = [ "7899EE7319601cbC2684709e0eC3A4807bb0Fd74", "C5b874618a1E81C68bEb30A7A219Fee3f9839a01", "9Ad301Eb2A4938070ccda5e4b298C4f867812d6e" ]
[synchronzer]
broadcast_status_interval = 180000

[rocksdb]
# 1024 * 8 (8 KB)
# block_size = 8192
# 1024 * 1024 * 8 (8 MiB)
# block_cache_size = 8388608
# 1024 * 1024 * 256 (256 MiB)
# max_bytes_for_level_base = 268435456
# 1024 * 1024 * 256 (256 MiB)
# max_bytes_for_level_multiplier = 268435456
# 1024 * 1024 * 64 (64 MiB)
# write_buffer_size = 67108864
# 1024 * 1024 * 64 (64 MiB)
write_buffer_size = 10737418240
# max_write_buffer_number = 4
# max_background_compactions = 2
# max_background_flushes = 2
# increase_parallelism = 3
50 changes: 50 additions & 0 deletions devtools/fabric/config-bft-3.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# crypto
privkey = "028590ad352d54387a9c8a0ecf7e180e68c4840c72f958fc5917657f506caa82"

# db config
data_path = "./devtools/chain/data"

[rpc]
address = "0.0.0.0:3030"
workers = 20
payload_size = 8388608

[network]
# private_key = "bcfa6d5fffa63edf3bd17b17422e416f9374d981322c4ccccf38de215e659b02"
bootstrap_addresses = ['192.168.0.35:1337']
listening_address = "0.0.0.0:1337"
max_connections = 40
send_buffer_size = 104857600
recv_buffer_size = 104857600

[txpool]
pool_size = 180000
until_block_limit = 10000
quota_limit = 1800000000

[consensus]
tx_limit = 60000
interval = 1000
verifier_list = [ "7899EE7319601cbC2684709e0eC3A4807bb0Fd74", "C5b874618a1E81C68bEb30A7A219Fee3f9839a01", "9Ad301Eb2A4938070ccda5e4b298C4f867812d6e", "64EC8878182F52af52611dDc575E267ABd012560" ]
# verifier_list = [ "7899EE7319601cbC2684709e0eC3A4807bb0Fd74", "C5b874618a1E81C68bEb30A7A219Fee3f9839a01", "9Ad301Eb2A4938070ccda5e4b298C4f867812d6e" ]
[synchronzer]
broadcast_status_interval = 180000

[rocksdb]
# 1024 * 8 (8 KB)
# block_size = 8192
# 1024 * 1024 * 8 (8 MiB)
# block_cache_size = 8388608
# 1024 * 1024 * 256 (256 MiB)
# max_bytes_for_level_base = 268435456
# 1024 * 1024 * 256 (256 MiB)
# max_bytes_for_level_multiplier = 268435456
# 1024 * 1024 * 64 (64 MiB)
# write_buffer_size = 67108864
write_buffer_size = 10737418240
# 1024 * 1024 * 64 (64 MiB)
# target_file_size_base = 67108864
# max_write_buffer_number = 4
# max_background_compactions = 2
# max_background_flushes = 2
# increase_parallelism = 3
50 changes: 50 additions & 0 deletions devtools/fabric/config-bft-4.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# crypto
privkey = "028590ad352d54387a9c8a0ecf7e180e68c4840c72f958fc5917657f506caa83"

# db config
data_path = "./devtools/chain/data"

[rpc]
address = "0.0.0.0:3030"
workers = 20
payload_size = 8388608

[network]
# private_key = "bcfa6d5fffa63edf3bd17b17422e416f9374d981322c4ccccf38de215e659b02"
bootstrap_addresses = ['192.168.0.35:1337']
listening_address = "0.0.0.0:1337"
max_connections = 40
send_buffer_size = 104857600
recv_buffer_size = 104857600

[txpool]
pool_size = 180000
until_block_limit = 10000
quota_limit = 1800000000

[consensus]
tx_limit = 60000
interval = 1000
verifier_list = [ "7899EE7319601cbC2684709e0eC3A4807bb0Fd74", "C5b874618a1E81C68bEb30A7A219Fee3f9839a01", "9Ad301Eb2A4938070ccda5e4b298C4f867812d6e", "64EC8878182F52af52611dDc575E267ABd012560" ]
# verifier_list = [ "7899EE7319601cbC2684709e0eC3A4807bb0Fd74", "C5b874618a1E81C68bEb30A7A219Fee3f9839a01", "9Ad301Eb2A4938070ccda5e4b298C4f867812d6e" ]
[synchronzer]
broadcast_status_interval = 180000

[rocksdb]
# 1024 * 8 (8 KB)
# block_size = 8192
# 1024 * 1024 * 8 (8 MiB)
# block_cache_size = 8388608
# 1024 * 1024 * 256 (256 MiB)
# max_bytes_for_level_base = 268435456
# 1024 * 1024 * 256 (256 MiB)
# max_bytes_for_level_multiplier = 268435456
# 1024 * 1024 * 64 (64 MiB)
# write_buffer_size = 67108864
write_buffer_size = 10737418240
# 1024 * 1024 * 64 (64 MiB)
# target_file_size_base = 67108864
# max_write_buffer_number = 4
# max_background_compactions = 2
# max_background_flushes = 2
# increase_parallelism = 3
86 changes: 86 additions & 0 deletions devtools/fabric/fabfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
from fabric.api import *
import time

hosts = [
"192.168.0.35",
"192.168.0.36",
"192.168.0.37",
"192.168.0.38",
]
env.roledefs.update({'hosts': hosts})


def update():
local('cd ~/muta && git pull && cargo build --release && git log -1 > version')


def deploy_diff():
for i, h in enumerate(hosts, 1):
local('scp ./config-bft-{}.toml {}:~/muta_chain/config.toml'.format(
i, h))


def deploy_common():
run('mkdir -p ~/muta_chain/devtools/chain/data')
run('rm -rf ~/muta_chain/muta')
put('~/muta/target/release/muta', '~/muta_chain')
put('~/muta/version', '~/muta_chain/version')
put('genesis.json', '~/muta_chain/devtools/chain')
run('chmod +x ~/muta_chain/muta')


def deploy():
execute(deploy_common, hosts=hosts)
deploy_diff()


@roles('hosts')
def service():
put('muta.service', '~/muta_chain')
run('sudo cp ~/muta_chain/muta.service /etc/systemd/system')
run('sudo systemctl daemon-reload')


@roles('hosts')
def clear():
run('sudo rm -rf ~/muta_chain/devtools/chain/data')


@roles('hosts')
def dellog():
run('sudo rm -rf ~/muta_chain/muta.log')
run('touch ~/muta_chain/muta.log')


@roles('hosts')
def start():
run('sudo systemctl start muta')


@roles('hosts')
def stop():
run('sudo systemctl stop muta')


@roles('hosts')
def restart():
run('sudo systemctl restart muta')


@roles('hosts')
def status():
run('sudo systemctl status muta')


def all():
execute(deploy)
execute(service, hosts=hosts)
execute(clear, hosts=hosts)
execute(dellog, hosts=hosts)
execute(restart, hosts=hosts)


@roles('hosts')
@parallel
def init_server():
run('sudo apt update && sudo apt install -y policykit-1 tmux')
30 changes: 30 additions & 0 deletions devtools/fabric/genesis.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"timestamp": 0,
"prevhash": "44915be5b6c20b0678cf05fcddbbaa832e25d7e6ac538784cd5c24de00d47472",
"state_alloc": [
{
"address": "7899EE7319601cbC2684709e0eC3A4807bb0Fd74",
"code": "",
"storage": {},
"balance": "400000000000000000"
},
{
"address": "C5b874618a1E81C68bEb30A7A219Fee3f9839a01",
"code": "",
"storage": {},
"balance": "400000000000000000"
},
{
"address": "9Ad301Eb2A4938070ccda5e4b298C4f867812d6e",
"code": "",
"storage": {},
"balance": "400000000000000000"
},
{
"address": "64EC8878182F52af52611dDc575E267ABd012560",
"code": "",
"storage": {},
"balance": "400000000000000000"
}
]
}
10 changes: 10 additions & 0 deletions devtools/fabric/muta.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[Unit]
Description=muta

[Service]
Type=simple
ExecStart=/bin/sh -c 'cd /home/cita/muta_chain && RUST_LOG=error ./muta -c ./config.toml init >>muta.log 2>&1'
Restart=always

[Install]
WantedBy=multi-user.target

0 comments on commit fcdc25c

Please sign in to comment.