Created
December 16, 2021 21:19
-
-
Save electrocucaracha/0a0d914fa00613001b9efca71565c64e to your computer and use it in GitHub Desktop.
Deploy Distributed Compliance Ledger locally
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# SPDX-license-identifier: Apache-2.0 | |
############################################################################## | |
# Copyright (c) | |
# All rights reserved. This program and the accompanying materials | |
# are made available under the terms of the Apache License, Version 2.0 | |
# which accompanies this distribution, and is available at | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
############################################################################## | |
set -o pipefail | |
set -o errexit | |
set -o nounset | |
if [[ "${DEBUG:-false}" == "true" ]]; then | |
set -o xtrace | |
fi | |
if [ ! -d /opt/dcl ]; then | |
sudo git clone --depth 1 -b v0.5.1 https://github.com/zigbee-alliance/distributed-compliance-ledger /opt/dcl | |
sudo chown -R "$USER" /opt/dcl | |
fi | |
newgrp docker <<'EONG' | |
for target in build install; do | |
make --directory=/opt/dcl "$target" | |
done | |
EONG |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# SPDX-license-identifier: Apache-2.0 | |
############################################################################## | |
# Copyright (c) | |
# All rights reserved. This program and the accompanying materials | |
# are made available under the terms of the Apache License, Version 2.0 | |
# which accompanies this distribution, and is available at | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
############################################################################## | |
set -o pipefail | |
set -o errexit | |
set -o nounset | |
if [[ "${DEBUG:-false}" == "true" ]]; then | |
set -o xtrace | |
export PKG_DEBUG=true | |
fi | |
export PKG_GOLANG_VERSION=1.13.15 | |
export PKG_COMMANDS_LIST=docker,docker-compose,git,make,jq | |
export PKG=go-lang | |
# Install dependencies | |
# NOTE: Shorten link -> https://github.com/electrocucaracha/pkg-mgr_scripts | |
curl -fsSL http://bit.ly/install_pkg | bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# SPDX-license-identifier: Apache-2.0 | |
############################################################################## | |
# Copyright (c) | |
# All rights reserved. This program and the accompanying materials | |
# are made available under the terms of the Apache License, Version 2.0 | |
# which accompanies this distribution, and is available at | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
############################################################################## | |
set -o pipefail | |
set -o errexit | |
set -o nounset | |
if [[ "${DEBUG:-false}" == "true" ]]; then | |
set -o xtrace | |
fi | |
export PATH=$PATH:/opt/dcl/build | |
function exit_trap { | |
set +o xtrace | |
sudo make --directory=/opt/dcl localnet_stop | |
sudo rm -rf ~/.dcl{cli,d} /opt/dcl/.localnet/ | |
} | |
for target in localnet_init localnet_start; do | |
sudo -H --preserve-env=PATH make --directory=/opt/dcl "$target" | |
done | |
trap exit_trap EXIT | |
# Wait for nodes | |
attempt_counter=0 | |
max_attempts=6 | |
until [[ "${started:-false}" == "true" ]]; do | |
started=true | |
for node in $(sudo docker ps --format "{{.Names}}"); do | |
if [[ "$(sudo docker logs "$node")" != *"starting ABCI with Tendermint"* ]]; then | |
started=false | |
break | |
fi | |
done | |
if [[ "${started:-false}" == "true" ]]; then | |
break | |
elif [ ${attempt_counter} -eq ${max_attempts} ];then | |
sudo docker-compose --file /opt/dcl/docker-compose.yml logs | |
echo "Max attempts reached" | |
exit 1 | |
fi | |
attempt_counter=$((attempt_counter+1)) | |
sleep $((attempt_counter*5)) | |
done | |
echo "$(dclcli query model all-models | jq -r '.result.total') total models" | |
echo "$(dclcli query model vendors | jq -r '.result.total') total vendors" | |
for node in $(sudo docker ps --format "{{.Names}}"); do | |
echo "$node has $(dclcli status "$node" | jq -r '.validator_info.voting_power') voting power" | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
############################################################################## | |
# Copyright (c) | |
# All rights reserved. This program and the accompanying materials | |
# are made available under the terms of the Apache License, Version 2.0 | |
# which accompanies this distribution, and is available at | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
############################################################################## | |
host = RbConfig::CONFIG['host_os'] | |
no_proxy = ENV['NO_PROXY'] || ENV['no_proxy'] || '127.0.0.1,localhost' | |
(1..254).each do |i| | |
no_proxy += ",10.0.2.#{i}" | |
end | |
case host | |
when /darwin/ | |
mem = `sysctl -n hw.memsize`.to_i / 1024 | |
when /linux/ | |
mem = `grep 'MemTotal' /proc/meminfo | sed -e 's/MemTotal://' -e 's/ kB//'`.to_i | |
when /mswin|mingw|cygwin/ | |
mem = `wmic computersystem Get TotalPhysicalMemory`.split[1].to_i / 1024 | |
end | |
Vagrant.configure("2") do |config| | |
config.vm.provider :libvirt | |
config.vm.provider :virtualbox | |
config.vm.box = "generic/ubuntu2004" | |
config.vm.box_version = "3.5.0" | |
config.vm.box_check_update = false | |
config.vm.synced_folder './', '/vagrant' | |
config.vm.provision 'shell', privileged: false, inline: <<-SHELL | |
set -o errexit | |
set -o pipefail | |
set -o xtrace | |
cd /vagrant/ | |
./install.sh | tee ~/install.log | |
source /etc/profile.d/path.sh | |
./configure.sh | tee ~/configure.log | |
./start.sh | tee ~/start.log | |
SHELL | |
%i[virtualbox libvirt].each do |provider| | |
config.vm.provider provider do |p| | |
p.cpus = ENV['CPUS'] || 2 | |
p.memory = ENV['MEMORY'] || mem / 1024 / 4 | |
end | |
end | |
config.vm.provider "virtualbox" do |v| | |
v.gui = false | |
v.customize ["modifyvm", :id, "--nictype1", "virtio", "--cableconnected1", "on"] | |
# https://bugs.launchpad.net/cloud-images/+bug/1829625/comments/2 | |
v.customize ["modifyvm", :id, "--uart1", "0x3F8", "4"] | |
v.customize ["modifyvm", :id, "--uartmode1", "file", File::NULL] | |
# Enable nested paging for memory management in hardware | |
v.customize ["modifyvm", :id, "--nestedpaging", "on"] | |
# Use large pages to reduce Translation Lookaside Buffers usage | |
v.customize ["modifyvm", :id, "--largepages", "on"] | |
# Use virtual processor identifiers to accelerate context switching | |
v.customize ["modifyvm", :id, "--vtxvpid", "on"] | |
end | |
config.vm.provider :libvirt do |v, override| | |
override.vm.synced_folder './', '/vagrant', type: 'nfs' | |
v.random_hostname = true | |
v.management_network_address = '10.0.2.0/24' | |
v.management_network_name = 'administration' | |
v.cpu_mode = 'host-passthrough' | |
end | |
if ENV['http_proxy'] != nil and ENV['https_proxy'] != nil | |
if Vagrant.has_plugin?('vagrant-proxyconf') | |
config.proxy.http = ENV['http_proxy'] || ENV['HTTP_PROXY'] || "" | |
config.proxy.https = ENV['https_proxy'] || ENV['HTTPS_PROXY'] || "" | |
config.proxy.no_proxy = no_proxy | |
config.proxy.enabled = { docker: false } | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment