Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions tfgrid3/casper/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:18.04
FROM ubuntu:20.04

LABEL maintainer="[email protected]"
WORKDIR /opt
Expand Down Expand Up @@ -41,10 +41,11 @@ RUN set -ex; \
software-properties-common \
git \
jq \
ufw \
;

# Install zinit
RUN wget -O /sbin/zinit https://github.com/threefoldtech/zinit/releases/download/v0.2.5/zinit \
RUN wget -O /sbin/zinit https://github.com/threefoldtech/zinit/releases/download/v0.2.14/zinit \
&& chmod +x /sbin/zinit \
&& mkdir -p /etc/zinit

Expand All @@ -62,7 +63,7 @@ COPY config/init /tmp/
COPY scripts/start_casper /
COPY scripts/check* /usr/bin/
COPY config/casper /var/www/html/

# Set Casperlabs Startup Script
ENTRYPOINT ["/sbin/zinit", "init"]
VOLUME /var/lib/casper
Expand Down
2 changes: 2 additions & 0 deletions tfgrid3/casper/scripts/casperlabs.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
exec: bash -c "/start_casper"
after:
- ufw
6 changes: 3 additions & 3 deletions tfgrid3/casper/scripts/install_casper
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ CASPER_VERSION=1_0_0
CASPER_NETWORK=casper

### Install Casper node
echo "deb https://repo.casperlabs.io/releases" bionic main | sudo tee -a /etc/apt/sources.list.d/casper.list
curl -O https://repo.casperlabs.io/casper-repo-pubkey.asc
echo "deb https://repo.casper.network/releases" bionic main | sudo tee -a /etc/apt/sources.list.d/casper.list
curl -O https://repo.casper.network/casper-repo-pubkey.asc
sudo apt-key add casper-repo-pubkey.asc
sudo apt update
sudo apt install casper-node-launcher casper-client -y
Expand Down Expand Up @@ -34,7 +34,7 @@ BRANCH="1.0.20" \
### Build smart contracts
cd ~

git clone git://github.com/CasperLabs/casper-node.git
git clone https://github.com/casper-network/casper-node.git
cd casper-node/

git checkout release-1.4.4
Expand Down
28 changes: 10 additions & 18 deletions tfgrid3/casper/scripts/start_casper
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
#!/usr/bin/env bash
set -ex
CASPER_VERSION=1_0_0
CASPER_VERSION=1_5_8
CASPER_NETWORK=casper

# Frontend
cat /opt/cronjobs | crontab -
rm -f /var/www/html/index.html
mkdir /run/lock
if [ ! -d "/run/lock" ]; then
mkdir /run/lock
fi
/usr/bin/checkheaders
/usr/bin/checkip
/etc/init.d/apache2 start
/etc/init.d/cron start
chmod 777 /tmp/*

### Generate node keys
rm /etc/casper/validator_keys/*
cd /etc/casper/validator_keys
sudo -u casper casper-client keygen .


### Set up configuration
sudo -u casper /etc/casper/pull_casper_node_version.sh $CASPER_NETWORK.conf $CASPER_VERSION
sudo -u casper /etc/casper/config_from_example.sh $CASPER_VERSION
sudo -u casper /etc/casper/node_util.py stage_protocols $CASPER_NETWORK.conf

### Get known validator IP
KNOWN_ADDRESSES=$(sudo -u casper cat /etc/casper/$CASPER_VERSION/config.toml | grep known_addresses)
Expand All @@ -41,21 +43,11 @@ done
if [ -z ${KNOWN_VALIDATOR_IP} ]; then exit 1; fi

# Get trusted_hash into config.toml
TRUSTED_HASH=$(casper-client get-block --node-address http://$KNOWN_VALIDATOR_IP:7777 -b 20 | jq -r .result.block.hash | tr -d '\n')
if [ "$TRUSTED_HASH" != "null" ]; then sudo -u casper sed -i "/trusted_hash =/c\trusted_hash = '$TRUSTED_HASH'" /etc/casper/$CASPER_VERSION/config.toml; fi
TRUSTED_HASH=$(casper-client get-block --node-address http://$KNOWN_VALIDATOR_IP:7777 | jq -r .result.block.hash | tr -d '\n')
if [ "$TRUSTED_HASH" != "null" ]; then sudo -u casper sed -i "7c\trusted_hash = '$TRUSTED_HASH'" /etc/casper/$CASPER_VERSION/config.toml; fi


### Stage the upgrades
curl -sSf genesis.casperlabs.io/casper/1_1_0/stage_1_1_0_upgrade.sh | sudo bash
curl -sSf genesis.casperlabs.io/casper/1_1_2/stage_upgrade.sh | sudo bash -
curl -sSf genesis.casperlabs.io/casper/1_2_0/stage_upgrade.sh | sudo bash -
curl -sSf genesis.casperlabs.io/casper/1_2_1/stage_upgrade.sh | sudo bash -
cd ~; curl -sSf genesis.casperlabs.io/casper/1_3_2/stage_upgrade.sh | sudo bash -
cd ~; curl -sSf genesis.casperlabs.io/casper/1_3_4/stage_upgrade.sh | sudo bash -
cd ~; curl -sSf genesis.casperlabs.io/casper/1_4_1/stage_upgrade.sh | sudo bash -
cd ~; curl -sSf genesis.casperlabs.io/casper/1_4_3/stage_upgrade.sh | sudo bash -
cd ~; curl -sSf genesis.casperlabs.io/casper/1_4_4/stage_upgrade.sh | sudo bash -

### Start the node
sudo logrotate -f /etc/logrotate.d/casper-node
exec casper-node-launcher > /var/www/html/node.log
sudo /etc/casper/node_util.py rotate_logs
exec casper-node-launcher -f 1.5.8
13 changes: 13 additions & 0 deletions tfgrid3/casper/scripts/ufw.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
set -x

ufw default deny incoming
ufw default allow outgoing
ufw allow ssh
ufw limit ssh
ufw allow 7777
ufw allow 8888
ufw allow 9999
ufw allow 35000
ufw allow 80
ufw allow 443
4 changes: 4 additions & 0 deletions tfgrid3/casper/scripts/ufw.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
exec: ufw --force enable
oneshot: true
after:
- ufw_init
5 changes: 5 additions & 0 deletions tfgrid3/casper/scripts/ufw_init.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
exec: /bin/sh -eux -c "
chmod +x /etc/zinit/ufw.sh;
/etc/zinit/ufw.sh;"
oneshot: true

Loading