dist: add Medalla binary and starting script

This commit is contained in:
Ștefan Talpalaru 2020-11-05 20:51:35 +01:00 committed by zah
parent 24d6618ceb
commit c7d8b81c86
4 changed files with 78 additions and 11 deletions

20
docker/dist/README.md vendored
View File

@ -20,3 +20,23 @@ make dist
No `-march=native` and no metrics support.
## Running a Medalla node
With default options:
```bash
./run_medalla_node.sh
```
Change options implemented as shell variables inside the script:
```bash
LOG_LEVEL=DEBUG BASE_PORT=9100 ./run_medalla_node.sh
```
Add arbitrary `beacon_node` parameters (yes, you can combine this with env vars):
```bash
./run_medalla_node.sh --log-level=DEBUG --rpc-port=9290
```

View File

@ -8,16 +8,16 @@ PREFIX="nimbus-eth2_Linux_amd64_"
GIT_COMMIT="$(git rev-parse --short HEAD)"
DIR="${PREFIX}${GIT_COMMIT}_$(date --utc +'%Y%m%d%H%M%S')"
DIST_PATH="dist/${DIR}"
BINARIES="beacon_node"
BINARIES="beacon_node medalla_beacon_node"
# delete old artefacts
rm -rf "dist/${PREFIX}"*
rm -rf "dist/${PREFIX}"*.tar.gz
mkdir -p "${DIST_PATH}"
# we need to build everything against libraries available inside this container, including the Nim compiler
make clean
make -j$(nproc) NIMFLAGS="-d:disableMarchNative" PARTIAL_STATIC_LINKING=1 ${BINARIES}
make -j$(nproc) LOG_LEVEL="TRACE" NIMFLAGS="-d:disableMarchNative" PARTIAL_STATIC_LINKING=1 ${BINARIES}
for BINARY in ${BINARIES}; do
cp -a ./build/${BINARY} "${DIST_PATH}/"
cd "${DIST_PATH}"
@ -26,6 +26,7 @@ for BINARY in ${BINARIES}; do
cd - >/dev/null
done
sed -e "s/GIT_COMMIT/${GIT_COMMIT}/" docker/dist/README.md > "${DIST_PATH}/README.md"
cp -a scripts/makedir.sh docker/dist/run_medalla_node.sh "${DIST_PATH}/"
# create the tarball
cd dist

38
docker/dist/run_medalla_node.sh vendored Executable file
View File

@ -0,0 +1,38 @@
#!/bin/bash
# Copyright (c) 2020 Status Research & Development GmbH. Licensed under
# either of:
# - Apache License, version 2.0
# - MIT license
# at your option. This file may not be copied, modified, or distributed except
# according to those terms.
set -e
REL_PATH="$(dirname $0)"
# Overridable from the environment.
: ${LOG_LEVEL:="INFO"}
: ${NODE_ID:=0}
: ${NETWORK:="medalla"}
: ${DATA_DIR:="shared_${NETWORK}_${NODE_ID}"}
: ${BASE_PORT:=9000}
: ${BASE_RPC_PORT:=9190}
: ${GOERLI_WEB3_URL:="wss://goerli.infura.io/ws/v3/809a18497dd74102b5f37d25aae3c85a"}
# Create the data directory with the proper permissions.
"${REL_PATH}"/makedir.sh "${DATA_DIR}"
# Run the beacon node.
"${REL_PATH}"/${NETWORK}_beacon_node \
--network="${NETWORK}" \
--log-level="${LOG_LEVEL}" \
--log-file="${DATA_DIR}"/nbc_bn_$(date +"%Y%m%d%H%M%S").log \
--data-dir="${DATA_DIR}" \
--web3-url=${GOERLI_WEB3_URL} \
--tcp-port=$(( ${BASE_PORT} + ${NODE_ID} )) \
--udp-port=$(( ${BASE_PORT} + ${NODE_ID} )) \
--rpc \
--rpc-port=$(( ${BASE_RPC_PORT} +${NODE_ID} )) \
"$@"

View File

@ -1,22 +1,30 @@
#!/bin/bash
# Copyright (c) 2018-2019 Status Research & Development GmbH. Licensed under
# Copyright (c) 2018-2020 Status Research & Development GmbH. Licensed under
# either of:
# - Apache License, version 2.0
# - MIT license
# at your option. This file may not be copied, modified, or distributed except
# according to those terms.
if [[ $OS = "Windows_NT" ]]
then
if [ ! -d "$1" ]; then
[[ -z "$1" ]] && { echo "Usage: $(basename $0) path"; exit 1; }
if uname | grep -qiE "mingw|msys"; then
ON_WINDOWS=1
else
ON_WINDOWS=0
fi
if [[ "${ON_WINDOWS}" == "1" ]]; then
if [[ ! -d "$1" ]]; then
# Create full path.
mkdir -p $1;
# Remove all inherited aces from path $1 ACL and grant full access rights
mkdir -p "$1";
# Remove all inherited access from path $1 ACL and grant full access rights
# to current user only in $1 ACL.
icacls $1 /inheritance:r /grant:r $USERDOMAIN\\$USERNAME:\(OI\)\(CI\)\(F\)&>/dev/null;
icacls "$1" /inheritance:r /grant:r $USERDOMAIN\\$USERNAME:\(OI\)\(CI\)\(F\)&>/dev/null;
fi
else
# Create full path with 0750 permissions.
mkdir -m 0750 -p $1
mkdir -m 0750 -p "$1"
fi