From 668386ac40352d1015e8b0dbbd34a73620f1e9f3 Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Fri, 10 Jul 2020 19:06:51 +0200 Subject: [PATCH 01/28] Build VM box using Packer Added Packer template to build a Vagrant box provisioned with all tools needed to install and run local-setup environment. --- .gitignore | 5 ++- deployments/packer/provision.sh | 75 ++++++++++++++++++++++++++++++++ deployments/packer/template.json | 17 ++++++++ deployments/vagrant/Vagrantfile | 4 ++ 4 files changed, 100 insertions(+), 1 deletion(-) create mode 100644 deployments/packer/provision.sh create mode 100644 deployments/packer/template.json create mode 100644 deployments/vagrant/Vagrantfile diff --git a/.gitignore b/.gitignore index 1f55638..bf91386 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,7 @@ .idea /ethereum/data/geth/ /storage/ -node_modules \ No newline at end of file +node_modules +local-setup-box +.vagrant +*.log \ No newline at end of file diff --git a/deployments/packer/provision.sh b/deployments/packer/provision.sh new file mode 100644 index 0000000..a2901f2 --- /dev/null +++ b/deployments/packer/provision.sh @@ -0,0 +1,75 @@ +#!/bin/bash + +# Install common tools. +echo "Installing common tools..." +sudo apt-get update +sudo apt-get install unzip +sudo apt-get install jq +echo "Common tools have been installed successfully!" + +# Install Node.js. +echo "Installing Node.js..." +curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash +export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")" +[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" +nvm install 14.3.0 +nvm install 11.15.0 +nvm alias default 11.15.0 +nvm use default +echo "Node.js $(node -v) and NPM $(npm -v) have been installed successfully!" + +# Install Golang. +echo "Installing Go..." +GOLANG_PACKAGE=go1.13.4.linux-amd64.tar.gz +curl -O https://storage.googleapis.com/golang/$GOLANG_PACKAGE +tar -xvf $GOLANG_PACKAGE +sudo chown -R root:root ./go +sudo mv go /usr/local +echo "export GOPATH=$HOME/go" >> ~/.profile +echo "export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin" >> ~/.profile +source ~/.profile +echo "$(go version) has been installed successfully!" + +# Install go-ethereum. +echo "Installing go-ethereum..." +GETH_PACKAGE=geth-alltools-linux-amd64-1.9.9-01744997.tar.gz +curl -O https://gethstore.blob.core.windows.net/builds/$GETH_PACKAGE +tar -xvf $GETH_PACKAGE +mkdir ./go-ethereum && tar -xzf $GETH_PACKAGE -C ./go-ethereum --strip-components=1 +sudo chown -R root:root ./go-ethereum +sudo mv ./go-ethereum/* /usr/local/bin +geth version +echo "go-ethereum has been installed successfully!" + +# Install Solidity. +echo "Installing Solidity..." +SOLC_VERSION=v0.5.17 +wget https://github.com/ethereum/solidity/releases/download/$SOLC_VERSION/solc-static-linux +chmod 755 solc-static-linux +sudo mv solc-static-linux /usr/local/bin +sudo ln -s -f /usr/local/bin/solc-static-linux /usr/local/bin/solc +solc --version +echo "Solidity has been installed successfully!" + +# Install Truffle. +echo "Installing Truffle..." +npm install -g truffle@5.0.30 +truffle version +echo "Truffle has been installed successfully!" + +# Install Protobuf. +echo "Installing Protobuf..." +PROTOC_VERSION=3.11.4 +PROTOC_PACKAGE=protoc-$PROTOC_VERSION-linux-x86_64.zip +wget https://github.com/protocolbuffers/protobuf/releases/download/v$PROTOC_VERSION/$PROTOC_PACKAGE +mkdir ./protoc && unzip $PROTOC_PACKAGE -d ./protoc +chmod 755 -R ./protoc +sudo mv protoc/bin/protoc /usr/local/bin +sudo mv protoc/include/* /usr/local/include +go get -u github.com/gogo/protobuf/protoc-gen-gogoslick +protoc --version +command -v protoc-gen-gogoslick +echo "Protobuf has been installed successfully!" + +# TODO: Install pyenv and pipenv. +# TODO: Install Docker and Docker Compose. \ No newline at end of file diff --git a/deployments/packer/template.json b/deployments/packer/template.json new file mode 100644 index 0000000..236b070 --- /dev/null +++ b/deployments/packer/template.json @@ -0,0 +1,17 @@ +{ + "builders": [ + { + "type": "vagrant", + "source_path": "ubuntu/xenial64", + "provider": "virtualbox", + "communicator": "ssh", + "output_dir": "local-setup-box" + } + ], + "provisioners": [ + { + "type": "shell", + "script": "provision.sh" + } + ] +} \ No newline at end of file diff --git a/deployments/vagrant/Vagrantfile b/deployments/vagrant/Vagrantfile new file mode 100644 index 0000000..22197b2 --- /dev/null +++ b/deployments/vagrant/Vagrantfile @@ -0,0 +1,4 @@ +Vagrant.configure("2") do |config| + config.vm.box = "LocalSetupBox" + config.vm.synced_folder ".", "/vagrant", disabled: true +end \ No newline at end of file From 4766ac3ef19467c03375de8143bbe2dc790a4412 Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Mon, 13 Jul 2020 16:02:16 +0200 Subject: [PATCH 02/28] Remaining Packer provisioning scripts --- deployments/packer/provision.sh | 75 ------------------- .../packer/provisioning/install-commons.sh | 16 ++++ .../provisioning/install-docker-compose.sh | 14 ++++ .../packer/provisioning/install-docker.sh | 26 +++++++ .../packer/provisioning/install-geth.sh | 18 +++++ deployments/packer/provisioning/install-go.sh | 21 ++++++ .../packer/provisioning/install-nodejs.sh | 20 +++++ .../packer/provisioning/install-pipenv.sh | 18 +++++ .../packer/provisioning/install-protobuf.sh | 22 ++++++ .../packer/provisioning/install-pyenv.sh | 34 +++++++++ .../packer/provisioning/install-solidity.sh | 17 +++++ .../packer/provisioning/install-truffle.sh | 11 +++ deployments/packer/template.json | 42 ++++++++++- deployments/vagrant/Vagrantfile | 2 +- 14 files changed, 259 insertions(+), 77 deletions(-) delete mode 100644 deployments/packer/provision.sh create mode 100755 deployments/packer/provisioning/install-commons.sh create mode 100755 deployments/packer/provisioning/install-docker-compose.sh create mode 100755 deployments/packer/provisioning/install-docker.sh create mode 100755 deployments/packer/provisioning/install-geth.sh create mode 100755 deployments/packer/provisioning/install-go.sh create mode 100755 deployments/packer/provisioning/install-nodejs.sh create mode 100755 deployments/packer/provisioning/install-pipenv.sh create mode 100755 deployments/packer/provisioning/install-protobuf.sh create mode 100755 deployments/packer/provisioning/install-pyenv.sh create mode 100755 deployments/packer/provisioning/install-solidity.sh create mode 100755 deployments/packer/provisioning/install-truffle.sh diff --git a/deployments/packer/provision.sh b/deployments/packer/provision.sh deleted file mode 100644 index a2901f2..0000000 --- a/deployments/packer/provision.sh +++ /dev/null @@ -1,75 +0,0 @@ -#!/bin/bash - -# Install common tools. -echo "Installing common tools..." -sudo apt-get update -sudo apt-get install unzip -sudo apt-get install jq -echo "Common tools have been installed successfully!" - -# Install Node.js. -echo "Installing Node.js..." -curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash -export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")" -[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" -nvm install 14.3.0 -nvm install 11.15.0 -nvm alias default 11.15.0 -nvm use default -echo "Node.js $(node -v) and NPM $(npm -v) have been installed successfully!" - -# Install Golang. -echo "Installing Go..." -GOLANG_PACKAGE=go1.13.4.linux-amd64.tar.gz -curl -O https://storage.googleapis.com/golang/$GOLANG_PACKAGE -tar -xvf $GOLANG_PACKAGE -sudo chown -R root:root ./go -sudo mv go /usr/local -echo "export GOPATH=$HOME/go" >> ~/.profile -echo "export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin" >> ~/.profile -source ~/.profile -echo "$(go version) has been installed successfully!" - -# Install go-ethereum. -echo "Installing go-ethereum..." -GETH_PACKAGE=geth-alltools-linux-amd64-1.9.9-01744997.tar.gz -curl -O https://gethstore.blob.core.windows.net/builds/$GETH_PACKAGE -tar -xvf $GETH_PACKAGE -mkdir ./go-ethereum && tar -xzf $GETH_PACKAGE -C ./go-ethereum --strip-components=1 -sudo chown -R root:root ./go-ethereum -sudo mv ./go-ethereum/* /usr/local/bin -geth version -echo "go-ethereum has been installed successfully!" - -# Install Solidity. -echo "Installing Solidity..." -SOLC_VERSION=v0.5.17 -wget https://github.com/ethereum/solidity/releases/download/$SOLC_VERSION/solc-static-linux -chmod 755 solc-static-linux -sudo mv solc-static-linux /usr/local/bin -sudo ln -s -f /usr/local/bin/solc-static-linux /usr/local/bin/solc -solc --version -echo "Solidity has been installed successfully!" - -# Install Truffle. -echo "Installing Truffle..." -npm install -g truffle@5.0.30 -truffle version -echo "Truffle has been installed successfully!" - -# Install Protobuf. -echo "Installing Protobuf..." -PROTOC_VERSION=3.11.4 -PROTOC_PACKAGE=protoc-$PROTOC_VERSION-linux-x86_64.zip -wget https://github.com/protocolbuffers/protobuf/releases/download/v$PROTOC_VERSION/$PROTOC_PACKAGE -mkdir ./protoc && unzip $PROTOC_PACKAGE -d ./protoc -chmod 755 -R ./protoc -sudo mv protoc/bin/protoc /usr/local/bin -sudo mv protoc/include/* /usr/local/include -go get -u github.com/gogo/protobuf/protoc-gen-gogoslick -protoc --version -command -v protoc-gen-gogoslick -echo "Protobuf has been installed successfully!" - -# TODO: Install pyenv and pipenv. -# TODO: Install Docker and Docker Compose. \ No newline at end of file diff --git a/deployments/packer/provisioning/install-commons.sh b/deployments/packer/provisioning/install-commons.sh new file mode 100755 index 0000000..5907422 --- /dev/null +++ b/deployments/packer/provisioning/install-commons.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +set -e + +echo "Installing common tools..." + +sudo apt-get update + +sudo apt-get install -y \ + unzip \ + jq + +if ! [ -x "$(command -v unzip)" ]; then echo "unzip installation failed"; exit 1; fi +if ! [ -x "$(command -v jq)" ]; then echo "jq installation failed"; exit 1; fi + +echo "Common tools have been installed successfully!" \ No newline at end of file diff --git a/deployments/packer/provisioning/install-docker-compose.sh b/deployments/packer/provisioning/install-docker-compose.sh new file mode 100755 index 0000000..c892980 --- /dev/null +++ b/deployments/packer/provisioning/install-docker-compose.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +set -e + +echo "Installing Docker Compose..." + +sudo curl -L "https://github.com/docker/compose/releases/download/1.26.2/docker-compose-$(uname -s)-$(uname -m)" \ + -o /usr/local/bin/docker-compose + +sudo chmod +x /usr/local/bin/docker-compose + +if ! [ -x "$(command -v docker-compose)" ]; then echo "Docker compose installation failed"; exit 1; fi + +echo "Docker Compose has been installed successfully!" \ No newline at end of file diff --git a/deployments/packer/provisioning/install-docker.sh b/deployments/packer/provisioning/install-docker.sh new file mode 100755 index 0000000..6678092 --- /dev/null +++ b/deployments/packer/provisioning/install-docker.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +set -e + +echo "Installing Docker..." + +sudo apt-get install -y \ + apt-transport-https \ + ca-certificates \ + curl \ + gnupg-agent \ + software-properties-common + +curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - + +sudo add-apt-repository \ + "deb [arch=amd64] https://download.docker.com/linux/ubuntu \ + $(lsb_release -cs) \ + stable" + +sudo apt-get update +sudo apt-get install -y docker-ce docker-ce-cli containerd.io + +if ! [ -x "$(command -v docker)" ]; then echo "Docker installation failed"; exit 1; fi + +echo "Docker has been installed successfully!" \ No newline at end of file diff --git a/deployments/packer/provisioning/install-geth.sh b/deployments/packer/provisioning/install-geth.sh new file mode 100755 index 0000000..5364858 --- /dev/null +++ b/deployments/packer/provisioning/install-geth.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +set -e + +echo "Installing go-ethereum..." + +GETH_PACKAGE=geth-alltools-linux-amd64-1.9.9-01744997.tar.gz + +curl -O https://gethstore.blob.core.windows.net/builds/$GETH_PACKAGE + +tar -xvf $GETH_PACKAGE +mkdir ./go-ethereum && tar -xzf $GETH_PACKAGE -C ./go-ethereum --strip-components=1 +sudo chown -R root:root ./go-ethereum +sudo mv ./go-ethereum/* /usr/local/bin + +if ! [ -x "$(command -v geth)" ]; then echo "go-ethereum installation failed"; exit 1; fi + +echo "go-ethereum has been installed successfully!" \ No newline at end of file diff --git a/deployments/packer/provisioning/install-go.sh b/deployments/packer/provisioning/install-go.sh new file mode 100755 index 0000000..4b7fc42 --- /dev/null +++ b/deployments/packer/provisioning/install-go.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +set -e + +echo "Installing Go..." + +GOLANG_PACKAGE=go1.13.4.linux-amd64.tar.gz + +curl -O https://storage.googleapis.com/golang/$GOLANG_PACKAGE + +tar -xvf $GOLANG_PACKAGE +sudo chown -R root:root ./go +sudo mv go /usr/local + +echo 'GOPATH="$HOME/go"' >> ~/.profile +echo 'PATH="$PATH:/usr/local/go/bin:$GOPATH/bin"' >> ~/.profile +source ~/.profile + +if ! [ -x "$(command -v go)" ]; then echo "Go installation failed"; exit 1; fi + +echo "Go has been installed successfully!" \ No newline at end of file diff --git a/deployments/packer/provisioning/install-nodejs.sh b/deployments/packer/provisioning/install-nodejs.sh new file mode 100755 index 0000000..1e6a663 --- /dev/null +++ b/deployments/packer/provisioning/install-nodejs.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +set -e + +echo "Installing Node.js and NPM..." + +curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash + +export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")" +[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" + +nvm install 14.3.0 +nvm install 11.15.0 +nvm alias default 11.15.0 +nvm use default + +if ! [ -x "$(command -v node)" ]; then echo "Node installation failed"; exit 1; fi +if ! [ -x "$(command -v npm)" ]; then echo "NPM installation failed"; exit 1; fi + +echo "Node.js and NPM have been installed successfully!" \ No newline at end of file diff --git a/deployments/packer/provisioning/install-pipenv.sh b/deployments/packer/provisioning/install-pipenv.sh new file mode 100755 index 0000000..13bcb51 --- /dev/null +++ b/deployments/packer/provisioning/install-pipenv.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +set -e + +echo "Installing pipenv..." + +if ! [ -x "$(command -v pyenv)" ]; then echo "pyenv is not installed"; exit 1; fi + +pyenv install 3.7.7 +pyenv global 3.7.7 + +if ! [ -x "$(command -v pip)" ]; then echo "pip is not installed"; exit 1; fi + +pip install pipenv + +if ! [ -x "$(command -v pipenv)" ]; then echo "pipenv installation failed"; exit 1; fi + +echo "pipenv has been installed successfully!" \ No newline at end of file diff --git a/deployments/packer/provisioning/install-protobuf.sh b/deployments/packer/provisioning/install-protobuf.sh new file mode 100755 index 0000000..85421ca --- /dev/null +++ b/deployments/packer/provisioning/install-protobuf.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +set -e + +echo "Installing Protobuf..." + +PROTOC_VERSION=3.11.4 +PROTOC_PACKAGE=protoc-$PROTOC_VERSION-linux-x86_64.zip + +wget https://github.com/protocolbuffers/protobuf/releases/download/v$PROTOC_VERSION/$PROTOC_PACKAGE + +mkdir ./protoc && unzip $PROTOC_PACKAGE -d ./protoc +chmod 755 -R ./protoc +sudo mv protoc/bin/protoc /usr/local/bin +sudo mv protoc/include/* /usr/local/include + +go get -u github.com/gogo/protobuf/protoc-gen-gogoslick + +if ! [ -x "$(command -v protoc)" ]; then echo "protoc installation failed"; exit 1; fi +if ! [ -x "$(command -v protoc-gen-gogoslick)" ]; then echo "protoc-gen-gogoslick installation failed"; exit 1; fi + +echo "Protobuf has been installed successfully!" \ No newline at end of file diff --git a/deployments/packer/provisioning/install-pyenv.sh b/deployments/packer/provisioning/install-pyenv.sh new file mode 100755 index 0000000..979d026 --- /dev/null +++ b/deployments/packer/provisioning/install-pyenv.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +set -e + +echo "Installing pyenv..." + +sudo apt-get install -y \ + build-essential \ + libssl-dev \ + zlib1g-dev \ + libbz2-dev \ + libreadline-dev \ + libsqlite3-dev \ + wget \ + curl \ + llvm \ + libncurses5-dev \ + libncursesw5-dev \ + xz-utils \ + tk-dev \ + libffi-dev \ + liblzma-dev \ + python-openssl \ + git + +curl https://pyenv.run | bash + +echo 'export PATH="~/.pyenv/bin:$PATH"' >> ~/.bashrc +echo 'eval "$(pyenv init -)"' >> ~/.bashrc +echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc + +exec "$SHELL" + +echo "pyenv has been installed successfully!" \ No newline at end of file diff --git a/deployments/packer/provisioning/install-solidity.sh b/deployments/packer/provisioning/install-solidity.sh new file mode 100755 index 0000000..d8b0b48 --- /dev/null +++ b/deployments/packer/provisioning/install-solidity.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +set -e + +echo "Installing Solidity..." + +SOLC_VERSION=v0.5.17 + +wget https://github.com/ethereum/solidity/releases/download/$SOLC_VERSION/solc-static-linux + +chmod 755 solc-static-linux +sudo mv solc-static-linux /usr/local/bin +sudo ln -s -f /usr/local/bin/solc-static-linux /usr/local/bin/solc + +if ! [ -x "$(command -v solc)" ]; then echo "Solidity installation failed"; exit 1; fi + +echo "Solidity has been installed successfully!" \ No newline at end of file diff --git a/deployments/packer/provisioning/install-truffle.sh b/deployments/packer/provisioning/install-truffle.sh new file mode 100755 index 0000000..1595ce0 --- /dev/null +++ b/deployments/packer/provisioning/install-truffle.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +set -e + +echo "Installing Truffle..." + +npm install -g truffle@5.0.30 + +if ! [ -x "$(command -v truffle)" ]; then echo "Truffle installation failed"; exit 1; fi + +echo "Truffle has been installed successfully!" \ No newline at end of file diff --git a/deployments/packer/template.json b/deployments/packer/template.json index 236b070..e2c9fd6 100644 --- a/deployments/packer/template.json +++ b/deployments/packer/template.json @@ -11,7 +11,47 @@ "provisioners": [ { "type": "shell", - "script": "provision.sh" + "script": "./provisioning/install-commons.sh" + }, + { + "type": "shell", + "script": "./provisioning/install-nodejs.sh" + }, + { + "type": "shell", + "script": "./provisioning/install-go.sh" + }, + { + "type": "shell", + "script": "./provisioning/install-geth.sh" + }, + { + "type": "shell", + "script": "./provisioning/install-solidity.sh" + }, + { + "type": "shell", + "script": "./provisioning/install-truffle.sh" + }, + { + "type": "shell", + "script": "./provisioning/install-protobuf.sh" + }, + { + "type": "shell", + "script": "./provisioning/install-pyenv.sh" + }, + { + "type": "shell", + "script": "./provisioning/install-pipenv.sh" + }, + { + "type": "shell", + "script": "./provisioning/install-docker.sh" + }, + { + "type": "shell", + "script": "./provisioning/install-docker-compose.sh" } ] } \ No newline at end of file diff --git a/deployments/vagrant/Vagrantfile b/deployments/vagrant/Vagrantfile index 22197b2..ff498c4 100644 --- a/deployments/vagrant/Vagrantfile +++ b/deployments/vagrant/Vagrantfile @@ -1,4 +1,4 @@ Vagrant.configure("2") do |config| - config.vm.box = "LocalSetupBox" + config.vm.box = "local-setup" config.vm.synced_folder ".", "/vagrant", disabled: true end \ No newline at end of file From fed4466cbee1a8783683af8e88221ec604da056d Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Mon, 13 Jul 2020 16:20:33 +0200 Subject: [PATCH 03/28] Add wrapper script for provisioning --- deployments/packer/provisioning/install.sh | 25 +++++++++++++ deployments/packer/template.json | 42 +--------------------- 2 files changed, 26 insertions(+), 41 deletions(-) create mode 100644 deployments/packer/provisioning/install.sh diff --git a/deployments/packer/provisioning/install.sh b/deployments/packer/provisioning/install.sh new file mode 100644 index 0000000..f5175eb --- /dev/null +++ b/deployments/packer/provisioning/install.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +set -e + +./install-commons.sh + +./install-nodejs.sh + +./install-go.sh + +./install-geth.sh + +./install-solidity.sh + +./install-truffle.sh + +./install-protobuf.sh + +./install-pyenv.sh + +./install-pipenv.sh + +./install-docker.sh + +./install-docker-compose.sh \ No newline at end of file diff --git a/deployments/packer/template.json b/deployments/packer/template.json index e2c9fd6..abcf317 100644 --- a/deployments/packer/template.json +++ b/deployments/packer/template.json @@ -11,47 +11,7 @@ "provisioners": [ { "type": "shell", - "script": "./provisioning/install-commons.sh" - }, - { - "type": "shell", - "script": "./provisioning/install-nodejs.sh" - }, - { - "type": "shell", - "script": "./provisioning/install-go.sh" - }, - { - "type": "shell", - "script": "./provisioning/install-geth.sh" - }, - { - "type": "shell", - "script": "./provisioning/install-solidity.sh" - }, - { - "type": "shell", - "script": "./provisioning/install-truffle.sh" - }, - { - "type": "shell", - "script": "./provisioning/install-protobuf.sh" - }, - { - "type": "shell", - "script": "./provisioning/install-pyenv.sh" - }, - { - "type": "shell", - "script": "./provisioning/install-pipenv.sh" - }, - { - "type": "shell", - "script": "./provisioning/install-docker.sh" - }, - { - "type": "shell", - "script": "./provisioning/install-docker-compose.sh" + "script": "./provisioning/install.sh" } ] } \ No newline at end of file From 1d56c9a0f010b3455e8a1feb7421f1951a98e820 Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Mon, 13 Jul 2020 19:42:32 +0200 Subject: [PATCH 04/28] Revert "Add wrapper script for provisioning" This reverts commit fed4466c --- deployments/packer/provisioning/install.sh | 25 ------------- deployments/packer/template.json | 42 +++++++++++++++++++++- 2 files changed, 41 insertions(+), 26 deletions(-) delete mode 100644 deployments/packer/provisioning/install.sh diff --git a/deployments/packer/provisioning/install.sh b/deployments/packer/provisioning/install.sh deleted file mode 100644 index f5175eb..0000000 --- a/deployments/packer/provisioning/install.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash - -set -e - -./install-commons.sh - -./install-nodejs.sh - -./install-go.sh - -./install-geth.sh - -./install-solidity.sh - -./install-truffle.sh - -./install-protobuf.sh - -./install-pyenv.sh - -./install-pipenv.sh - -./install-docker.sh - -./install-docker-compose.sh \ No newline at end of file diff --git a/deployments/packer/template.json b/deployments/packer/template.json index abcf317..e2c9fd6 100644 --- a/deployments/packer/template.json +++ b/deployments/packer/template.json @@ -11,7 +11,47 @@ "provisioners": [ { "type": "shell", - "script": "./provisioning/install.sh" + "script": "./provisioning/install-commons.sh" + }, + { + "type": "shell", + "script": "./provisioning/install-nodejs.sh" + }, + { + "type": "shell", + "script": "./provisioning/install-go.sh" + }, + { + "type": "shell", + "script": "./provisioning/install-geth.sh" + }, + { + "type": "shell", + "script": "./provisioning/install-solidity.sh" + }, + { + "type": "shell", + "script": "./provisioning/install-truffle.sh" + }, + { + "type": "shell", + "script": "./provisioning/install-protobuf.sh" + }, + { + "type": "shell", + "script": "./provisioning/install-pyenv.sh" + }, + { + "type": "shell", + "script": "./provisioning/install-pipenv.sh" + }, + { + "type": "shell", + "script": "./provisioning/install-docker.sh" + }, + { + "type": "shell", + "script": "./provisioning/install-docker-compose.sh" } ] } \ No newline at end of file From 308435edea89dc05ceea4279441c7d2e41a635cc Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Mon, 13 Jul 2020 20:25:08 +0200 Subject: [PATCH 05/28] Invoke bash with -l option --- .../packer/provisioning/install-nodejs.sh | 5 +- deployments/packer/template.json | 55 +++++-------------- 2 files changed, 17 insertions(+), 43 deletions(-) diff --git a/deployments/packer/provisioning/install-nodejs.sh b/deployments/packer/provisioning/install-nodejs.sh index 1e6a663..351b199 100755 --- a/deployments/packer/provisioning/install-nodejs.sh +++ b/deployments/packer/provisioning/install-nodejs.sh @@ -6,8 +6,9 @@ echo "Installing Node.js and NPM..." curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash -export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")" -[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" +echo 'export NVM_DIR="$HOME/.nvm"' >> ~/.profile +echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"' >> ~/.profile +source ~/.profile nvm install 14.3.0 nvm install 11.15.0 diff --git a/deployments/packer/template.json b/deployments/packer/template.json index e2c9fd6..572dbcf 100644 --- a/deployments/packer/template.json +++ b/deployments/packer/template.json @@ -11,47 +11,20 @@ "provisioners": [ { "type": "shell", - "script": "./provisioning/install-commons.sh" - }, - { - "type": "shell", - "script": "./provisioning/install-nodejs.sh" - }, - { - "type": "shell", - "script": "./provisioning/install-go.sh" - }, - { - "type": "shell", - "script": "./provisioning/install-geth.sh" - }, - { - "type": "shell", - "script": "./provisioning/install-solidity.sh" - }, - { - "type": "shell", - "script": "./provisioning/install-truffle.sh" - }, - { - "type": "shell", - "script": "./provisioning/install-protobuf.sh" - }, - { - "type": "shell", - "script": "./provisioning/install-pyenv.sh" - }, - { - "type": "shell", - "script": "./provisioning/install-pipenv.sh" - }, - { - "type": "shell", - "script": "./provisioning/install-docker.sh" - }, - { - "type": "shell", - "script": "./provisioning/install-docker-compose.sh" + "execute_command": "chmod +x {{ .Path }}; {{ .Vars }} bash -l {{ .Path }}", + "scripts": [ + "./provisioning/install-commons.sh", + "./provisioning/install-nodejs.sh", + "./provisioning/install-go.sh", + "./provisioning/install-geth.sh", + "./provisioning/install-solidity.sh", + "./provisioning/install-truffle.sh", + "./provisioning/install-protobuf.sh", + "./provisioning/install-pyenv.sh", + "./provisioning/install-pipenv.sh", + "./provisioning/install-docker.sh", + "./provisioning/install-docker-compose.sh" + ] } ] } \ No newline at end of file From b80ecfe7fc29101e059366151905932aaa2a427b Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Tue, 14 Jul 2020 09:48:45 +0200 Subject: [PATCH 06/28] Don't install python and testnet relay Testnet relay (and python) is not necessary if local btcd and ElectrumX are used. --- README.adoc | 4 +-- .../packer/provisioning/install-pipenv.sh | 18 ---------- .../packer/provisioning/install-pyenv.sh | 34 ------------------- deployments/packer/template.json | 2 -- install.sh | 3 -- 5 files changed, 2 insertions(+), 59 deletions(-) delete mode 100755 deployments/packer/provisioning/install-pipenv.sh delete mode 100755 deployments/packer/provisioning/install-pyenv.sh diff --git a/README.adoc b/README.adoc index d848bf6..2051dc3 100644 --- a/README.adoc +++ b/README.adoc @@ -15,9 +15,9 @@ If you are not on macOS or you don't have Homebrew, you need to install: Regardless you use `macos-setup.sh` or not, you should also install: -- https://github.com/pyenv/pyenv[pyenv], at least 1.2.18 -- https://github.com/pypa/pipenv[pipenv], at least 2018.11.26 - https://docs.docker.com/get-docker[Docker] & https://docs.docker.com/compose/install/[Docker Compose] +- https://github.com/pyenv/pyenv[pyenv], at least 1.2.18 (optional - only if testnet relay is used) +- https://github.com/pypa/pipenv[pipenv], at least 2018.11.26 (optional - only if testnet relay is used) == Node.js version notice diff --git a/deployments/packer/provisioning/install-pipenv.sh b/deployments/packer/provisioning/install-pipenv.sh deleted file mode 100755 index 13bcb51..0000000 --- a/deployments/packer/provisioning/install-pipenv.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash - -set -e - -echo "Installing pipenv..." - -if ! [ -x "$(command -v pyenv)" ]; then echo "pyenv is not installed"; exit 1; fi - -pyenv install 3.7.7 -pyenv global 3.7.7 - -if ! [ -x "$(command -v pip)" ]; then echo "pip is not installed"; exit 1; fi - -pip install pipenv - -if ! [ -x "$(command -v pipenv)" ]; then echo "pipenv installation failed"; exit 1; fi - -echo "pipenv has been installed successfully!" \ No newline at end of file diff --git a/deployments/packer/provisioning/install-pyenv.sh b/deployments/packer/provisioning/install-pyenv.sh deleted file mode 100755 index 979d026..0000000 --- a/deployments/packer/provisioning/install-pyenv.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash - -set -e - -echo "Installing pyenv..." - -sudo apt-get install -y \ - build-essential \ - libssl-dev \ - zlib1g-dev \ - libbz2-dev \ - libreadline-dev \ - libsqlite3-dev \ - wget \ - curl \ - llvm \ - libncurses5-dev \ - libncursesw5-dev \ - xz-utils \ - tk-dev \ - libffi-dev \ - liblzma-dev \ - python-openssl \ - git - -curl https://pyenv.run | bash - -echo 'export PATH="~/.pyenv/bin:$PATH"' >> ~/.bashrc -echo 'eval "$(pyenv init -)"' >> ~/.bashrc -echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc - -exec "$SHELL" - -echo "pyenv has been installed successfully!" \ No newline at end of file diff --git a/deployments/packer/template.json b/deployments/packer/template.json index 572dbcf..b371e41 100644 --- a/deployments/packer/template.json +++ b/deployments/packer/template.json @@ -20,8 +20,6 @@ "./provisioning/install-solidity.sh", "./provisioning/install-truffle.sh", "./provisioning/install-protobuf.sh", - "./provisioning/install-pyenv.sh", - "./provisioning/install-pipenv.sh", "./provisioning/install-docker.sh", "./provisioning/install-docker-compose.sh" ] diff --git a/install.sh b/install.sh index 7dd458d..8b2f295 100755 --- a/install.sh +++ b/install.sh @@ -19,6 +19,3 @@ set -e # Install tBTC dApp. ./install-tbtc-dapp.sh - -# Install relay-maintainer. -./install-testnet-relay.sh From 3aec7b0dfe6763b20e8c25151d7f56a9f7a37999 Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Thu, 16 Jul 2020 12:42:04 +0200 Subject: [PATCH 07/28] Vagrant provisioning scripts Added several provisioning scripts for Vagrant which run auxilliary software (geth, btc core, electrum) and install local-setup. --- .../packer/{template.json => packerfile.json} | 0 .../packer/provisioning/install-docker.sh | 2 + deployments/vagrant/Vagrantfile | 19 ++++++++ .../vagrant/provisioning/clone-repository.sh | 12 +++++ .../vagrant/provisioning/initialize-geth.sh | 11 +++++ .../vagrant/provisioning/run-bitcoin.sh | 11 +++++ deployments/vagrant/provisioning/run-geth.sh | 11 +++++ .../vagrant/provisioning/run-install.sh | 47 +++++++++++++++++++ .../vagrant/provisioning/update-repository.sh | 12 +++++ 9 files changed, 125 insertions(+) rename deployments/packer/{template.json => packerfile.json} (100%) create mode 100644 deployments/vagrant/provisioning/clone-repository.sh create mode 100644 deployments/vagrant/provisioning/initialize-geth.sh create mode 100644 deployments/vagrant/provisioning/run-bitcoin.sh create mode 100644 deployments/vagrant/provisioning/run-geth.sh create mode 100644 deployments/vagrant/provisioning/run-install.sh create mode 100644 deployments/vagrant/provisioning/update-repository.sh diff --git a/deployments/packer/template.json b/deployments/packer/packerfile.json similarity index 100% rename from deployments/packer/template.json rename to deployments/packer/packerfile.json diff --git a/deployments/packer/provisioning/install-docker.sh b/deployments/packer/provisioning/install-docker.sh index 6678092..54a6ecc 100755 --- a/deployments/packer/provisioning/install-docker.sh +++ b/deployments/packer/provisioning/install-docker.sh @@ -23,4 +23,6 @@ sudo apt-get install -y docker-ce docker-ce-cli containerd.io if ! [ -x "$(command -v docker)" ]; then echo "Docker installation failed"; exit 1; fi +sudo gpasswd -a $USER docker + echo "Docker has been installed successfully!" \ No newline at end of file diff --git a/deployments/vagrant/Vagrantfile b/deployments/vagrant/Vagrantfile index ff498c4..10bf4c1 100644 --- a/deployments/vagrant/Vagrantfile +++ b/deployments/vagrant/Vagrantfile @@ -1,4 +1,23 @@ +def total_cpus + require 'etc' + Etc.nprocessors +end + Vagrant.configure("2") do |config| config.vm.box = "local-setup" config.vm.synced_folder ".", "/vagrant", disabled: true + + config.vm.provider "virtualbox" do |v| + v.name = "local-setup-vm" + v.memory = "4096" + v.cpus = total_cpus - 2 + v.customize ["modifyvm", :id, "--vram", "256"] + end + + config.vm.provision "shell", path: "./provisioning/clone-repository.sh" + config.vm.provision "shell", path: "./provisioning/update-repository.sh" + config.vm.provision "shell", path: "./provisioning/initialize-geth.sh" + config.vm.provision "shell", path: "./provisioning/run-geth.sh", run: "always" + config.vm.provision "shell", path: "./provisioning/run-bitcoin.sh", run: "always" + config.vm.provision "shell", path: "./provisioning/run-install.sh", run: "always" end \ No newline at end of file diff --git a/deployments/vagrant/provisioning/clone-repository.sh b/deployments/vagrant/provisioning/clone-repository.sh new file mode 100644 index 0000000..f181bb5 --- /dev/null +++ b/deployments/vagrant/provisioning/clone-repository.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +set -e + +echo "Cloning repository..." + +if [ -d local-setup ]; then rm -Rf local-setup; fi + +git clone https://github.com/keep-network/local-setup.git + +echo "Repository has been cloned successfully!" + diff --git a/deployments/vagrant/provisioning/initialize-geth.sh b/deployments/vagrant/provisioning/initialize-geth.sh new file mode 100644 index 0000000..b48a059 --- /dev/null +++ b/deployments/vagrant/provisioning/initialize-geth.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +set -e + +echo "Initializing Geth..." + +cd local-setup + +./initialize-geth.sh + +echo "Geth has been initialized successfully!" \ No newline at end of file diff --git a/deployments/vagrant/provisioning/run-bitcoin.sh b/deployments/vagrant/provisioning/run-bitcoin.sh new file mode 100644 index 0000000..e19a91b --- /dev/null +++ b/deployments/vagrant/provisioning/run-bitcoin.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +set -e + +echo "Running Bitcoin Core and ElectrumX as transient system service..." + +cd local-setup + +systemd-run --unit=bitcoin -p WorkingDirectory=/home/vagrant/local-setup ./run-bitcoin.sh + +echo "Bitcoin Core and ElectrumX have been run as transient system service successfully!" \ No newline at end of file diff --git a/deployments/vagrant/provisioning/run-geth.sh b/deployments/vagrant/provisioning/run-geth.sh new file mode 100644 index 0000000..2974dba --- /dev/null +++ b/deployments/vagrant/provisioning/run-geth.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +set -e + +echo "Running Geth as transient system service..." + +cd local-setup + +systemd-run --unit=geth -p WorkingDirectory=/home/vagrant/local-setup ./run-geth.sh + +echo "Geth has been run as transient system service successfully!" \ No newline at end of file diff --git a/deployments/vagrant/provisioning/run-install.sh b/deployments/vagrant/provisioning/run-install.sh new file mode 100644 index 0000000..0975a26 --- /dev/null +++ b/deployments/vagrant/provisioning/run-install.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +set -e + +cd local-setup + +while true; do + echo "Checking Geth state..." + + ETH_BLOCK=$(curl -s -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":67}' http://localhost:8545 | jq -r '.result') + + if [ -z "$ETH_BLOCK" ] || [ "$ETH_BLOCK" == "0x0" ]; then + echo "Geth still not initialized - waiting..." + sleep 30 + continue; + fi + + echo "Geth initialized!" + + break +done + +while true; do + echo "Checking Bitcoin Core state..." + + BTC_BLOCK=$(curl -s --user user:password --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "getblockcount", "params": []}' -H 'content-type: text/plain;' http://127.0.0.1:18332 | jq -r '.result') + + if [ -z "$BTC_BLOCK" ] || [ "$BTC_BLOCK" == "0" ]; then + echo "Bitcoin Core still not initialized - waiting..." + sleep 30 + continue; + fi + + echo "Bitcoin Core initialized!" + + break +done + +echo "Running install script..." + +./install.sh + +echo "Install script executed successfully!" + + + + diff --git a/deployments/vagrant/provisioning/update-repository.sh b/deployments/vagrant/provisioning/update-repository.sh new file mode 100644 index 0000000..7fb44be --- /dev/null +++ b/deployments/vagrant/provisioning/update-repository.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +set -e + +echo "Updating repository..." + +cd local-setup + +#TODO: Temporary. Final solution should update all submodules to the recent master. +git checkout local-setup-vm + +echo "Repository has been updated successfully!" \ No newline at end of file From 8d0aa63e706e91cf92079ac29ce96106d0524a9f Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Thu, 16 Jul 2020 13:30:44 +0200 Subject: [PATCH 08/28] Make sed invocations cross-platform --- install-keep-core.sh | 5 +++-- install-keep-ecdsa.sh | 20 ++++++++++++++------ install-testnet-relay.sh | 5 +++-- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/install-keep-core.sh b/install-keep-core.sh index 422f80c..c740376 100755 --- a/install-keep-core.sh +++ b/install-keep-core.sh @@ -19,8 +19,9 @@ cp -R configs/keep-core/. keep-core/configs/ cd keep-core/configs # Fill absolute paths in config file with actual working directory. -sed -i .OLD 's:WORKDIR:'$WORKDIR':' config.local.1.toml -rm *.OLD +TMP_FILE=$(mktemp /tmp/config.local.1.toml.XXXXXXXXXX) +sed 's:WORKDIR:'$WORKDIR':' config.local.1.toml > $TMP_FILE +mv $TMP_FILE config.local.1.toml printf "${LOG_START}Creating storage directories...${LOG_END}" diff --git a/install-keep-ecdsa.sh b/install-keep-ecdsa.sh index 2cb62d2..5e4de46 100755 --- a/install-keep-ecdsa.sh +++ b/install-keep-ecdsa.sh @@ -19,10 +19,17 @@ cp -R configs/keep-ecdsa/. keep-ecdsa/configs/ cd keep-ecdsa/configs # Fill absolute paths in config files with actual working directory. -sed -i .OLD 's:WORKDIR:'$WORKDIR':' config.local.1.toml -sed -i .OLD 's:WORKDIR:'$WORKDIR':' config.local.2.toml -sed -i .OLD 's:WORKDIR:'$WORKDIR':' config.local.3.toml -rm *.OLD +TMP_FILE=$(mktemp /tmp/config.local.1.toml.XXXXXXXXXX) +sed 's:WORKDIR:'$WORKDIR':' config.local.1.toml > $TMP_FILE +mv $TMP_FILE config.local.1.toml + +TMP_FILE=$(mktemp /tmp/config.local.2.toml.XXXXXXXXXX) +sed 's:WORKDIR:'$WORKDIR':' config.local.2.toml > $TMP_FILE +mv $TMP_FILE config.local.2.toml + +TMP_FILE=$(mktemp /tmp/config.local.3.toml.XXXXXXXXXX) +sed 's:WORKDIR:'$WORKDIR':' config.local.3.toml > $TMP_FILE +mv $TMP_FILE config.local.3.toml printf "${LOG_START}Creating storage directories...${LOG_END}" @@ -37,8 +44,9 @@ printf "${LOG_START}Updating keep-ecdsa configuration...${LOG_END}" # Set correct Geth WS port. cd keep-ecdsa/solidity -sed -i "" 's/\port\:.*/\port\: '8546,'/g' truffle.js -sed -i "" 's/\websockets\:.*/\websockets\: 'true,'/g' truffle.js +TMP_FILE=$(mktemp /tmp/truffle.js.XXXXXXXXXX) +sed -e 's/\port\:.*/\port\: '8546,'/g;s/\websockets\:.*/\websockets\: 'true,'/g' truffle.js > $TMP_FILE +mv $TMP_FILE truffle.js cd .. printf "${LOG_START}Running install script...${LOG_END}" diff --git a/install-testnet-relay.sh b/install-testnet-relay.sh index 2598167..e039589 100755 --- a/install-testnet-relay.sh +++ b/install-testnet-relay.sh @@ -32,8 +32,9 @@ cp -R configs/relays/. relays/maintainer/maintainer/config/ cd "$WORKDIR/relays/maintainer/maintainer/config" # Fill SUMMA_RELAY_CONTRACT env in config file with their actual value. -sed -i .OLD 's:RELAYCONTRACT:'$TESTNET_RELAY_CONTRACT_ADDRESS':' .my_env_file.env -rm .my_env_file.env.OLD +TMP_FILE=$(mktemp /tmp/.my_env_file.env.XXXXXXXXXX) +sed 's:RELAYCONTRACT:'$TESTNET_RELAY_CONTRACT_ADDRESS':' .my_env_file.env > $TMP_FILE +mv $TMP_FILE .my_env_file.env cd $WORKDIR From d1712584938399956682bf19b21806330f74db51 Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Thu, 16 Jul 2020 15:48:59 +0200 Subject: [PATCH 09/28] Make install.sh pass --- .../packer/provisioning/install-commons.sh | 4 +++- deployments/vagrant/Vagrantfile | 18 ++++++++++++------ .../vagrant/provisioning/run-bitcoin.sh | 2 +- deployments/vagrant/provisioning/run-geth.sh | 2 +- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/deployments/packer/provisioning/install-commons.sh b/deployments/packer/provisioning/install-commons.sh index 5907422..f4c1294 100755 --- a/deployments/packer/provisioning/install-commons.sh +++ b/deployments/packer/provisioning/install-commons.sh @@ -8,7 +8,9 @@ sudo apt-get update sudo apt-get install -y \ unzip \ - jq + jq \ + python \ + build-essential if ! [ -x "$(command -v unzip)" ]; then echo "unzip installation failed"; exit 1; fi if ! [ -x "$(command -v jq)" ]; then echo "jq installation failed"; exit 1; fi diff --git a/deployments/vagrant/Vagrantfile b/deployments/vagrant/Vagrantfile index 10bf4c1..ddb6285 100644 --- a/deployments/vagrant/Vagrantfile +++ b/deployments/vagrant/Vagrantfile @@ -3,9 +3,15 @@ def total_cpus Etc.nprocessors end +# Install vagrant-disksize to allow resizing the vagrant box disk. +unless Vagrant.has_plugin?("vagrant-disksize") + raise Vagrant::Errors::VagrantError.new, "vagrant-disksize plugin is missing. Please install it using 'vagrant plugin install vagrant-disksize' and rerun the command" +end + Vagrant.configure("2") do |config| config.vm.box = "local-setup" config.vm.synced_folder ".", "/vagrant", disabled: true + config.disksize.size = '15GB' config.vm.provider "virtualbox" do |v| v.name = "local-setup-vm" @@ -14,10 +20,10 @@ Vagrant.configure("2") do |config| v.customize ["modifyvm", :id, "--vram", "256"] end - config.vm.provision "shell", path: "./provisioning/clone-repository.sh" - config.vm.provision "shell", path: "./provisioning/update-repository.sh" - config.vm.provision "shell", path: "./provisioning/initialize-geth.sh" - config.vm.provision "shell", path: "./provisioning/run-geth.sh", run: "always" - config.vm.provision "shell", path: "./provisioning/run-bitcoin.sh", run: "always" - config.vm.provision "shell", path: "./provisioning/run-install.sh", run: "always" + config.vm.provision "shell", path: "./provisioning/clone-repository.sh", privileged: false + config.vm.provision "shell", path: "./provisioning/update-repository.sh", privileged: false + config.vm.provision "shell", path: "./provisioning/initialize-geth.sh", privileged: false + config.vm.provision "shell", path: "./provisioning/run-geth.sh", privileged: false, run: "always" + config.vm.provision "shell", path: "./provisioning/run-bitcoin.sh", privileged: false, run: "always" + config.vm.provision "shell", path: "./provisioning/run-install.sh", privileged: false end \ No newline at end of file diff --git a/deployments/vagrant/provisioning/run-bitcoin.sh b/deployments/vagrant/provisioning/run-bitcoin.sh index e19a91b..d8a019e 100644 --- a/deployments/vagrant/provisioning/run-bitcoin.sh +++ b/deployments/vagrant/provisioning/run-bitcoin.sh @@ -6,6 +6,6 @@ echo "Running Bitcoin Core and ElectrumX as transient system service..." cd local-setup -systemd-run --unit=bitcoin -p WorkingDirectory=/home/vagrant/local-setup ./run-bitcoin.sh +sudo systemd-run --unit=bitcoin -p WorkingDirectory=/home/vagrant/local-setup ./run-bitcoin.sh echo "Bitcoin Core and ElectrumX have been run as transient system service successfully!" \ No newline at end of file diff --git a/deployments/vagrant/provisioning/run-geth.sh b/deployments/vagrant/provisioning/run-geth.sh index 2974dba..63f6156 100644 --- a/deployments/vagrant/provisioning/run-geth.sh +++ b/deployments/vagrant/provisioning/run-geth.sh @@ -6,6 +6,6 @@ echo "Running Geth as transient system service..." cd local-setup -systemd-run --unit=geth -p WorkingDirectory=/home/vagrant/local-setup ./run-geth.sh +sudo systemd-run --unit=geth -p WorkingDirectory=/home/vagrant/local-setup ./run-geth.sh echo "Geth has been run as transient system service successfully!" \ No newline at end of file From 5c361a1d01befd2c76a4d31b3f429f855afd5ee5 Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Thu, 16 Jul 2020 17:17:50 +0200 Subject: [PATCH 10/28] Clients provisioning script --- deployments/vagrant/Vagrantfile | 1 + deployments/vagrant/provisioning/run-clients.sh | 15 +++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 deployments/vagrant/provisioning/run-clients.sh diff --git a/deployments/vagrant/Vagrantfile b/deployments/vagrant/Vagrantfile index ddb6285..1d9ad85 100644 --- a/deployments/vagrant/Vagrantfile +++ b/deployments/vagrant/Vagrantfile @@ -26,4 +26,5 @@ Vagrant.configure("2") do |config| config.vm.provision "shell", path: "./provisioning/run-geth.sh", privileged: false, run: "always" config.vm.provision "shell", path: "./provisioning/run-bitcoin.sh", privileged: false, run: "always" config.vm.provision "shell", path: "./provisioning/run-install.sh", privileged: false + config.vm.provision "shell", path: "./provisioning/run-clients.sh", privileged: false, run: "always" end \ No newline at end of file diff --git a/deployments/vagrant/provisioning/run-clients.sh b/deployments/vagrant/provisioning/run-clients.sh new file mode 100644 index 0000000..9ed4064 --- /dev/null +++ b/deployments/vagrant/provisioning/run-clients.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +set -e + +echo "Running Core and ECDSA clients..." + +cd local-setup + +sudo systemd-run --unit=keep-core-1 -p WorkingDirectory=/home/vagrant/local-setup ./run-core-1.sh + +sudo systemd-run --unit=keep-ecdsa-1 -p WorkingDirectory=/home/vagrant/local-setup ./run-ecdsa-1.sh +sudo systemd-run --unit=keep-ecdsa-2 -p WorkingDirectory=/home/vagrant/local-setup ./run-ecdsa-2.sh +sudo systemd-run --unit=keep-ecdsa-3 -p WorkingDirectory=/home/vagrant/local-setup ./run-ecdsa-3.sh + +echo "Core and ECDSA have been run successfully!" \ No newline at end of file From cf2035d9e813b57dd01b210b68718d6fbf48d69a Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Fri, 17 Jul 2020 10:58:36 +0200 Subject: [PATCH 11/28] Add Docker builder --- deployments/packer/packerfile.json | 36 +++++++++++++++++-- .../packer/provisioning/install-commons.sh | 3 ++ .../packer/provisioning/install-docker.sh | 2 -- deployments/vagrant/Vagrantfile | 2 +- 4 files changed, 38 insertions(+), 5 deletions(-) diff --git a/deployments/packer/packerfile.json b/deployments/packer/packerfile.json index b371e41..ce94663 100644 --- a/deployments/packer/packerfile.json +++ b/deployments/packer/packerfile.json @@ -5,10 +5,24 @@ "source_path": "ubuntu/xenial64", "provider": "virtualbox", "communicator": "ssh", - "output_dir": "local-setup-box" + "output_dir": "local-setup-base" + }, + { + "type": "docker", + "image": "ubuntu:xenial", + "commit": true, + "changes": [ + "ENTRYPOINT /bin/bash" + ] } ], "provisioners": [ + { + "type": "shell", + "execute_command": "chmod +x {{ .Path }}; {{ .Vars }} bash -l {{ .Path }}", + "inline": ["apt-get update && apt-get -y install sudo"], + "only": ["docker"] + }, { "type": "shell", "execute_command": "chmod +x {{ .Path }}; {{ .Vars }} bash -l {{ .Path }}", @@ -18,11 +32,29 @@ "./provisioning/install-go.sh", "./provisioning/install-geth.sh", "./provisioning/install-solidity.sh", - "./provisioning/install-truffle.sh", "./provisioning/install-protobuf.sh", "./provisioning/install-docker.sh", "./provisioning/install-docker-compose.sh" ] + }, + { + "type": "shell", + "execute_command": "chmod +x {{ .Path }}; {{ .Vars }} bash -l {{ .Path }}", + "inline": ["npm -g config set user root"], + "only": ["docker"] + }, + { + "type": "shell", + "execute_command": "chmod +x {{ .Path }}; {{ .Vars }} bash -l {{ .Path }}", + "script": "./provisioning/install-truffle.sh" } + ], + "post-processors": [ + [ + { + "type": "docker-tag", + "repository": "local-setup-base" + } + ] ] } \ No newline at end of file diff --git a/deployments/packer/provisioning/install-commons.sh b/deployments/packer/provisioning/install-commons.sh index f4c1294..fca6f35 100755 --- a/deployments/packer/provisioning/install-commons.sh +++ b/deployments/packer/provisioning/install-commons.sh @@ -7,6 +7,9 @@ echo "Installing common tools..." sudo apt-get update sudo apt-get install -y \ + curl \ + wget \ + git \ unzip \ jq \ python \ diff --git a/deployments/packer/provisioning/install-docker.sh b/deployments/packer/provisioning/install-docker.sh index 54a6ecc..6678092 100755 --- a/deployments/packer/provisioning/install-docker.sh +++ b/deployments/packer/provisioning/install-docker.sh @@ -23,6 +23,4 @@ sudo apt-get install -y docker-ce docker-ce-cli containerd.io if ! [ -x "$(command -v docker)" ]; then echo "Docker installation failed"; exit 1; fi -sudo gpasswd -a $USER docker - echo "Docker has been installed successfully!" \ No newline at end of file diff --git a/deployments/vagrant/Vagrantfile b/deployments/vagrant/Vagrantfile index 1d9ad85..ad60c49 100644 --- a/deployments/vagrant/Vagrantfile +++ b/deployments/vagrant/Vagrantfile @@ -9,7 +9,7 @@ unless Vagrant.has_plugin?("vagrant-disksize") end Vagrant.configure("2") do |config| - config.vm.box = "local-setup" + config.vm.box = "local-setup-base" config.vm.synced_folder ".", "/vagrant", disabled: true config.disksize.size = '15GB' From 4b0ea3b10b93808ca62bad494c2b13bf2231b5b1 Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Fri, 17 Jul 2020 11:18:02 +0200 Subject: [PATCH 12/28] Update gitignore --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index bf91386..f9c3e67 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,6 @@ /ethereum/data/geth/ /storage/ node_modules -local-setup-box +local-setup-base .vagrant *.log \ No newline at end of file From 9a9110b041cc251c2943bc1e01f47cbc81b1acf0 Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Fri, 17 Jul 2020 15:16:34 +0200 Subject: [PATCH 13/28] Improve Docker builder --- deployments/packer/packerfile.json | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/deployments/packer/packerfile.json b/deployments/packer/packerfile.json index ce94663..4656bed 100644 --- a/deployments/packer/packerfile.json +++ b/deployments/packer/packerfile.json @@ -11,8 +11,17 @@ "type": "docker", "image": "ubuntu:xenial", "commit": true, + "run_command": [ + "-d", "-i", "-t", + "--name=local-setup-base-builder", + "-w=/root", + "--entrypoint=/bin/bash", + "--", + "{{.Image}}" + ], "changes": [ - "ENTRYPOINT /bin/bash" + "WORKDIR /root", + "ENTRYPOINT /bin/bash -l" ] } ], From 85cc840388828964318943b51e05dbdd404b1f7e Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Fri, 17 Jul 2020 15:41:27 +0200 Subject: [PATCH 14/28] Fetch workdirs for transient services --- deployments/vagrant/provisioning/run-bitcoin.sh | 4 +++- deployments/vagrant/provisioning/run-clients.sh | 10 ++++++---- deployments/vagrant/provisioning/run-geth.sh | 4 +++- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/deployments/vagrant/provisioning/run-bitcoin.sh b/deployments/vagrant/provisioning/run-bitcoin.sh index d8a019e..0d3c934 100644 --- a/deployments/vagrant/provisioning/run-bitcoin.sh +++ b/deployments/vagrant/provisioning/run-bitcoin.sh @@ -6,6 +6,8 @@ echo "Running Bitcoin Core and ElectrumX as transient system service..." cd local-setup -sudo systemd-run --unit=bitcoin -p WorkingDirectory=/home/vagrant/local-setup ./run-bitcoin.sh +WORKDIR=$(pwd) + +sudo systemd-run --unit=bitcoin -p WorkingDirectory=$WORKDIR ./run-bitcoin.sh echo "Bitcoin Core and ElectrumX have been run as transient system service successfully!" \ No newline at end of file diff --git a/deployments/vagrant/provisioning/run-clients.sh b/deployments/vagrant/provisioning/run-clients.sh index 9ed4064..9064fb7 100644 --- a/deployments/vagrant/provisioning/run-clients.sh +++ b/deployments/vagrant/provisioning/run-clients.sh @@ -6,10 +6,12 @@ echo "Running Core and ECDSA clients..." cd local-setup -sudo systemd-run --unit=keep-core-1 -p WorkingDirectory=/home/vagrant/local-setup ./run-core-1.sh +WORKDIR=$(pwd) -sudo systemd-run --unit=keep-ecdsa-1 -p WorkingDirectory=/home/vagrant/local-setup ./run-ecdsa-1.sh -sudo systemd-run --unit=keep-ecdsa-2 -p WorkingDirectory=/home/vagrant/local-setup ./run-ecdsa-2.sh -sudo systemd-run --unit=keep-ecdsa-3 -p WorkingDirectory=/home/vagrant/local-setup ./run-ecdsa-3.sh +sudo systemd-run --unit=keep-core-1 -p WorkingDirectory=$WORKDIR ./run-core-1.sh + +sudo systemd-run --unit=keep-ecdsa-1 -p WorkingDirectory=$WORKDIR ./run-ecdsa-1.sh +sudo systemd-run --unit=keep-ecdsa-2 -p WorkingDirectory=$WORKDIR ./run-ecdsa-2.sh +sudo systemd-run --unit=keep-ecdsa-3 -p WorkingDirectory=$WORKDIR ./run-ecdsa-3.sh echo "Core and ECDSA have been run successfully!" \ No newline at end of file diff --git a/deployments/vagrant/provisioning/run-geth.sh b/deployments/vagrant/provisioning/run-geth.sh index 63f6156..6e02636 100644 --- a/deployments/vagrant/provisioning/run-geth.sh +++ b/deployments/vagrant/provisioning/run-geth.sh @@ -6,6 +6,8 @@ echo "Running Geth as transient system service..." cd local-setup -sudo systemd-run --unit=geth -p WorkingDirectory=/home/vagrant/local-setup ./run-geth.sh +WORKDIR=$(pwd) + +sudo systemd-run --unit=geth -p WorkingDirectory=$WORKDIR ./run-geth.sh echo "Geth has been run as transient system service successfully!" \ No newline at end of file From 8dbe15b6e658a255d94cabe02c003033adadeb49 Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Fri, 17 Jul 2020 16:21:30 +0200 Subject: [PATCH 15/28] Align artifacts naming --- .gitignore | 2 +- deployments/packer/packerfile.json | 5 ++--- deployments/vagrant/Vagrantfile | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index f9c3e67..9c07107 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,6 @@ /ethereum/data/geth/ /storage/ node_modules -local-setup-base +vagrant-box .vagrant *.log \ No newline at end of file diff --git a/deployments/packer/packerfile.json b/deployments/packer/packerfile.json index 4656bed..e1f92f5 100644 --- a/deployments/packer/packerfile.json +++ b/deployments/packer/packerfile.json @@ -5,7 +5,7 @@ "source_path": "ubuntu/xenial64", "provider": "virtualbox", "communicator": "ssh", - "output_dir": "local-setup-base" + "output_dir": "vagrant-box" }, { "type": "docker", @@ -13,7 +13,6 @@ "commit": true, "run_command": [ "-d", "-i", "-t", - "--name=local-setup-base-builder", "-w=/root", "--entrypoint=/bin/bash", "--", @@ -62,7 +61,7 @@ [ { "type": "docker-tag", - "repository": "local-setup-base" + "repository": "local-setup-environment" } ] ] diff --git a/deployments/vagrant/Vagrantfile b/deployments/vagrant/Vagrantfile index ad60c49..98ae3a8 100644 --- a/deployments/vagrant/Vagrantfile +++ b/deployments/vagrant/Vagrantfile @@ -9,7 +9,7 @@ unless Vagrant.has_plugin?("vagrant-disksize") end Vagrant.configure("2") do |config| - config.vm.box = "local-setup-base" + config.vm.box = "local-setup-environment" config.vm.synced_folder ".", "/vagrant", disabled: true config.disksize.size = '15GB' From 293454cc23426e1a05df480e385942b79206e72a Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Fri, 17 Jul 2020 16:23:30 +0200 Subject: [PATCH 16/28] Rename `packer` and `vagrant` directories --- deployments/{packer => local-setup-environment}/packerfile.json | 0 .../provisioning/install-commons.sh | 0 .../provisioning/install-docker-compose.sh | 0 .../provisioning/install-docker.sh | 0 .../provisioning/install-geth.sh | 0 .../provisioning/install-go.sh | 0 .../provisioning/install-nodejs.sh | 0 .../provisioning/install-protobuf.sh | 0 .../provisioning/install-solidity.sh | 0 .../provisioning/install-truffle.sh | 0 deployments/{vagrant => local-setup-instance}/Vagrantfile | 0 .../provisioning/clone-repository.sh | 0 .../provisioning/initialize-geth.sh | 0 .../{vagrant => local-setup-instance}/provisioning/run-bitcoin.sh | 0 .../{vagrant => local-setup-instance}/provisioning/run-clients.sh | 0 .../{vagrant => local-setup-instance}/provisioning/run-geth.sh | 0 .../{vagrant => local-setup-instance}/provisioning/run-install.sh | 0 .../provisioning/update-repository.sh | 0 18 files changed, 0 insertions(+), 0 deletions(-) rename deployments/{packer => local-setup-environment}/packerfile.json (100%) rename deployments/{packer => local-setup-environment}/provisioning/install-commons.sh (100%) rename deployments/{packer => local-setup-environment}/provisioning/install-docker-compose.sh (100%) rename deployments/{packer => local-setup-environment}/provisioning/install-docker.sh (100%) rename deployments/{packer => local-setup-environment}/provisioning/install-geth.sh (100%) rename deployments/{packer => local-setup-environment}/provisioning/install-go.sh (100%) rename deployments/{packer => local-setup-environment}/provisioning/install-nodejs.sh (100%) rename deployments/{packer => local-setup-environment}/provisioning/install-protobuf.sh (100%) rename deployments/{packer => local-setup-environment}/provisioning/install-solidity.sh (100%) rename deployments/{packer => local-setup-environment}/provisioning/install-truffle.sh (100%) rename deployments/{vagrant => local-setup-instance}/Vagrantfile (100%) rename deployments/{vagrant => local-setup-instance}/provisioning/clone-repository.sh (100%) rename deployments/{vagrant => local-setup-instance}/provisioning/initialize-geth.sh (100%) rename deployments/{vagrant => local-setup-instance}/provisioning/run-bitcoin.sh (100%) rename deployments/{vagrant => local-setup-instance}/provisioning/run-clients.sh (100%) rename deployments/{vagrant => local-setup-instance}/provisioning/run-geth.sh (100%) rename deployments/{vagrant => local-setup-instance}/provisioning/run-install.sh (100%) rename deployments/{vagrant => local-setup-instance}/provisioning/update-repository.sh (100%) diff --git a/deployments/packer/packerfile.json b/deployments/local-setup-environment/packerfile.json similarity index 100% rename from deployments/packer/packerfile.json rename to deployments/local-setup-environment/packerfile.json diff --git a/deployments/packer/provisioning/install-commons.sh b/deployments/local-setup-environment/provisioning/install-commons.sh similarity index 100% rename from deployments/packer/provisioning/install-commons.sh rename to deployments/local-setup-environment/provisioning/install-commons.sh diff --git a/deployments/packer/provisioning/install-docker-compose.sh b/deployments/local-setup-environment/provisioning/install-docker-compose.sh similarity index 100% rename from deployments/packer/provisioning/install-docker-compose.sh rename to deployments/local-setup-environment/provisioning/install-docker-compose.sh diff --git a/deployments/packer/provisioning/install-docker.sh b/deployments/local-setup-environment/provisioning/install-docker.sh similarity index 100% rename from deployments/packer/provisioning/install-docker.sh rename to deployments/local-setup-environment/provisioning/install-docker.sh diff --git a/deployments/packer/provisioning/install-geth.sh b/deployments/local-setup-environment/provisioning/install-geth.sh similarity index 100% rename from deployments/packer/provisioning/install-geth.sh rename to deployments/local-setup-environment/provisioning/install-geth.sh diff --git a/deployments/packer/provisioning/install-go.sh b/deployments/local-setup-environment/provisioning/install-go.sh similarity index 100% rename from deployments/packer/provisioning/install-go.sh rename to deployments/local-setup-environment/provisioning/install-go.sh diff --git a/deployments/packer/provisioning/install-nodejs.sh b/deployments/local-setup-environment/provisioning/install-nodejs.sh similarity index 100% rename from deployments/packer/provisioning/install-nodejs.sh rename to deployments/local-setup-environment/provisioning/install-nodejs.sh diff --git a/deployments/packer/provisioning/install-protobuf.sh b/deployments/local-setup-environment/provisioning/install-protobuf.sh similarity index 100% rename from deployments/packer/provisioning/install-protobuf.sh rename to deployments/local-setup-environment/provisioning/install-protobuf.sh diff --git a/deployments/packer/provisioning/install-solidity.sh b/deployments/local-setup-environment/provisioning/install-solidity.sh similarity index 100% rename from deployments/packer/provisioning/install-solidity.sh rename to deployments/local-setup-environment/provisioning/install-solidity.sh diff --git a/deployments/packer/provisioning/install-truffle.sh b/deployments/local-setup-environment/provisioning/install-truffle.sh similarity index 100% rename from deployments/packer/provisioning/install-truffle.sh rename to deployments/local-setup-environment/provisioning/install-truffle.sh diff --git a/deployments/vagrant/Vagrantfile b/deployments/local-setup-instance/Vagrantfile similarity index 100% rename from deployments/vagrant/Vagrantfile rename to deployments/local-setup-instance/Vagrantfile diff --git a/deployments/vagrant/provisioning/clone-repository.sh b/deployments/local-setup-instance/provisioning/clone-repository.sh similarity index 100% rename from deployments/vagrant/provisioning/clone-repository.sh rename to deployments/local-setup-instance/provisioning/clone-repository.sh diff --git a/deployments/vagrant/provisioning/initialize-geth.sh b/deployments/local-setup-instance/provisioning/initialize-geth.sh similarity index 100% rename from deployments/vagrant/provisioning/initialize-geth.sh rename to deployments/local-setup-instance/provisioning/initialize-geth.sh diff --git a/deployments/vagrant/provisioning/run-bitcoin.sh b/deployments/local-setup-instance/provisioning/run-bitcoin.sh similarity index 100% rename from deployments/vagrant/provisioning/run-bitcoin.sh rename to deployments/local-setup-instance/provisioning/run-bitcoin.sh diff --git a/deployments/vagrant/provisioning/run-clients.sh b/deployments/local-setup-instance/provisioning/run-clients.sh similarity index 100% rename from deployments/vagrant/provisioning/run-clients.sh rename to deployments/local-setup-instance/provisioning/run-clients.sh diff --git a/deployments/vagrant/provisioning/run-geth.sh b/deployments/local-setup-instance/provisioning/run-geth.sh similarity index 100% rename from deployments/vagrant/provisioning/run-geth.sh rename to deployments/local-setup-instance/provisioning/run-geth.sh diff --git a/deployments/vagrant/provisioning/run-install.sh b/deployments/local-setup-instance/provisioning/run-install.sh similarity index 100% rename from deployments/vagrant/provisioning/run-install.sh rename to deployments/local-setup-instance/provisioning/run-install.sh diff --git a/deployments/vagrant/provisioning/update-repository.sh b/deployments/local-setup-instance/provisioning/update-repository.sh similarity index 100% rename from deployments/vagrant/provisioning/update-repository.sh rename to deployments/local-setup-instance/provisioning/update-repository.sh From 1ed577c76c2c16314d6ae0875c627c887c01e6d0 Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Fri, 17 Jul 2020 16:53:24 +0200 Subject: [PATCH 17/28] Fix docker-tag post processor --- deployments/local-setup-environment/packerfile.json | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/deployments/local-setup-environment/packerfile.json b/deployments/local-setup-environment/packerfile.json index e1f92f5..257843a 100644 --- a/deployments/local-setup-environment/packerfile.json +++ b/deployments/local-setup-environment/packerfile.json @@ -58,11 +58,10 @@ } ], "post-processors": [ - [ - { - "type": "docker-tag", - "repository": "local-setup-environment" - } - ] + { + "type": "docker-tag", + "repository": "local-setup-environment", + "only": ["docker"] + } ] } \ No newline at end of file From bc20d9a57f8ffd9fa82df1f3b371ea52cf26de42 Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Mon, 20 Jul 2020 12:53:44 +0200 Subject: [PATCH 18/28] Make all scripts executable --- deployments/local-setup-instance/provisioning/clone-repository.sh | 0 deployments/local-setup-instance/provisioning/initialize-geth.sh | 0 deployments/local-setup-instance/provisioning/run-bitcoin.sh | 0 deployments/local-setup-instance/provisioning/run-clients.sh | 0 deployments/local-setup-instance/provisioning/run-geth.sh | 0 deployments/local-setup-instance/provisioning/run-install.sh | 0 .../local-setup-instance/provisioning/update-repository.sh | 0 7 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 deployments/local-setup-instance/provisioning/clone-repository.sh mode change 100644 => 100755 deployments/local-setup-instance/provisioning/initialize-geth.sh mode change 100644 => 100755 deployments/local-setup-instance/provisioning/run-bitcoin.sh mode change 100644 => 100755 deployments/local-setup-instance/provisioning/run-clients.sh mode change 100644 => 100755 deployments/local-setup-instance/provisioning/run-geth.sh mode change 100644 => 100755 deployments/local-setup-instance/provisioning/run-install.sh mode change 100644 => 100755 deployments/local-setup-instance/provisioning/update-repository.sh diff --git a/deployments/local-setup-instance/provisioning/clone-repository.sh b/deployments/local-setup-instance/provisioning/clone-repository.sh old mode 100644 new mode 100755 diff --git a/deployments/local-setup-instance/provisioning/initialize-geth.sh b/deployments/local-setup-instance/provisioning/initialize-geth.sh old mode 100644 new mode 100755 diff --git a/deployments/local-setup-instance/provisioning/run-bitcoin.sh b/deployments/local-setup-instance/provisioning/run-bitcoin.sh old mode 100644 new mode 100755 diff --git a/deployments/local-setup-instance/provisioning/run-clients.sh b/deployments/local-setup-instance/provisioning/run-clients.sh old mode 100644 new mode 100755 diff --git a/deployments/local-setup-instance/provisioning/run-geth.sh b/deployments/local-setup-instance/provisioning/run-geth.sh old mode 100644 new mode 100755 diff --git a/deployments/local-setup-instance/provisioning/run-install.sh b/deployments/local-setup-instance/provisioning/run-install.sh old mode 100644 new mode 100755 diff --git a/deployments/local-setup-instance/provisioning/update-repository.sh b/deployments/local-setup-instance/provisioning/update-repository.sh old mode 100644 new mode 100755 From ab36583024c3ee2323bcfdebac3369bf791619e6 Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Mon, 20 Jul 2020 14:16:59 +0200 Subject: [PATCH 19/28] Auto update of submodules --- deployments/local-setup-instance/Vagrantfile | 1 - .../provisioning/update-repository.sh | 12 ------------ install-repositories.sh | 3 +-- install.sh | 2 ++ 4 files changed, 3 insertions(+), 15 deletions(-) delete mode 100755 deployments/local-setup-instance/provisioning/update-repository.sh diff --git a/deployments/local-setup-instance/Vagrantfile b/deployments/local-setup-instance/Vagrantfile index 98ae3a8..31ced34 100644 --- a/deployments/local-setup-instance/Vagrantfile +++ b/deployments/local-setup-instance/Vagrantfile @@ -21,7 +21,6 @@ Vagrant.configure("2") do |config| end config.vm.provision "shell", path: "./provisioning/clone-repository.sh", privileged: false - config.vm.provision "shell", path: "./provisioning/update-repository.sh", privileged: false config.vm.provision "shell", path: "./provisioning/initialize-geth.sh", privileged: false config.vm.provision "shell", path: "./provisioning/run-geth.sh", privileged: false, run: "always" config.vm.provision "shell", path: "./provisioning/run-bitcoin.sh", privileged: false, run: "always" diff --git a/deployments/local-setup-instance/provisioning/update-repository.sh b/deployments/local-setup-instance/provisioning/update-repository.sh deleted file mode 100755 index 7fb44be..0000000 --- a/deployments/local-setup-instance/provisioning/update-repository.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -set -e - -echo "Updating repository..." - -cd local-setup - -#TODO: Temporary. Final solution should update all submodules to the recent master. -git checkout local-setup-vm - -echo "Repository has been updated successfully!" \ No newline at end of file diff --git a/install-repositories.sh b/install-repositories.sh index a8679c2..2c7781e 100755 --- a/install-repositories.sh +++ b/install-repositories.sh @@ -7,5 +7,4 @@ LOG_END='\n\e[0m' # new line + reset color printf "${LOG_START}Initializing submodules...${LOG_END}" -git submodule init -git submodule update \ No newline at end of file +git submodule update --init --recursive --remote --rebase --force \ No newline at end of file diff --git a/install.sh b/install.sh index 8b2f295..68d2689 100755 --- a/install.sh +++ b/install.sh @@ -19,3 +19,5 @@ set -e # Install tBTC dApp. ./install-tbtc-dapp.sh + +echo "Installation script executed successfully with versions of submodules:\n$(git submodule)" \ No newline at end of file From 4f2b720441b7d3d43efa969edbd5f875da48b0d3 Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Mon, 20 Jul 2020 17:02:55 +0200 Subject: [PATCH 20/28] Docs update --- README.adoc | 148 +++------------------------------------ docs/auto-setup.adoc | 111 ++++++++++++++++++++++++++++++ docs/manual-setup.adoc | 152 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 271 insertions(+), 140 deletions(-) create mode 100644 docs/auto-setup.adoc create mode 100644 docs/manual-setup.adoc diff --git a/README.adoc b/README.adoc index 2051dc3..d2d0da5 100644 --- a/README.adoc +++ b/README.adoc @@ -1,148 +1,16 @@ = KEEP & tBTC local setup -== Setting up development environment -If you’re on macOS, install Homebrew and https://github.com/keep-network/keep-core/blob/master/scripts/macos-setup.sh[macos-setup.sh] script to setup all necessary tools. +== Installation -If you are not on macOS or you don't have Homebrew, you need to install: +This repository can be used in two different ways described below: -- Go compiler, at least 1.14 -- Geth (Ethereum client) 1.9.9-stable -- Solidity, at least 0.5.17 -- Truffle, at least 5.1.18 -- Protobuf compiler, at least 3.11.4 -- `protoc-gen-gogoslick` toolchain -- `jq` +=== Automatic installation on separate virtual machine -Regardless you use `macos-setup.sh` or not, you should also install: +To install everything automatically on a separate VitualBox machine using Packer and +Vagrant, please follow the <<./docs/auto-setup.adoc#title, automatic setup guide>>. -- https://docs.docker.com/get-docker[Docker] & https://docs.docker.com/compose/install/[Docker Compose] -- https://github.com/pyenv/pyenv[pyenv], at least 1.2.18 (optional - only if testnet relay is used) -- https://github.com/pypa/pipenv[pipenv], at least 2018.11.26 (optional - only if testnet relay is used) +=== Manual installation on your local machine -== Node.js version notice +To install everything on your local machine by hand, +please follow the <<./docs/manual-setup.adoc#title, manual setup guide>>. -Please use Node `v11.15.0` for everything but E2E test script. -To run the test script, please use Node `v14.3.0`. - -We recommend using https://github.com/nvm-sh/nvm[nvm] to manage node versions easily. -You can install both versions by doing: -``` -nvm install 11.15.0 -nvm install 14.3.0 -``` -And use the specific version: -``` -nvm use 11.15.0 -nvm use 14.3.0 -``` - -== Installing the system -. Initialize local `geth` using: -+ -``` -./initialize-geth.sh -``` -+ -You can skip this step if your local geth is already initialized. This script clears all Ethereum client data, initilizes genesis block, and funds five accounts. All client data are kept in the working directory of this project so all the data used for other projects stay untouched. - -. Run local `geth` node using: -+ -``` -./run-geth.sh -``` -. Run local Bitcoin Core node and ElectrumX using: -+ -``` -./run-bitcoin.sh -``` -. Run Keep & tBTC installation script: -+ -``` -./install.sh -``` -+ -This script will fetch `keep-core`, `keep-ecdsa`, and `tbtc` source code, deploy contracts of `keep-core`, `keep-ecdsa`, and `tbtc`. It will also build `keep-core` and `keep-ecdsa` off-chain clients. -+ -Later on, if you decide to update `tbtc`, you can run just `install-tbtc.sh`. -+ -Keep in mind, `tbtc` depends on `keep-ecdsa` and `keep-ecdsa` depends on `keep-core` so if you decide to update `keep-ecdsa`, you can run `install-keep-ecdsa.sh` followed by `install-tbtc.sh`. -+ -If you decide to update `keep-core`, you have to run `install-keep-core.sh` followed by `install-keep-ecdsa.sh` followed by `install-tbtc.sh` or just the entire `install.sh` again. - -== Run clients -The above installation script will configure: - -- 1 `keep-core` client -- 3 `keep-ecdsa` clients - -To run the `keep-core` client use: -``` -./run-core-1.sh -``` - -It is enough to run one `keep-core` client to generate a group and produce relay entries. Setting up more than one client locally is possible but consumes more resources. - -To run `keep-ecdsa` clients use: -``` -./run-ecdsa-1.sh -``` -``` -./run-ecdsa-2.sh -``` -``` -./run-ecdsa-3.sh -``` - -There are at least 3 `keep-ecdsa` clients needed to open a keep. Setting up more than three clients locally is possible but consumes more resources. - -== Beacon genesis - -Before the beacon is able to produce a first relay entry, genesis needs to happen. Genesis triggers the first random beacon group selection. - -Genesis should be triggered after `keep-core` client started with: -``` -cd keep-core -KEEP_ETHEREUM_PASSWORD="password" ./keep-core --config configs/config.local.1.toml relay genesis -``` - -Bonded ECDSA keep factory from `keep-ecdsa` contracts requests for new relay entry to reseed after each signer selection but it is also possible to request for a new relay entry manually with: -``` -cd keep-core -KEEP_ETHEREUM_PASSWORD="password" ./keep-core --config configs/config.local.1.toml relay request -``` - -= How to interact with the system - -You can interact with the system through the tBTC dApp or automated -end-to-end tests. Before you start interacting, make sure you: - -- Installed all system components using `install.sh` script -- Have a local Geth instance (`run-geth.sh`) working -- Have local Bitcoin Core and ElectrumX instances (`run-bitcoin.sh`) working -- Have 1 `keep-core` and 3 `keep-ecdsa` clients up and running - -== Keep Dashboard dApp - -To run the Keep Dashboard dApp invoke: -``` -./run-keep-dashboard.sh -``` - -== tBTC dApp - -To run the tBTC dApp against the local Bitcoin network, -make sure the tBTC dApp is configured to work with the local ElectrumX instance. -You can configure this in `./tbtc-dapp/src/wrappers/web3.js` file, -where `TBTC.withConfig` line occurs. -Then, you can invoke: -``` -./run-tbtc-dapp.sh -``` -The application will be available on `http://localhost:3000`. - -== E2E tests - -To run the automated end-to-end scenario invoke: -``` -./run-e2e-test.sh -``` diff --git a/docs/auto-setup.adoc b/docs/auto-setup.adoc new file mode 100644 index 0000000..4c3c1e3 --- /dev/null +++ b/docs/auto-setup.adoc @@ -0,0 +1,111 @@ += Automatic setup on virtual machine + +== Prerequisites + +You need to install: + +- https://www.packer.io/downloads[Packer] +- https://www.vagrantup.com/downloads[Vagrant] +- https://www.virtualbox.org/wiki/Downloads[VirtualBox] + +[TIP] +VirtualBox installation may fail on macOS Catalina. If it's your case, please look +at https://apple.stackexchange.com/questions/372492/virtualbox-installation-failed-on-macos-catalina[this issue]. + +== Installing the system + +First, go to the `deployments/local-setup-environment` directory and build the environment image: +``` +packer build -only=vagrant packerfile.json +``` +An output directory named `vagrant-box` containing `package.box` file should be created. + +Then, switch the directory to `deployments/local-setup-instance` and import +the image: +``` +vagrant box add --force --name=local-setup-environment ./../local-setup-environment/vagrant-box/package.box +``` +Finally, you can run the virtual machine by doing: +``` +vagrant up +``` +A new virtual machine will be created and provisioned accordingly. When +this command terminates successfully, the machine should be ready to work +and have all the auxiliary software like Geth, Bitcoin Core, ElectrumX +and Core/ECDSA clients running. + +== How to interact with the system + +You can interact with the system through the tBTC dApp or automated +end-to-end tests. Before you start interacting, you have to connect +to the virtual machine. First, switch to the `deployments/local-setup-instance` +directory and do: +``` +vagrant ssh +``` + +You will be moved to the virtual machine home directory where you can find +the `local-setup` directory where all installed things live. + +=== Keep Dashboard dApp + +To run the Keep Dashboard dApp invoke: +``` +./run-keep-dashboard.sh +``` + +=== tBTC dApp + +To run the tBTC dApp against the local Bitcoin network, +make sure the tBTC dApp is configured to work with the local ElectrumX instance. +You can configure this in `./tbtc-dapp/src/wrappers/web3.js` file, +where `TBTC.withConfig` line occurs. +Then, you can invoke: +``` +./run-tbtc-dapp.sh +``` +The application will be available on `http://localhost:3000`. + +=== E2E tests + +To run the automated end-to-end scenario switch to Node 14.3.0: +``` +nvm use 14.3.0 +``` +Then invoke: +``` +./run-e2e-test.sh +``` + +== Virtual machine lifecycle + +You can manage the VM lifecycle by switching to the `deployments/local-setup-instance` +directory. + +To stop the machine do: +``` +vagrant halt +``` + +To start it again, just make: +``` +vagrant up +``` + +To restart the machine, invoke: +``` +vagrant reload +``` + +Everytime you start the machine, Geth, btcd, ElectrumX and Core/ECDSA clients +will be started as well but the configured `local-setup` directory won't be touched. +However, if you want to deploy everything from scratch +you can reload the machine with provisioning option enabled: +``` +vagrant reload --provision +``` +or, destroy the machine: +``` +vagrant destroy +``` +and run it again. diff --git a/docs/manual-setup.adoc b/docs/manual-setup.adoc new file mode 100644 index 0000000..aad721d --- /dev/null +++ b/docs/manual-setup.adoc @@ -0,0 +1,152 @@ += Manual setup on local machine + +== Prerequisites +If you’re on macOS, install Homebrew and https://github.com/keep-network/keep-core/blob/master/scripts/macos-setup.sh[macos-setup.sh] script to setup all necessary tools. + +If you are not on macOS or you don't have Homebrew, you need to install: + +- Go compiler, at least 1.14 +- Geth (Ethereum client) 1.9.9-stable +- Solidity, at least 0.5.17 +- Truffle, at least 5.1.18 +- Protobuf compiler, at least 3.11.4 +- `protoc-gen-gogoslick` toolchain +- `jq` + +Regardless you use `macos-setup.sh` or not, you should also install: + +- https://docs.docker.com/get-docker[Docker] & https://docs.docker.com/compose/install/[Docker Compose] +- https://github.com/pyenv/pyenv[pyenv], at least 1.2.18 (optional - only if testnet relay is used) +- https://github.com/pypa/pipenv[pipenv], at least 2018.11.26 (optional - only if testnet relay is used) + +== Node.js version notice + +Please use Node `v11.15.0` for everything but E2E test script. +To run the test script, please use Node `v14.3.0`. + +We recommend using https://github.com/nvm-sh/nvm[nvm] to manage node versions easily. +You can install both versions by doing: +``` +nvm install 11.15.0 +nvm install 14.3.0 +``` +And use the specific version: +``` +nvm use 11.15.0 +nvm use 14.3.0 +``` + +== Installing the system +. Initialize local `geth` using: ++ +``` +./initialize-geth.sh +``` ++ +You can skip this step if your local geth is already initialized. This script clears all Ethereum client data, initilizes genesis block, and funds five accounts. All client data are kept in the working directory of this project so all the data used for other projects stay untouched. + +. Run local `geth` node using: ++ +``` +./run-geth.sh +``` +. Run local Bitcoin Core node and ElectrumX using: ++ +``` +./run-bitcoin.sh +``` +. Run Keep & tBTC installation script: ++ +``` +./install.sh +``` ++ +This script will fetch `keep-core`, `keep-ecdsa`, and `tbtc` source code, deploy contracts of `keep-core`, `keep-ecdsa`, and `tbtc`. It will also build `keep-core` and `keep-ecdsa` off-chain clients. ++ +Later on, if you decide to update `tbtc`, you can run just `install-tbtc.sh`. ++ +Keep in mind, `tbtc` depends on `keep-ecdsa` and `keep-ecdsa` depends on `keep-core` so if you decide to update `keep-ecdsa`, you can run `install-keep-ecdsa.sh` followed by `install-tbtc.sh`. ++ +If you decide to update `keep-core`, you have to run `install-keep-core.sh` followed by `install-keep-ecdsa.sh` followed by `install-tbtc.sh` or just the entire `install.sh` again. + +== Run clients +The above installation script will configure: + +- 1 `keep-core` client +- 3 `keep-ecdsa` clients + +To run the `keep-core` client use: +``` +./run-core-1.sh +``` + +It is enough to run one `keep-core` client to generate a group and produce relay entries. Setting up more than one client locally is possible but consumes more resources. + +To run `keep-ecdsa` clients use: +``` +./run-ecdsa-1.sh +``` +``` +./run-ecdsa-2.sh +``` +``` +./run-ecdsa-3.sh +``` + +There are at least 3 `keep-ecdsa` clients needed to open a keep. Setting up more than three clients locally is possible but consumes more resources. + +== Beacon genesis + +Before the beacon is able to produce a first relay entry, genesis needs to happen. Genesis triggers the first random beacon group selection. + +Genesis should be triggered after `keep-core` client started with: +``` +cd keep-core +KEEP_ETHEREUM_PASSWORD="password" ./keep-core --config configs/config.local.1.toml relay genesis +``` + +Bonded ECDSA keep factory from `keep-ecdsa` contracts requests for new relay entry to reseed after each signer selection but it is also possible to request for a new relay entry manually with: +``` +cd keep-core +KEEP_ETHEREUM_PASSWORD="password" ./keep-core --config configs/config.local.1.toml relay request +``` + +== How to interact with the system + +You can interact with the system through the tBTC dApp or automated +end-to-end tests. Before you start interacting, make sure you: + +- Installed all system components using `install.sh` script +- Have a local Geth instance (`run-geth.sh`) working +- Have local Bitcoin Core and ElectrumX instances (`run-bitcoin.sh`) working +- Have 1 `keep-core` and 3 `keep-ecdsa` clients up and running + +=== Keep Dashboard dApp + +To run the Keep Dashboard dApp invoke: +``` +./run-keep-dashboard.sh +``` + +=== tBTC dApp + +To run the tBTC dApp against the local Bitcoin network, +make sure the tBTC dApp is configured to work with the local ElectrumX instance. +You can configure this in `./tbtc-dapp/src/wrappers/web3.js` file, +where `TBTC.withConfig` line occurs. +Then, you can invoke: +``` +./run-tbtc-dapp.sh +``` +The application will be available on `http://localhost:3000`. + +=== E2E tests + +To run the automated end-to-end scenario switch to Node 14.3.0: +``` +nvm use 14.3.0 +``` +Then invoke: +``` +./run-e2e-test.sh +``` From a3fe830af7a73d74f7ce7cf6e9daf0ad0fa53b80 Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Mon, 20 Jul 2020 17:16:18 +0200 Subject: [PATCH 21/28] Fix readme typo --- README.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.adoc b/README.adoc index d2d0da5..e985a55 100644 --- a/README.adoc +++ b/README.adoc @@ -6,7 +6,7 @@ This repository can be used in two different ways described below: === Automatic installation on separate virtual machine -To install everything automatically on a separate VitualBox machine using Packer and +To install everything automatically on a separate VirtualBox machine using Packer and Vagrant, please follow the <<./docs/auto-setup.adoc#title, automatic setup guide>>. === Manual installation on your local machine From bfb72b84fb52fdbdb7e3dcb085b69a78f536a941 Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Thu, 23 Jul 2020 09:37:45 +0200 Subject: [PATCH 22/28] Add note about core/ecdsa clients versions --- docs/auto-setup.adoc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/auto-setup.adoc b/docs/auto-setup.adoc index 4c3c1e3..a848da6 100644 --- a/docs/auto-setup.adoc +++ b/docs/auto-setup.adoc @@ -32,7 +32,8 @@ vagrant up A new virtual machine will be created and provisioned accordingly. When this command terminates successfully, the machine should be ready to work and have all the auxiliary software like Geth, Bitcoin Core, ElectrumX -and Core/ECDSA clients running. +and Core/ECDSA clients running. Worth noting, `keep-core` and `keep-ecdsa` client +executables are always built from their recent master versions. == How to interact with the system From 033cc31c936af2b73a55bf78092a690f354cf671 Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Thu, 23 Jul 2020 09:55:27 +0200 Subject: [PATCH 23/28] Add readme introduction --- README.adoc | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/README.adoc b/README.adoc index e985a55..fc185fc 100644 --- a/README.adoc +++ b/README.adoc @@ -1,8 +1,27 @@ = KEEP & tBTC local setup +This repository provide a bunch of scripts which allow to install tBTC and +Keep locally for development and test purposes. It also contains and +enables execution of automated end-to-end system tests for tBTC. + +Basically, the entire setup operates on several component submodules: + +- https://github.com/keep-network/keep-core[`keep-core`] +- https://github.com/keep-network/keep-ecdsa[`keep-ecdsa`] +- https://github.com/keep-network/tbtc[`tbtc`] +- https://github.com/keep-network/tbtc.js[`tbtc.js`] +- https://github.com/keep-network/tbtc-dapp[`tbtc-dapp`] +- https://github.com/keep-network/relays[`relays`] + +It also uses some auxiliary software needed by tBTC and Keep: + +- https://github.com/ethereum/go-ethereum[Geth] +- https://bitcoincore.org[Bitcoin Core] +- https://electrumx.readthedocs.io/en/latest[ElectrumX] + == Installation -This repository can be used in two different ways described below: +The installation can be performed in two different ways described below: === Automatic installation on separate virtual machine From ed1c00cbc68b411c5b5b300cba68726b6538b01a Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Thu, 23 Jul 2020 10:26:56 +0200 Subject: [PATCH 24/28] Add checks to install-commons.sh --- .../local-setup-environment/provisioning/install-commons.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/deployments/local-setup-environment/provisioning/install-commons.sh b/deployments/local-setup-environment/provisioning/install-commons.sh index fca6f35..5d538bc 100755 --- a/deployments/local-setup-environment/provisioning/install-commons.sh +++ b/deployments/local-setup-environment/provisioning/install-commons.sh @@ -15,7 +15,12 @@ sudo apt-get install -y \ python \ build-essential +if ! [ -x "$(command -v curl)" ]; then echo "curl installation failed"; exit 1; fi +if ! [ -x "$(command -v wget)" ]; then echo "wget installation failed"; exit 1; fi +if ! [ -x "$(command -v git)" ]; then echo "git installation failed"; exit 1; fi if ! [ -x "$(command -v unzip)" ]; then echo "unzip installation failed"; exit 1; fi if ! [ -x "$(command -v jq)" ]; then echo "jq installation failed"; exit 1; fi +if ! [ -x "$(command -v python)" ]; then echo "python installation failed"; exit 1; fi +if ! [ -x "$(command -v make)" ]; then echo "build-essential installation failed"; exit 1; fi echo "Common tools have been installed successfully!" \ No newline at end of file From 117c39074741e31586a2042cf8236bd24547e1b2 Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Thu, 23 Jul 2020 12:20:54 +0200 Subject: [PATCH 25/28] Add note about vagrant-disksize plugin --- docs/auto-setup.adoc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/auto-setup.adoc b/docs/auto-setup.adoc index a848da6..b18f75d 100644 --- a/docs/auto-setup.adoc +++ b/docs/auto-setup.adoc @@ -25,6 +25,10 @@ the image: ``` vagrant box add --force --name=local-setup-environment ./../local-setup-environment/vagrant-box/package.box ``` +Also, install the required `vagrant-disksize` plugin: +``` +vagrant plugin install vagrant-disksize +``` Finally, you can run the virtual machine by doing: ``` vagrant up From 5e0b1e46367fb141bf05ef15d3bf782bd28329ef Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Thu, 23 Jul 2020 13:52:33 +0200 Subject: [PATCH 26/28] Add note about tbtc-dapp local config --- docs/auto-setup.adoc | 25 ++++++++++++++++++++++++- docs/manual-setup.adoc | 25 ++++++++++++++++++++++++- 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/docs/auto-setup.adoc b/docs/auto-setup.adoc index b18f75d..f87d95a 100644 --- a/docs/auto-setup.adoc +++ b/docs/auto-setup.adoc @@ -64,7 +64,30 @@ To run the Keep Dashboard dApp invoke: To run the tBTC dApp against the local Bitcoin network, make sure the tBTC dApp is configured to work with the local ElectrumX instance. You can configure this in `./tbtc-dapp/src/wrappers/web3.js` file, -where `TBTC.withConfig` line occurs. +where `TBTC.withConfig` line occurs: +``` +const initializeContracts = async (web3, connector) => { + // Initialise default account. + const accounts = await web3.eth.getAccounts() + web3.eth.defaultAccount = accounts[0] + + // Log the netId/chainId. + const netId = await web3.eth.net.getId() + const chainId = await web3.eth.getChainId() + console.debug(`netId: ${netId}\nchainId: ${chainId}`) + + Web3LoadedDeferred.resolve(web3) + + const tbtc = await TBTC.withConfig({ + web3: web3, + bitcoinNetwork: "testnet", + electrum: config.electrum + }) + + TBTCLoadedDeferred.resolve(tbtc) +} +``` + Then, you can invoke: ``` ./run-tbtc-dapp.sh diff --git a/docs/manual-setup.adoc b/docs/manual-setup.adoc index aad721d..5b386e1 100644 --- a/docs/manual-setup.adoc +++ b/docs/manual-setup.adoc @@ -133,7 +133,30 @@ To run the Keep Dashboard dApp invoke: To run the tBTC dApp against the local Bitcoin network, make sure the tBTC dApp is configured to work with the local ElectrumX instance. You can configure this in `./tbtc-dapp/src/wrappers/web3.js` file, -where `TBTC.withConfig` line occurs. +where `TBTC.withConfig` line occurs: +``` +const initializeContracts = async (web3, connector) => { + // Initialise default account. + const accounts = await web3.eth.getAccounts() + web3.eth.defaultAccount = accounts[0] + + // Log the netId/chainId. + const netId = await web3.eth.net.getId() + const chainId = await web3.eth.getChainId() + console.debug(`netId: ${netId}\nchainId: ${chainId}`) + + Web3LoadedDeferred.resolve(web3) + + const tbtc = await TBTC.withConfig({ + web3: web3, + bitcoinNetwork: "testnet", + electrum: config.electrum + }) + + TBTCLoadedDeferred.resolve(tbtc) +} +``` + Then, you can invoke: ``` ./run-tbtc-dapp.sh From c48e44164498097bf75475bfb730b4cf5521a119 Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Thu, 23 Jul 2020 13:58:13 +0200 Subject: [PATCH 27/28] Change note about tbtc-dapp local config --- docs/auto-setup.adoc | 35 +++++++++++++---------------------- docs/manual-setup.adoc | 35 +++++++++++++---------------------- 2 files changed, 26 insertions(+), 44 deletions(-) diff --git a/docs/auto-setup.adoc b/docs/auto-setup.adoc index f87d95a..e2711f1 100644 --- a/docs/auto-setup.adoc +++ b/docs/auto-setup.adoc @@ -64,28 +64,19 @@ To run the Keep Dashboard dApp invoke: To run the tBTC dApp against the local Bitcoin network, make sure the tBTC dApp is configured to work with the local ElectrumX instance. You can configure this in `./tbtc-dapp/src/wrappers/web3.js` file, -where `TBTC.withConfig` line occurs: -``` -const initializeContracts = async (web3, connector) => { - // Initialise default account. - const accounts = await web3.eth.getAccounts() - web3.eth.defaultAccount = accounts[0] - - // Log the netId/chainId. - const netId = await web3.eth.net.getId() - const chainId = await web3.eth.getChainId() - console.debug(`netId: ${netId}\nchainId: ${chainId}`) - - Web3LoadedDeferred.resolve(web3) - - const tbtc = await TBTC.withConfig({ - web3: web3, - bitcoinNetwork: "testnet", - electrum: config.electrum - }) - - TBTCLoadedDeferred.resolve(tbtc) -} +where `TBTC.withConfig` line occurs. Change it as follows: +``` +const tbtc = await TBTC.withConfig({ + web3: web3, + bitcoinNetwork: "regtest", + electrum: { + testnetWS: { + server: "127.0.0.1", + port: 50003, + protocol: "ws" + } + } +}) ``` Then, you can invoke: diff --git a/docs/manual-setup.adoc b/docs/manual-setup.adoc index 5b386e1..37bb74f 100644 --- a/docs/manual-setup.adoc +++ b/docs/manual-setup.adoc @@ -133,28 +133,19 @@ To run the Keep Dashboard dApp invoke: To run the tBTC dApp against the local Bitcoin network, make sure the tBTC dApp is configured to work with the local ElectrumX instance. You can configure this in `./tbtc-dapp/src/wrappers/web3.js` file, -where `TBTC.withConfig` line occurs: -``` -const initializeContracts = async (web3, connector) => { - // Initialise default account. - const accounts = await web3.eth.getAccounts() - web3.eth.defaultAccount = accounts[0] - - // Log the netId/chainId. - const netId = await web3.eth.net.getId() - const chainId = await web3.eth.getChainId() - console.debug(`netId: ${netId}\nchainId: ${chainId}`) - - Web3LoadedDeferred.resolve(web3) - - const tbtc = await TBTC.withConfig({ - web3: web3, - bitcoinNetwork: "testnet", - electrum: config.electrum - }) - - TBTCLoadedDeferred.resolve(tbtc) -} +where `TBTC.withConfig` line occurs. Change it as follows: +``` +const tbtc = await TBTC.withConfig({ + web3: web3, + bitcoinNetwork: "regtest", + electrum: { + testnetWS: { + server: "127.0.0.1", + port: 50003, + protocol: "ws" + } + } +}) ``` Then, you can invoke: From 3b1434d1863a291e345ec530ccb33dfcd103b4b9 Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Fri, 24 Jul 2020 09:42:15 +0200 Subject: [PATCH 28/28] Add missing sudo to clone-repository.sh --- .../local-setup-instance/provisioning/clone-repository.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployments/local-setup-instance/provisioning/clone-repository.sh b/deployments/local-setup-instance/provisioning/clone-repository.sh index f181bb5..e01f0ba 100755 --- a/deployments/local-setup-instance/provisioning/clone-repository.sh +++ b/deployments/local-setup-instance/provisioning/clone-repository.sh @@ -4,7 +4,7 @@ set -e echo "Cloning repository..." -if [ -d local-setup ]; then rm -Rf local-setup; fi +if [ -d local-setup ]; then sudo rm -Rf local-setup; fi git clone https://github.com/keep-network/local-setup.git