forked from cerc-io/stack-orchestrator
Rename app -> stack_orchestrator (#625)
This commit is contained in:
+13
@@ -0,0 +1,13 @@
|
||||
# source'ed into container build scripts to do generic command setup
|
||||
if [[ -n "$CERC_SCRIPT_DEBUG" ]]; then
|
||||
set -x
|
||||
echo "Build environment variables:"
|
||||
env
|
||||
fi
|
||||
build_command_args=""
|
||||
if [[ ${CERC_FORCE_REBUILD} == "true" ]]; then
|
||||
build_command_args="${build_command_args} --no-cache"
|
||||
fi
|
||||
if [[ -n "$CERC_CONTAINER_EXTRA_BUILD_ARGS" ]]; then
|
||||
build_command_args="${build_command_args} ${CERC_CONTAINER_EXTRA_BUILD_ARGS}"
|
||||
fi
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
# Build a local version of the task executor for act-runner
|
||||
source ${CERC_CONTAINER_BASE_DIR}/build-base.sh
|
||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
docker build -t cerc/act-runner-task-executor:local -f ${CERC_REPO_BASE_DIR}/hosting/act-runner/Dockerfile.task-executor ${build_command_args} ${SCRIPT_DIR}
|
||||
@@ -0,0 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
source ${CERC_CONTAINER_BASE_DIR}/build-base.sh
|
||||
# Build a local version of the act-runner image
|
||||
# TODO: enhance the default build code path to cope with this container (repo has an _ which needs to be converted to - in the image tag)
|
||||
docker build -t cerc/act-runner:local -f ${CERC_REPO_BASE_DIR}/act_runner/Dockerfile ${build_command_args} ${CERC_REPO_BASE_DIR}/act_runner
|
||||
@@ -0,0 +1,31 @@
|
||||
# From: https://github.com/vyzo/gerbil/blob/master/docker/Dockerfile
|
||||
FROM gerbil/ubuntu
|
||||
|
||||
# Install the Solidity compiler (latest stable version)
|
||||
# and guile
|
||||
# and libsecp256k1-dev
|
||||
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive && export DEBCONF_NOWARNINGS="yes" && \
|
||||
apt-get install -y software-properties-common && \
|
||||
add-apt-repository ppa:ethereum/ethereum && \
|
||||
apt-get update && \
|
||||
apt-get install -y solc && \
|
||||
apt-get install -y guile-3.0 && \
|
||||
apt-get install -y libsecp256k1-dev && \
|
||||
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
||||
|
||||
RUN mkdir /scripts
|
||||
COPY install-dependencies.sh /scripts
|
||||
|
||||
# Override the definition of GERBIL_PATH in the base image, but
|
||||
# is safe because (at present) no gerbil packages are installed in the base image
|
||||
# We do this in order to allow a set of pre-installed packages from the container
|
||||
# to be used with an arbitrary, potentially different set of projects bind mounted
|
||||
# at /src
|
||||
ENV GERBIL_PATH=/.gerbil
|
||||
RUN bash /scripts/install-dependencies.sh
|
||||
|
||||
# Needed to prevent git from raging about /src
|
||||
RUN git config --global --add safe.directory /src
|
||||
|
||||
COPY entrypoint.sh /scripts
|
||||
ENTRYPOINT ["/scripts/entrypoint.sh"]
|
||||
@@ -0,0 +1,21 @@
|
||||
## Gerbil Scheme Builder
|
||||
|
||||
This container is designed to be used as a simple "build runner" environment for building and running Scheme projects using Gerbil and gerbil-ethereum. Its primary purpose is to allow build/test/run of gerbil code without the need to install and configure all the necessary prerequisites and dependencies on the host system.
|
||||
|
||||
### Usage
|
||||
|
||||
First build the container with:
|
||||
|
||||
```
|
||||
$ laconic-so build-containers --include cerc/builder-gerbil
|
||||
```
|
||||
|
||||
Now, assuming a gerbil project located at `~/projects/my-project`, run bash in the container mounting the project with:
|
||||
|
||||
```
|
||||
$ docker run -it -v $HOME/projects/my-project:/src cerc/builder-gerbil:latest bash
|
||||
root@7c4124bb09e3:/src#
|
||||
```
|
||||
|
||||
Now gerbil commands can be run.
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
exec "$@"
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
DEPS=(github.com/fare/gerbil-utils
|
||||
github.com/fare/gerbil-poo
|
||||
github.com/fare/gerbil-crypto
|
||||
github.com/fare/gerbil-persist
|
||||
github.com/fare/gerbil-ethereum
|
||||
github.com/drewc/gerbil-swank
|
||||
github.com/drewc/drewc-r7rs-swank
|
||||
github.com/drewc/smug-gerbil
|
||||
github.com/drewc/ftw
|
||||
github.com/vyzo/gerbil-libp2p
|
||||
) ;
|
||||
for i in ${DEPS[@]} ; do
|
||||
echo "Installing gerbil package: $i"
|
||||
gxpkg install $i
|
||||
gxpkg build $i
|
||||
done
|
||||
@@ -0,0 +1,72 @@
|
||||
# Originally from: https://github.com/devcontainers/images/blob/main/src/javascript-node/.devcontainer/Dockerfile
|
||||
# Which depends on: https://github.com/nodejs/docker-node/blob/main/Dockerfile-debian.template
|
||||
# [Choice] Node.js version (use -bullseye variants on local arm64/Apple Silicon): 18, 16, 14, 18-bullseye, 16-bullseye, 14-bullseye, 18-buster, 16-buster, 14-buster
|
||||
ARG VARIANT=18-bullseye
|
||||
FROM node:${VARIANT}
|
||||
|
||||
# Set these args to change the uid/gid for the base container's "node" user to match that of the host user (so bind mounts work as expected).
|
||||
ARG CERC_HOST_UID=1000
|
||||
ARG CERC_HOST_GID=1000
|
||||
# Make these values available at runtime to allow a consistency check.
|
||||
ENV HOST_UID=${CERC_HOST_UID}
|
||||
ENV HOST_GID=${CERC_HOST_GID}
|
||||
|
||||
ARG USERNAME=node
|
||||
ARG NPM_GLOBAL=/usr/local/share/npm-global
|
||||
|
||||
# Add NPM global to PATH.
|
||||
ENV PATH=${NPM_GLOBAL}/bin:${PATH}
|
||||
|
||||
SHELL ["/bin/bash", "-c"]
|
||||
|
||||
RUN \
|
||||
# Don't switch container uid/gid if the host uid/gid is 1000 (which means it's already correct),
|
||||
# or root (which won't work anyway) or <= 100 (which also won't work).
|
||||
if [[ ${CERC_HOST_GID} -ne 1000 && ${CERC_HOST_GID} -ne 0 && ${CERC_HOST_GID} -gt 100 ]]; then \
|
||||
groupmod -g ${CERC_HOST_GID} ${USERNAME}; \
|
||||
fi \
|
||||
&& if [[ ${CERC_HOST_UID} -ne 1000 && ${CERC_HOST_UID} -ne 0 && ${CERC_HOST_UID} -gt 100 ]]; then \
|
||||
usermod -u ${CERC_HOST_UID} -g ${CERC_HOST_GID} ${USERNAME} && chown ${CERC_HOST_UID}:${CERC_HOST_GID} /home/${USERNAME}; \
|
||||
fi
|
||||
|
||||
# Prevents npm from printing version warnings
|
||||
ENV NPM_CONFIG_UPDATE_NOTIFIER=false
|
||||
|
||||
RUN \
|
||||
# Configure global npm install location, use group to adapt to UID/GID changes
|
||||
if ! cat /etc/group | grep -e "^npm:" > /dev/null 2>&1; then groupadd -r npm; fi \
|
||||
&& usermod -a -G npm ${USERNAME} \
|
||||
&& umask 0002 \
|
||||
&& mkdir -p ${NPM_GLOBAL} \
|
||||
&& touch /usr/local/etc/npmrc \
|
||||
&& chown ${USERNAME}:npm ${NPM_GLOBAL} /usr/local/etc/npmrc \
|
||||
&& chmod g+s ${NPM_GLOBAL} \
|
||||
&& npm config -g set prefix ${NPM_GLOBAL} \
|
||||
&& su ${USERNAME} -c "npm config -g set prefix ${NPM_GLOBAL}" \
|
||||
# Install eslint
|
||||
&& su ${USERNAME} -c "umask 0002 && npm install -g eslint" \
|
||||
&& npm cache clean --force > /dev/null 2>&1
|
||||
|
||||
# [Optional] Uncomment this section to install additional OS packages.
|
||||
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
|
||||
&& apt-get -y install --no-install-recommends jq
|
||||
|
||||
# [Optional] Uncomment if you want to install an additional version of node using nvm
|
||||
# ARG EXTRA_NODE_VERSION=10
|
||||
# RUN su node -c "source /usr/local/share/nvm/nvm.sh && nvm install ${EXTRA_NODE_VERSION}"
|
||||
|
||||
# [Optional] Uncomment if you want to install more global node modules
|
||||
# RUN su node -c "npm install -g <your-package-list-here>"
|
||||
|
||||
RUN mkdir /scripts
|
||||
COPY build-npm-package.sh /scripts
|
||||
COPY yarn-local-registry-fixup.sh /scripts
|
||||
COPY build-npm-package-local-dependencies.sh /scripts
|
||||
COPY check-uid.sh /scripts
|
||||
ENV PATH="${PATH}:/scripts"
|
||||
|
||||
COPY entrypoint.sh .
|
||||
ENTRYPOINT ["./entrypoint.sh"]
|
||||
# Placeholder CMD : generally this will be overridden at run time like :
|
||||
# docker run -it -v /home/builder/cerc/laconic-sdk:/workspace cerc/builder-js sh -c 'cd /workspace && yarn && yarn build'
|
||||
CMD node --version
|
||||
@@ -0,0 +1,17 @@
|
||||
## JS/TS Package Builder
|
||||
|
||||
This container is designed to be used as a simple "build runner" environment for building and publishing JS/TS projects
|
||||
using `yarn`.
|
||||
|
||||
### Running a build
|
||||
|
||||
As a temporary measure while the necessary functionality is being added to Stack Orchestrator,
|
||||
it is possible to build packages manually by invoking `docker run` , for example as follows:
|
||||
|
||||
|
||||
```
|
||||
$ docker run --rm -it --add-host gitea.local:host-gateway \
|
||||
-v ${HOME}/cerc/laconic-registry-cli:/workspace cerc/builder-js \
|
||||
sh -c 'cd /workspace && CERC_NPM_AUTH_TOKEN=6613572a28ebebaee20ccd90064251fa8c2b94f6 \
|
||||
build-npm-package-local-dependencies.sh http://gitea.local:3000/api/packages/cerc-io/npm/ 0.1.8'
|
||||
```
|
||||
Executable
+37
@@ -0,0 +1,37 @@
|
||||
#!/bin/bash
|
||||
# Usage: build-npm-package-local-dependencies.sh <registry-url> <publish-with-this-version>
|
||||
# Runs build-npm-package.sh after first fixing up yarn.lock to use a local
|
||||
# npm registry for all packages in a specific scope (currently @cerc-io and @lirewine)
|
||||
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
|
||||
set -x
|
||||
fi
|
||||
if ! [[ $# -eq 1 || $# -eq 2 ]]; then
|
||||
echo "Illegal number of parameters" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ -z "${CERC_NPM_AUTH_TOKEN}" ]]; then
|
||||
echo "CERC_NPM_AUTH_TOKEN is not set" >&2
|
||||
exit 1
|
||||
fi
|
||||
# Exit on error
|
||||
set -e
|
||||
local_npm_registry_url=$1
|
||||
package_publish_version=$2
|
||||
# If we need to handle an additional scope, add it to the list below:
|
||||
npm_scopes_to_handle=("@cerc-io" "@lirewine")
|
||||
for npm_scope_for_local in ${npm_scopes_to_handle[@]}
|
||||
do
|
||||
# We need to configure the local registry
|
||||
npm config set ${npm_scope_for_local}:registry ${local_npm_registry_url}
|
||||
npm config set -- ${local_npm_registry_url}:_authToken ${CERC_NPM_AUTH_TOKEN}
|
||||
# Find the set of dependencies from the specified scope
|
||||
mapfile -t dependencies_from_scope < <(cat package.json | jq -r '.dependencies | with_entries(if (.key|test("^'${npm_scope_for_local}'/.*$")) then ( {key: .key, value: .value } ) else empty end ) | keys[]')
|
||||
echo "Fixing up dependencies in scope ${npm_scope_for_local}"
|
||||
for package in "${dependencies_from_scope[@]}"
|
||||
do
|
||||
echo "Fixing up package ${package}"
|
||||
yarn-local-registry-fixup.sh $package ${local_npm_registry_url}
|
||||
done
|
||||
done
|
||||
echo "Running build"
|
||||
build-npm-package.sh ${local_npm_registry_url} ${package_publish_version}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
#!/bin/bash
|
||||
# Usage: build-npm-package.sh <registry-url> <publish-with-this-version>
|
||||
# Note: supply the registry auth token in CERC_NPM_AUTH_TOKEN
|
||||
if [[ -n "$CERC_SCRIPT_DEBUG" ]]; then
|
||||
set -x
|
||||
fi
|
||||
if ! [[ $# -eq 1 || $# -eq 2 ]]; then
|
||||
echo "Illegal number of parameters" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ -z "${CERC_NPM_AUTH_TOKEN}" ]]; then
|
||||
echo "CERC_NPM_AUTH_TOKEN is not set" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ $# -eq 2 ]]; then
|
||||
package_publish_version=$2
|
||||
else
|
||||
package_publish_version=$( cat package.json | jq -r .version )
|
||||
fi
|
||||
# Exit on error
|
||||
set -e
|
||||
# Get the name of this package from package.json since we weren't passed that
|
||||
package_name=$( cat package.json | jq -r .name )
|
||||
local_npm_registry_url=$1
|
||||
npm config set @cerc-io:registry ${local_npm_registry_url}
|
||||
npm config set @lirewine:registry ${local_npm_registry_url}
|
||||
# Workaround bug in npm unpublish where it needs the url to be of the form //<foo> and not http://<foo>
|
||||
local_npm_registry_url_fixed=$( echo ${local_npm_registry_url} | sed -e 's/^http[s]\{0,1\}://')
|
||||
npm config set -- ${local_npm_registry_url_fixed}:_authToken ${CERC_NPM_AUTH_TOKEN}
|
||||
# First check if the version of this package we're trying to build already exists in the registry
|
||||
package_exists=$( yarn info --json ${package_name}@${package_publish_version} 2>/dev/null | jq -r .data.dist.tarball )
|
||||
if [[ ! -z "$package_exists" && "$package_exists" != "null" ]]; then
|
||||
echo "${package_publish_version} of ${package_name} already exists in the registry"
|
||||
if [[ ${CERC_FORCE_REBUILD} == "true" ]]; then
|
||||
# Attempt to unpublish the existing package
|
||||
echo "NOTE: unpublishing existing package version since force rebuild is enabled"
|
||||
npm unpublish --force ${package_name}@${package_publish_version}
|
||||
else
|
||||
echo "skipping build since target version already exists"
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
echo "Build and publish ${package_name} version ${package_publish_version}"
|
||||
yarn install
|
||||
yarn build
|
||||
yarn publish --non-interactive --new-version ${package_publish_version} --no-git-tag-version
|
||||
@@ -0,0 +1,21 @@
|
||||
#!/bin/bash
|
||||
# Make the container usable for uid/gid != 1000
|
||||
if [[ -n "$CERC_SCRIPT_DEBUG" ]]; then
|
||||
set -x
|
||||
fi
|
||||
current_uid=$(id -u)
|
||||
current_gid=$(id -g)
|
||||
# Don't check if running as root
|
||||
if [[ ${current_uid} == 0 ]]; then
|
||||
exit 0
|
||||
fi
|
||||
# Check the current uid/gid vs the uid/gid used to build the container.
|
||||
# We do this because both bind mounts and npm tooling require the uid/gid to match.
|
||||
if [[ ${current_gid} != ${HOST_GID} ]]; then
|
||||
echo "Warning: running with gid: ${current_gid} which is not the gid for which this container was built (${HOST_GID})"
|
||||
exit 0
|
||||
fi
|
||||
if [[ ${current_uid} != ${HOST_UID} ]]; then
|
||||
echo "Warning: running with gid: ${current_uid} which is not the uid for which this container was built (${HOST_UID})"
|
||||
exit 0
|
||||
fi
|
||||
@@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
/scripts/check-uid.sh
|
||||
exec "$@"
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
#!/bin/bash
|
||||
# Usage: yarn-local-registry-fixup.sh <package-to-fix> <registry-url>
|
||||
# Assumes package.json and yarn.lock are in the cwd
|
||||
# The purpose of this script is to take a project cloned from git
|
||||
# and "fixup" its yarn.lock file such that specified dependency
|
||||
# will be fetched from a registry other than the one used when
|
||||
# yarn.lock was generated. It updates all checksums using data
|
||||
# from the "new" registry (because due to embedded timestamps etc
|
||||
# the same source code re-built later will not have the same checksum).
|
||||
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
|
||||
set -x
|
||||
fi
|
||||
if [[ $# -ne 2 ]]; then
|
||||
echo "Illegal number of parameters" >&2
|
||||
exit 1
|
||||
fi
|
||||
# Exit on error
|
||||
set -e
|
||||
target_package=$1
|
||||
local_npm_registry_url=$2
|
||||
# Extract the actual version pinned in yarn.lock
|
||||
# See: https://stackoverflow.com/questions/60454251/how-to-know-the-version-of-currently-installed-package-from-yarn-lock
|
||||
versioned_target_package=$(yarn list --pattern ${target_package} --depth=0 --json --non-interactive --no-progress | jq -r '.data.trees[].name')
|
||||
# Use yarn info to get URL checksums etc from the new registry
|
||||
yarn_info_output=$(yarn info --json $versioned_target_package 2>/dev/null)
|
||||
# First check if the target version actually exists.
|
||||
# If it doesn't exist there will be no .data.dist.tarball element,
|
||||
# and jq will output the string "null"
|
||||
package_tarball=$(echo $yarn_info_output | jq -r .data.dist.tarball)
|
||||
if [[ "$yarn_info_output" == "" || $package_tarball == "null" ]]; then
|
||||
echo "FATAL: Target package version ($versioned_target_package) not found (or bad npm auth token)" >&2
|
||||
exit 1
|
||||
fi
|
||||
# Code below parses out the values we need
|
||||
# When running inside a container, the registry can return a URL with the wrong host name due to proxying
|
||||
# so we need to check if that has happened and fix the URL if so.
|
||||
if ! [[ "${package_tarball}" =~ ^${local_npm_registry_url}.* ]]; then
|
||||
# HACK: I've hard-wired the host names below. Replace with proper implementation
|
||||
# TODO: remove the hack when proven no longer necessary
|
||||
package_tarball=$( echo ${package_tarball} | sed -e 's/localhost/gitea.local/g' )
|
||||
fi
|
||||
package_integrity=$(echo $yarn_info_output | jq -r .data.dist.integrity)
|
||||
package_shasum=$(echo $yarn_info_output | jq -r .data.dist.shasum)
|
||||
package_resolved=${package_tarball}#${package_shasum}
|
||||
# Some strings need to be escaped so they work when passed to sed later
|
||||
escaped_package_integrity=$(printf '%s\n' "$package_integrity" | sed -e 's/[\/&]/\\&/g')
|
||||
escaped_package_resolved=$(printf '%s\n' "$package_resolved" | sed -e 's/[\/&]/\\&/g')
|
||||
escaped_target_package=$(printf '%s\n' "$target_package" | sed -e 's/[\/&]/\\&/g')
|
||||
if [ -n "$CERC_SCRIPT_VERBOSE" ]; then
|
||||
echo "Tarball: ${package_tarball}"
|
||||
echo "Integrity: ${package_integrity}"
|
||||
echo "Shasum: ${package_shasum}"
|
||||
echo "Resolved: ${package_resolved}"
|
||||
fi
|
||||
# Use magic sed regex to replace the values in yarn.lock
|
||||
# Note: yarn.lock is not json so we can not use jq for this
|
||||
sed -i -e '/^\"'${escaped_target_package}'.*\":$/ , /^\".*$/ s/^\([[:space:]]\{1,\}resolved \).*$/\1'\"${escaped_package_resolved}\"'/' yarn.lock
|
||||
sed -i -e '/^\"'${escaped_target_package}'.*\":$/ , /^\".*$/ s/^\([[:space:]]\{1,\}integrity \).*$/\1'${escaped_package_integrity}'/' yarn.lock
|
||||
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
# Build cerc/eth-api-proxy
|
||||
|
||||
source ${CERC_CONTAINER_BASE_DIR}/build-base.sh
|
||||
|
||||
# See: https://stackoverflow.com/a/246128/1701505
|
||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
|
||||
docker build -t cerc/eth-api-proxy:local ${build_command_args} ${CERC_REPO_BASE_DIR}/eth-api-proxy
|
||||
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
# Build cerc/eth-probe
|
||||
source ${CERC_CONTAINER_BASE_DIR}/build-base.sh
|
||||
docker build -t cerc/eth-probe:local ${build_command_args} ${CERC_REPO_BASE_DIR}/eth-probe
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
# Build cerc/eth-statediff-fill-service
|
||||
source ${CERC_CONTAINER_BASE_DIR}/build-base.sh
|
||||
docker build -t cerc/eth-statediff-fill-service:local ${build_command_args} ${CERC_REPO_BASE_DIR}/eth-statediff-fill-service
|
||||
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
# Build cerc/eth-statediff-service
|
||||
source ${CERC_CONTAINER_BASE_DIR}/build-base.sh
|
||||
docker build -t cerc/eth-statediff-service:local ${build_command_args} ${CERC_REPO_BASE_DIR}/eth-statediff-service
|
||||
@@ -0,0 +1,27 @@
|
||||
FROM skylenet/ethereum-genesis-generator@sha256:210353ce7c898686bc5092f16c61220a76d357f51eff9c451e9ad1b9ad03d4d3 AS ethgen
|
||||
|
||||
FROM golang:1.20-alpine as builder
|
||||
|
||||
RUN apk add --no-cache python3 py3-pip
|
||||
|
||||
COPY genesis /opt/genesis
|
||||
|
||||
# Install ethereum-genesis-generator tools
|
||||
COPY --from=ethgen /usr/local/bin/eth2-testnet-genesis /usr/local/bin/
|
||||
COPY --from=ethgen /usr/local/bin/eth2-val-tools /usr/local/bin/
|
||||
COPY --from=ethgen /apps /apps
|
||||
RUN cd /apps/el-gen && pip3 install -r requirements.txt
|
||||
# web3==5.24.0 used by el-gen is broken on python 3.11
|
||||
RUN pip3 install --upgrade "web3==6.5.0"
|
||||
|
||||
# Build genesis config
|
||||
RUN apk add --no-cache make bash envsubst jq
|
||||
RUN cd /opt/genesis && make genesis-el
|
||||
|
||||
# Snag the genesis block info.
|
||||
RUN go install github.com/cerc-io/eth-dump-genblock@latest
|
||||
RUN eth-dump-genblock /opt/genesis/build/el/geth.json > /opt/genesis/build/el/genesis_block.json
|
||||
|
||||
FROM alpine:latest
|
||||
|
||||
COPY --from=builder /opt/genesis /opt/genesis
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
# Build cerc/fixturenet-eth-genesis
|
||||
|
||||
source ${CERC_CONTAINER_BASE_DIR}/build-base.sh
|
||||
|
||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
|
||||
docker build -t cerc/fixturenet-eth-genesis:local -f ${SCRIPT_DIR}/Dockerfile ${build_command_args} $SCRIPT_DIR
|
||||
@@ -0,0 +1,13 @@
|
||||
.PHONY: build
|
||||
build: genesis
|
||||
|
||||
.PHONY: genesis
|
||||
genesis: genesis-el
|
||||
|
||||
.PHONY: genesis-el
|
||||
genesis-el:
|
||||
cd el; ./build_el.sh
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -rf build
|
||||
Executable
+17
@@ -0,0 +1,17 @@
|
||||
#!/bin/sh
|
||||
|
||||
ACCOUNT_PASSWORD=${ACCOUNT_PASSWORD:-secret1212}
|
||||
|
||||
for line in `cat ../build/el/accounts.csv`; do
|
||||
BIP44_PATH="`echo "$line" | cut -d',' -f1`"
|
||||
ADDRESS="`echo "$line" | cut -d',' -f2`"
|
||||
PRIVATE_KEY="`echo "$line" | cut -d',' -f3`"
|
||||
|
||||
echo "$ACCOUNT_PASSWORD" > .pw.$$
|
||||
echo "$PRIVATE_KEY" | sed 's/0x//' > .key.$$
|
||||
|
||||
echo ""
|
||||
echo "$ADDRESS"
|
||||
geth account import --datadir=~/ethdata --password .pw.$$ .key.$$
|
||||
rm -f .pw.$$ .key.$$
|
||||
done
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
from web3.auto import w3
|
||||
import ruamel.yaml as yaml
|
||||
import sys
|
||||
|
||||
w3.eth.account.enable_unaudited_hdwallet_features()
|
||||
|
||||
testnet_config_path = "genesis-config.yaml"
|
||||
if len(sys.argv) > 1:
|
||||
testnet_config_path = sys.argv[1]
|
||||
|
||||
with open(testnet_config_path) as stream:
|
||||
data = yaml.safe_load(stream)
|
||||
|
||||
for key, value in data['el_premine'].items():
|
||||
acct = w3.eth.account.from_mnemonic(data['mnemonic'], account_path=key, passphrase='')
|
||||
print("%s,%s,%s" % (key, acct.address, acct.key.hex()))
|
||||
Executable
+40
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
# See: https://github.com/skylenet/ethereum-genesis-generator/blob/master/entrypoint.sh
|
||||
|
||||
rm -rf ../build/el
|
||||
mkdir -p ../build/el
|
||||
|
||||
tmp_dir=$(mktemp -d -t ci-XXXXXXXXXX)
|
||||
envsubst < el-config.yaml > $tmp_dir/genesis-config.yaml
|
||||
|
||||
ttd=`cat $tmp_dir/genesis-config.yaml | grep terminal_total_difficulty | awk '{ print $2 }'`
|
||||
homestead_block=`cat $tmp_dir/genesis-config.yaml | grep homestead_block | awk '{ print $2 }'`
|
||||
eip150_block=`cat $tmp_dir/genesis-config.yaml | grep eip150_block | awk '{ print $2 }'`
|
||||
eip155_block=`cat $tmp_dir/genesis-config.yaml | grep eip155_block | awk '{ print $2 }'`
|
||||
eip158_block=`cat $tmp_dir/genesis-config.yaml | grep eip158_block | awk '{ print $2 }'`
|
||||
byzantium_block=`cat $tmp_dir/genesis-config.yaml | grep byzantium_block | awk '{ print $2 }'`
|
||||
constantinople_block=`cat $tmp_dir/genesis-config.yaml | grep constantinople_block | awk '{ print $2 }'`
|
||||
petersburg_block=`cat $tmp_dir/genesis-config.yaml | grep petersburg_block | awk '{ print $2 }'`
|
||||
istanbul_block=`cat $tmp_dir/genesis-config.yaml | grep istanbul_block | awk '{ print $2 }'`
|
||||
berlin_block=`cat $tmp_dir/genesis-config.yaml | grep berlin_block | awk '{ print $2 }'`
|
||||
london_block=`cat $tmp_dir/genesis-config.yaml | grep london_block | awk '{ print $2 }'`
|
||||
merge_fork_block=`cat $tmp_dir/genesis-config.yaml | grep merge_fork_block | awk '{ print $2 }'`
|
||||
|
||||
python3 /apps/el-gen/genesis_geth.py $tmp_dir/genesis-config.yaml | \
|
||||
jq ".config.terminalTotalDifficulty=$ttd" | \
|
||||
jq ".config.homesteadBlock=$homestead_block" | \
|
||||
jq ".config.eip150Block=$eip150_block" | \
|
||||
jq ".config.eip155Block=$eip155_block" | \
|
||||
jq ".config.eip158Block=$eip158_block" | \
|
||||
jq ".config.byzantiumBlock=$byzantium_block" | \
|
||||
jq ".config.constantinopleBlock=$constantinople_block" | \
|
||||
jq ".config.petersburgBlock=$petersburg_block" | \
|
||||
jq ".config.istanbulBlock=$istanbul_block" | \
|
||||
jq ".config.berlinBlock=$berlin_block" | \
|
||||
jq ".config.londonBlock=$london_block" | \
|
||||
jq ".config.mergeForkBlock=$merge_fork_block" | \
|
||||
jq ".config.mergeNetsplitBlock=$merge_fork_block" \
|
||||
> ../build/el/geth.json
|
||||
python3 ../accounts/mnemonic_to_csv.py $tmp_dir/genesis-config.yaml > ../build/el/accounts.csv
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
mnemonic: "viable ketchup woman library opinion copy rhythm attend rose knock penalty practice photo bundle budget dentist enter round bind holiday useful arch danger lobster"
|
||||
el_premine:
|
||||
"m/44'/60'/0'/0/0": 10000000ETH
|
||||
"m/44'/60'/0'/0/1": 10000000ETH
|
||||
"m/44'/60'/0'/0/2": 10000000ETH
|
||||
"m/44'/60'/0'/0/3": 10000000ETH
|
||||
"m/44'/60'/0'/0/4": 10000000ETH
|
||||
"m/44'/60'/0'/0/5": 10000000ETH
|
||||
el_premine_addrs: {}
|
||||
chain_id: 1212
|
||||
deposit_contract_address: "0x1212121212121212121212121212121212121212"
|
||||
genesis_timestamp: 0
|
||||
terminal_total_difficulty: 1000
|
||||
homestead_block: 1
|
||||
eip150_block: 1
|
||||
eip155_block: 1
|
||||
eip158_block: 1
|
||||
byzantium_block: 1
|
||||
constantinople_block: 1
|
||||
petersburg_block: 1
|
||||
istanbul_block: 1
|
||||
berlin_block: 1
|
||||
london_block: 1
|
||||
merge_fork_block: 1
|
||||
|
||||
clique:
|
||||
enabled: false
|
||||
signers:
|
||||
- 36d56343bc308d4ffaac2f793d121aba905fa6cc
|
||||
- 5e762d4a3847cadaf40a4b0c39574b0ff6698c78
|
||||
- 15d7acc1019fdf8ab4f0f7bd31ec1487ecb5a2bd
|
||||
@@ -0,0 +1,21 @@
|
||||
FROM cerc/fixturenet-eth-genesis:local as fnetgen
|
||||
FROM cerc/go-ethereum:local as geth
|
||||
|
||||
# Using the same golang image as used to build geth: https://github.com/cerc-io/go-ethereum/blob/HEAD/Dockerfile
|
||||
FROM golang:1.20-alpine as delve
|
||||
RUN go install github.com/go-delve/delve/cmd/dlv@latest
|
||||
|
||||
FROM alpine:3.17
|
||||
|
||||
RUN apk add --no-cache bash wget python3 bind-tools postgresql-client
|
||||
|
||||
COPY run-el.sh /opt/testnet/run.sh
|
||||
|
||||
COPY --from=delve /go/bin/dlv /usr/local/bin/
|
||||
COPY --from=geth /usr/local/bin/geth /usr/local/bin/
|
||||
COPY --from=fnetgen /opt/genesis /opt/testnet
|
||||
|
||||
# Initialize the geth db with our config
|
||||
RUN geth --datadir ~/ethdata init /opt/testnet/build/el/geth.json && rm -f ~/ethdata/geth/nodekey
|
||||
|
||||
ENTRYPOINT ["/opt/testnet/run.sh"]
|
||||
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
# Build cerc/fixturenet-eth-geth
|
||||
|
||||
source ${CERC_CONTAINER_BASE_DIR}/build-base.sh
|
||||
|
||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
|
||||
docker build -t cerc/fixturenet-eth-geth:local -f ${SCRIPT_DIR}/Dockerfile ${build_command_args} $SCRIPT_DIR
|
||||
+147
@@ -0,0 +1,147 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
|
||||
set -x
|
||||
fi
|
||||
|
||||
ETHERBASE=`cat /opt/testnet/build/el/accounts.csv | head -1 | cut -d',' -f2`
|
||||
NETWORK_ID=`cat /opt/testnet/el/el-config.yaml | grep 'chain_id' | awk '{ print $2 }'`
|
||||
NETRESTRICT=`ip addr | grep inet | grep -v '127.0' | awk '{print $2}'`
|
||||
CERC_ETH_DATADIR="${CERC_ETH_DATADIR:-$HOME/ethdata}"
|
||||
CERC_PLUGINS_DIR="${CERC_PLUGINS_DIR:-/usr/local/lib/plugeth}"
|
||||
|
||||
cd /opt/testnet/build/el
|
||||
python3 -m http.server 9898 &
|
||||
cd $HOME
|
||||
|
||||
START_CMD="geth"
|
||||
if [ "true" == "$CERC_REMOTE_DEBUG" ] && [ -x "/usr/local/bin/dlv" ]; then
|
||||
START_CMD="/usr/local/bin/dlv --listen=:40000 --headless=true --api-version=2 --accept-multiclient exec /usr/local/bin/geth --continue --"
|
||||
fi
|
||||
|
||||
# See https://linuxconfig.org/how-to-propagate-a-signal-to-child-processes-from-a-bash-script
|
||||
cleanup() {
|
||||
echo "Signal received, cleaning up..."
|
||||
|
||||
# Kill the child process first (CERC_REMOTE_DEBUG=true uses dlv which starts geth as a child process)
|
||||
pkill -P ${geth_pid}
|
||||
sleep 2
|
||||
kill $(jobs -p)
|
||||
|
||||
wait
|
||||
echo "Done"
|
||||
}
|
||||
trap 'cleanup' SIGINT SIGTERM
|
||||
|
||||
if [ "true" == "$RUN_BOOTNODE" ]; then
|
||||
$START_CMD \
|
||||
--datadir="${CERC_ETH_DATADIR}" \
|
||||
--nodekeyhex="${BOOTNODE_KEY}" \
|
||||
--nodiscover \
|
||||
--ipcdisable \
|
||||
--networkid=${NETWORK_ID} \
|
||||
--netrestrict="${NETRESTRICT}" \
|
||||
&
|
||||
|
||||
geth_pid=$!
|
||||
else
|
||||
cd /opt/testnet/accounts
|
||||
./import_keys.sh
|
||||
|
||||
echo -n "$JWT" > /opt/testnet/build/el/jwtsecret
|
||||
|
||||
if [ "$CERC_RUN_STATEDIFF" == "detect" ] && [ -n "$CERC_STATEDIFF_DB_HOST" ]; then
|
||||
dig_result=$(dig $CERC_STATEDIFF_DB_HOST +short)
|
||||
dig_status_code=$?
|
||||
if [[ $dig_status_code = 0 && -n $dig_result ]]; then
|
||||
echo "Statediff DB at $CERC_STATEDIFF_DB_HOST"
|
||||
CERC_RUN_STATEDIFF="true"
|
||||
else
|
||||
echo "No statediff DB available."
|
||||
CERC_RUN_STATEDIFF="false"
|
||||
fi
|
||||
fi
|
||||
|
||||
STATEDIFF_OPTS=""
|
||||
if [ "$CERC_RUN_STATEDIFF" == "true" ]; then
|
||||
ready=0
|
||||
echo "Waiting for statediff DB..."
|
||||
while [ $ready -eq 0 ]; do
|
||||
sleep 1
|
||||
export PGPASSWORD="$CERC_STATEDIFF_DB_PASSWORD"
|
||||
result=$(psql -h "$CERC_STATEDIFF_DB_HOST" \
|
||||
-p "$CERC_STATEDIFF_DB_PORT" \
|
||||
-U "$CERC_STATEDIFF_DB_USER" \
|
||||
-d "$CERC_STATEDIFF_DB_NAME" \
|
||||
-t -c 'select max(version_id) from goose_db_version;' 2>/dev/null | awk '{ print $1 }')
|
||||
if [ -n "$result" ]; then
|
||||
echo "DB ready..."
|
||||
if [ $result -ge $CERC_STATEDIFF_DB_GOOSE_MIN_VER ]; then
|
||||
ready=1
|
||||
else
|
||||
echo "DB not at required version (want $CERC_STATEDIFF_DB_GOOSE_MIN_VER, have $result)"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
STATEDIFF_OPTS="--statediff \
|
||||
--statediff.db.host=$CERC_STATEDIFF_DB_HOST \
|
||||
--statediff.db.name=$CERC_STATEDIFF_DB_NAME \
|
||||
--statediff.db.nodeid=$CERC_STATEDIFF_DB_NODE_ID \
|
||||
--statediff.db.password=$CERC_STATEDIFF_DB_PASSWORD \
|
||||
--statediff.db.port=$CERC_STATEDIFF_DB_PORT \
|
||||
--statediff.db.user=$CERC_STATEDIFF_DB_USER \
|
||||
--statediff.db.logstatements=${CERC_STATEDIFF_DB_LOG_STATEMENTS:-false} \
|
||||
--statediff.db.copyfrom=${CERC_STATEDIFF_DB_COPY_FROM:-true} \
|
||||
--statediff.waitforsync=true \
|
||||
--statediff.workers=${CERC_STATEDIFF_WORKERS:-1} \
|
||||
--statediff.writing=true"
|
||||
|
||||
if [ -d "${CERC_PLUGINS_DIR}" ]; then
|
||||
# With plugeth, we separate the statediff options by prefixing with ' -- '
|
||||
STATEDIFF_OPTS="--pluginsdir "${CERC_PLUGINS_DIR}" -- ${STATEDIFF_OPTS}"
|
||||
fi
|
||||
fi
|
||||
|
||||
$START_CMD \
|
||||
--datadir="${CERC_ETH_DATADIR}" \
|
||||
--bootnodes="${ENODE}" \
|
||||
--allow-insecure-unlock \
|
||||
--http \
|
||||
--http.addr="0.0.0.0" \
|
||||
--http.vhosts="*" \
|
||||
--http.api="${CERC_GETH_HTTP_APIS:-eth,web3,net,admin,personal,debug,statediff}" \
|
||||
--http.corsdomain="*" \
|
||||
--authrpc.addr="0.0.0.0" \
|
||||
--authrpc.vhosts="*" \
|
||||
--authrpc.jwtsecret="/opt/testnet/build/el/jwtsecret" \
|
||||
--ws \
|
||||
--ws.addr="0.0.0.0" \
|
||||
--ws.origins="*" \
|
||||
--ws.api="${CERC_GETH_WS_APIS:-eth,web3,net,admin,personal,debug,statediff}" \
|
||||
--http.corsdomain="*" \
|
||||
--networkid="${NETWORK_ID}" \
|
||||
--netrestrict="${NETRESTRICT}" \
|
||||
--gcmode archive \
|
||||
--txlookuplimit=0 \
|
||||
--cache.preimages \
|
||||
--syncmode=full \
|
||||
--mine \
|
||||
--miner.threads=1 \
|
||||
--metrics \
|
||||
--metrics.addr="0.0.0.0" \
|
||||
--verbosity=${CERC_GETH_VERBOSITY:-3} \
|
||||
--log.vmodule="${CERC_GETH_VMODULE:-statediff/*=5}" \
|
||||
--miner.etherbase="${ETHERBASE}" \
|
||||
${STATEDIFF_OPTS} \
|
||||
&
|
||||
|
||||
geth_pid=$!
|
||||
fi
|
||||
|
||||
wait $geth_pid
|
||||
|
||||
if [ "true" == "$CERC_KEEP_RUNNING_AFTER_GETH_EXIT" ]; then
|
||||
while [ 1 -eq 1 ]; do
|
||||
sleep 60
|
||||
done
|
||||
fi
|
||||
@@ -0,0 +1,34 @@
|
||||
FROM cerc/lighthouse-cli:local AS lcli
|
||||
FROM skylenet/ethereum-genesis-generator@sha256:210353ce7c898686bc5092f16c61220a76d357f51eff9c451e9ad1b9ad03d4d3 AS ethgen
|
||||
FROM cerc/fixturenet-eth-genesis:local AS fnetgen
|
||||
|
||||
FROM cerc/lighthouse:local
|
||||
|
||||
# cerc/lighthouse is based on Ubuntu
|
||||
RUN apt-get update && apt-get -y upgrade && apt-get install -y --no-install-recommends \
|
||||
libssl-dev ca-certificates \
|
||||
curl socat iproute2 telnet wget jq \
|
||||
build-essential python3 python3-dev python3-pip gettext-base \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY genesis /opt/testnet
|
||||
COPY run-cl.sh /opt/testnet/run.sh
|
||||
|
||||
COPY --from=lcli /usr/local/bin/lcli /usr/local/bin/lcli
|
||||
COPY --from=ethgen /usr/local/bin/eth2-testnet-genesis /usr/local/bin/eth2-testnet-genesis
|
||||
COPY --from=ethgen /usr/local/bin/eth2-val-tools /usr/local/bin/eth2-val-tools
|
||||
COPY --from=ethgen /apps /apps
|
||||
COPY --from=fnetgen /opt/genesis/el /opt/testnet/el
|
||||
COPY --from=fnetgen /opt/genesis/build/el /opt/testnet/build/el
|
||||
|
||||
RUN cd /opt/testnet && make genesis-cl
|
||||
|
||||
# Work around some bugs in lcli where the default path is always used.
|
||||
RUN mkdir -p /root/.lighthouse && cd /root/.lighthouse && ln -s /opt/testnet/build/cl/testnet
|
||||
|
||||
RUN mkdir -p /scripts
|
||||
COPY scripts/status-internal.sh /scripts
|
||||
COPY scripts/status.sh /scripts
|
||||
|
||||
ENTRYPOINT ["/opt/testnet/run.sh"]
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
# Build cerc/fixturenet-eth-lighthouse
|
||||
|
||||
source ${CERC_CONTAINER_BASE_DIR}/build-base.sh
|
||||
|
||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
|
||||
docker build -t cerc/fixturenet-eth-lighthouse:local -f ${SCRIPT_DIR}/Dockerfile ${build_command_args} $SCRIPT_DIR
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
.PHONY: build
|
||||
build: genesis
|
||||
|
||||
.PHONY: genesis
|
||||
genesis: genesis-cl
|
||||
|
||||
.PHONY: genesis-cl
|
||||
genesis-cl:
|
||||
cd cl; ./build_cl.sh
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -rf build
|
||||
Executable
+42
@@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# See: https://github.com/sigp/lighthouse/blob/stable/scripts/local_testnet/beacon_node.sh
|
||||
#
|
||||
# Starts a beacon node based upon a genesis state created by `./setup.sh`.
|
||||
#
|
||||
|
||||
set -Eeuo pipefail
|
||||
|
||||
source ./vars.env
|
||||
|
||||
SUBSCRIBE_ALL_SUBNETS=
|
||||
DEBUG_LEVEL=${DEBUG_LEVEL:-debug}
|
||||
|
||||
# Get positional arguments
|
||||
data_dir=$DATADIR/node_${NODE_NUMBER}
|
||||
network_port=9001
|
||||
http_port=8001
|
||||
authrpc_port=8551
|
||||
|
||||
exec lighthouse \
|
||||
bn \
|
||||
$SUBSCRIBE_ALL_SUBNETS \
|
||||
--debug-level $DEBUG_LEVEL \
|
||||
--boot-nodes "$ENR" \
|
||||
--datadir $data_dir \
|
||||
--testnet-dir $TESTNET_DIR \
|
||||
--enable-private-discovery \
|
||||
--staking \
|
||||
--enr-address $ENR_IP \
|
||||
--enr-udp-port $network_port \
|
||||
--enr-tcp-port $network_port \
|
||||
--port $network_port \
|
||||
--http-address 0.0.0.0 \
|
||||
--http-port $http_port \
|
||||
--disable-packet-filter \
|
||||
--execution-endpoint $EXECUTION_ENDPOINT \
|
||||
--execution-jwt $JWTSECRET \
|
||||
--terminal-total-difficulty-override $ETH1_TTD \
|
||||
--suggested-fee-recipient $SUGGESTED_FEE_RECIPIENT \
|
||||
--target-peers $((BN_COUNT - 1)) \
|
||||
--http-allow-sync-stalled \
|
||||
Executable
+41
@@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# See: https://github.com/sigp/lighthouse/blob/stable/scripts/local_testnet/bootnode.sh
|
||||
#
|
||||
# Starts a bootnode from the generated enr.
|
||||
#
|
||||
|
||||
set -Eeuo pipefail
|
||||
|
||||
source ./vars.env
|
||||
|
||||
DEBUG_LEVEL=${1:-info}
|
||||
|
||||
echo "Starting bootnode"
|
||||
|
||||
# Clean up existing ENR dir to avoid node connectivity issues on a restart
|
||||
if [ -d "$DATADIR/bootnode" ]; then
|
||||
echo "Removing existing bootnode enr directory"
|
||||
rm -r "$DATADIR/bootnode"
|
||||
fi
|
||||
|
||||
echo "Generating bootnode enr"
|
||||
lcli \
|
||||
generate-bootnode-enr \
|
||||
--ip $ENR_IP \
|
||||
--udp-port $BOOTNODE_PORT \
|
||||
--tcp-port $BOOTNODE_PORT \
|
||||
--genesis-fork-version $GENESIS_FORK_VERSION \
|
||||
--output-dir $DATADIR/bootnode
|
||||
|
||||
bootnode_enr=`cat $DATADIR/bootnode/enr.dat`
|
||||
echo "- $bootnode_enr" > $TESTNET_DIR/boot_enr.yaml
|
||||
|
||||
echo "Generated bootnode enr and written to $TESTNET_DIR/boot_enr.yaml"
|
||||
|
||||
exec lighthouse boot_node \
|
||||
--testnet-dir $TESTNET_DIR \
|
||||
--port $BOOTNODE_PORT \
|
||||
--listen-address 0.0.0.0 \
|
||||
--disable-packet-filter \
|
||||
--network-dir $DATADIR/bootnode \
|
||||
Executable
+62
@@ -0,0 +1,62 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
#
|
||||
# Deploys the deposit contract and makes deposits for $VALIDATOR_COUNT insecure deterministic validators.
|
||||
# Produces a testnet specification and a genesis state where the genesis time
|
||||
# is now + $GENESIS_DELAY.
|
||||
#
|
||||
# Generates datadirs for multiple validator keys according to the
|
||||
# $VALIDATOR_COUNT and $BN_COUNT variables.
|
||||
#
|
||||
|
||||
set -o nounset -o errexit -o pipefail
|
||||
|
||||
source ./vars.env
|
||||
|
||||
rm -rf $DATADIR
|
||||
mkdir -p $DATADIR
|
||||
|
||||
NOW=`date +%s`
|
||||
GENESIS_TIME=`expr $NOW + $GENESIS_DELAY`
|
||||
|
||||
echo "Creating testnet ..."
|
||||
echo "(Note: errors of the form 'WARN: Scrypt parameters are too weak...' below can be safely ignored)"
|
||||
lcli \
|
||||
new-testnet \
|
||||
--spec $SPEC_PRESET \
|
||||
--deposit-contract-address $ETH1_DEPOSIT_CONTRACT_ADDRESS \
|
||||
--testnet-dir $TESTNET_DIR \
|
||||
--min-genesis-active-validator-count $GENESIS_VALIDATOR_COUNT \
|
||||
--validator-count $VALIDATOR_COUNT \
|
||||
--min-genesis-time $GENESIS_TIME \
|
||||
--genesis-delay $GENESIS_DELAY \
|
||||
--genesis-fork-version $GENESIS_FORK_VERSION \
|
||||
--altair-fork-epoch $ALTAIR_FORK_EPOCH \
|
||||
--bellatrix-fork-epoch $MERGE_FORK_EPOCH \
|
||||
--eth1-id $ETH1_CHAIN_ID \
|
||||
--eth1-block-hash $ETH1_BLOCK_HASH \
|
||||
--eth1-follow-distance 1 \
|
||||
--seconds-per-slot $SECONDS_PER_SLOT \
|
||||
--seconds-per-eth1-block $SECONDS_PER_ETH1_BLOCK \
|
||||
--force
|
||||
|
||||
echo Specification generated at $TESTNET_DIR.
|
||||
echo "Generating $VALIDATOR_COUNT validators concurrently... (this may take a while)"
|
||||
|
||||
lcli \
|
||||
insecure-validators \
|
||||
--count $VALIDATOR_COUNT \
|
||||
--base-dir $DATADIR \
|
||||
--node-count $BN_COUNT
|
||||
|
||||
echo Validators generated with keystore passwords at $DATADIR.
|
||||
echo "Building genesis state... (this might take a while)"
|
||||
|
||||
lcli \
|
||||
interop-genesis \
|
||||
--spec $SPEC_PRESET \
|
||||
--genesis-time $GENESIS_TIME \
|
||||
--testnet-dir $TESTNET_DIR \
|
||||
$GENESIS_VALIDATOR_COUNT
|
||||
|
||||
echo Created genesis state in $TESTNET_DIR
|
||||
Executable
+10
@@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
|
||||
LIGHTHOUSE_BASE_URL=http://localhost:8001
|
||||
|
||||
result=`wget --no-check-certificate --quiet -O - "$LIGHTHOUSE_BASE_URL/eth/v2/beacon/blocks/head" | jq -r '.data.message.body.execution_payload.block_number'`
|
||||
if [ ! -z "$result" ] && [ $result -gt 0 ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
exit 1
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
# See: https://github.com/sigp/lighthouse/blob/stable/scripts/local_testnet/reset_genesis_time.sh
|
||||
#
|
||||
# Resets the beacon state genesis time to now.
|
||||
#
|
||||
|
||||
set -Eeuo pipefail
|
||||
|
||||
source ./vars.env
|
||||
|
||||
NOW=${1:-`date +%s`}
|
||||
|
||||
lcli \
|
||||
change-genesis-time \
|
||||
--testnet-dir $TESTNET_DIR \
|
||||
$TESTNET_DIR/genesis.ssz \
|
||||
$NOW
|
||||
|
||||
echo "Reset genesis time to ($NOW)"
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# See: https://github.com/sigp/lighthouse/blob/stable/scripts/local_testnet/validator_client.sh
|
||||
#
|
||||
# Usage: ./validator_client.sh <DATADIR> <BEACON-NODE-HTTP> <OPTIONAL-DEBUG-LEVEL>
|
||||
|
||||
set -Eeuo pipefail
|
||||
|
||||
source ./vars.env
|
||||
|
||||
DEBUG_LEVEL=info
|
||||
|
||||
BUILDER_PROPOSALS=
|
||||
|
||||
# Get options
|
||||
while getopts "pd:" flag; do
|
||||
case "${flag}" in
|
||||
p) BUILDER_PROPOSALS="--builder-proposals";;
|
||||
d) DEBUG_LEVEL=${OPTARG};;
|
||||
esac
|
||||
done
|
||||
|
||||
exec lighthouse \
|
||||
vc \
|
||||
$BUILDER_PROPOSALS \
|
||||
--debug-level $DEBUG_LEVEL \
|
||||
--validators-dir $DATADIR/node_$NODE_NUMBER/validators \
|
||||
--secrets-dir $DATADIR/node_$NODE_NUMBER/secrets \
|
||||
--testnet-dir $TESTNET_DIR \
|
||||
--init-slashing-protection \
|
||||
--beacon-nodes http://localhost:8001 \
|
||||
--suggested-fee-recipient $SUGGESTED_FEE_RECIPIENT \
|
||||
$VC_ARGS
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
# Base directories for the validator keys and secrets
|
||||
DATADIR=${DATADIR:-../build/cl}
|
||||
|
||||
# Directory for the eth2 config
|
||||
TESTNET_DIR=${TESTNET_DIR:-$DATADIR/testnet}
|
||||
JWTSECRET=${JWTSECRET:-$DATADIR/jwtsecret}
|
||||
ENR=${ENR:="SET_AT_RUNTIME"}
|
||||
ENR_IP=`ip addr | grep inet | grep -v '127.0.0.1' | sort | head -1 | awk '{print $2}' | cut -d '/' -f1`
|
||||
|
||||
GENESIS_FORK_VERSION=${GENESIS_FORK_VERSION:-0x12121212}
|
||||
|
||||
VALIDATOR_COUNT=${VALIDATOR_COUNT:-80}
|
||||
GENESIS_VALIDATOR_COUNT=${GENESIS_VALIDATOR_COUNT:-80}
|
||||
|
||||
# Number of beacon_node instances that you intend to run
|
||||
BN_COUNT=${BN_COUNT:-2}
|
||||
|
||||
# Number of seconds to delay to start genesis block.
|
||||
# If started by a script this can be 0, if starting by hand
|
||||
# use something like 180.
|
||||
GENESIS_DELAY=${GENESIS_DELAY:-0}
|
||||
|
||||
# Port for P2P communication with bootnode
|
||||
BOOTNODE_PORT=${BOOTNODE_PORT:-4242}
|
||||
|
||||
# Hard fork configuration
|
||||
ALTAIR_FORK_EPOCH=${ALTAIR_FORK_EPOCH:-0}
|
||||
MERGE_FORK_EPOCH=${MERGE_FORK_EPOCH:-0}
|
||||
|
||||
# Spec version (mainnet or minimal)
|
||||
SPEC_PRESET=${SPEC_PRESET:-mainnet}
|
||||
|
||||
# Seconds per Eth2 slot
|
||||
SECONDS_PER_SLOT=${SECONDS_PER_SLOT:-3}
|
||||
|
||||
# Seconds per Eth1 block
|
||||
SECONDS_PER_ETH1_BLOCK=${SECONDS_PER_ETH1_BLOCK:-1}
|
||||
|
||||
# Command line arguments for validator client
|
||||
VC_ARGS=${VC_ARGS:-""}
|
||||
|
||||
EXECUTION_ENDPOINT=${EXECUTION_ENDPOINT:-http://localhost:8551}
|
||||
|
||||
ETH1_GENESIS_JSON=${ETH1_GENESIS_JSON:-"../build/el/geth.json"}
|
||||
ETH1_GENESIS_BLOCK_JSON=${ETH1_GENESIS_BLOCK_JSON:-"../build/el/genesis_block.json"}
|
||||
ETH1_CONFIG_YAML=${ETH1_CONFIG_YAML:-"../el/el-config.yaml"}
|
||||
ETH1_BLOCK_HASH=${ETH1_BLOCK_HASH:-`cat $ETH1_GENESIS_BLOCK_JSON | jq -r '.hash' | cut -d'x' -f2`}
|
||||
|
||||
ETH1_CHAIN_ID=${ETH1_CHAIN_ID:-`cat $ETH1_GENESIS_JSON | jq -r '.config.chainId'`}
|
||||
ETH1_TTD=${ETH1_TTD:-`cat $ETH1_GENESIS_JSON | jq -r '.config.terminalTotalDifficulty'`}
|
||||
ETH1_DEPOSIT_CONTRACT_ADDRESS=${ETH1_DEPOSIT_CONTRACT_ADDRESS:-`cat $ETH1_CONFIG_YAML | grep 'deposit_contract_address' | awk '{ print $2 }' | sed 's/"//g'`}
|
||||
ETH1_DEPOSIT_CONTRACT_BLOCK=${ETH1_DEPOSIT_CONTRACT_BLOCK:-0x0}
|
||||
SUGGESTED_FEE_RECIPIENT=`cat ../build/el/accounts.csv | head -1 | cut -d',' -f2`
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
#!/bin/bash
|
||||
|
||||
# See https://linuxconfig.org/how-to-propagate-a-signal-to-child-processes-from-a-bash-script
|
||||
cleanup() {
|
||||
echo "Signal received, cleaning up..."
|
||||
kill $(jobs -p)
|
||||
|
||||
wait
|
||||
echo "Done"
|
||||
}
|
||||
trap 'cleanup' SIGINT SIGTERM
|
||||
|
||||
if [ "true" == "$RUN_BOOTNODE" ]; then
|
||||
cd /opt/testnet/build/cl
|
||||
python3 -m http.server 3000 &
|
||||
|
||||
|
||||
cd /opt/testnet/cl
|
||||
./bootnode.sh 2>&1 | tee /var/log/lighthouse_bootnode.log &
|
||||
bootnode_pid=$!
|
||||
|
||||
wait $bootnode_pid
|
||||
else
|
||||
while [ 1 -eq 1 ]; do
|
||||
echo "Waiting on geth ..."
|
||||
sleep 5
|
||||
result=`wget --no-check-certificate --quiet \
|
||||
-O - \
|
||||
--method POST \
|
||||
--timeout=0 \
|
||||
--header 'Content-Type: application/json' \
|
||||
--body-data '{ "jsonrpc": "2.0", "id": 1, "method": "eth_blockNumber", "params": [] }' "${ETH1_ENDPOINT:-localhost:8545}" | jq -r '.result'`
|
||||
if [ ! -z "$result" ] && [ "null" != "$result" ]; then
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
cd /opt/testnet/cl
|
||||
|
||||
if [ -z "$LIGHTHOUSE_GENESIS_STATE_URL" ]; then
|
||||
# Check if beacon node data exists to avoid resetting genesis time on a restart
|
||||
if [ -d /opt/testnet/build/cl/node_"$NODE_NUMBER"/beacon ]; then
|
||||
echo "Skipping genesis time reset"
|
||||
else
|
||||
./reset_genesis_time.sh
|
||||
fi
|
||||
else
|
||||
while [ 1 -eq 1 ]; do
|
||||
echo "Waiting on Genesis time ..."
|
||||
sleep 5
|
||||
result=`wget --no-check-certificate --quiet -O - --timeout=0 $LIGHTHOUSE_GENESIS_STATE_URL | jq -r '.data.genesis_time'`
|
||||
if [ ! -z "$result" ]; then
|
||||
./reset_genesis_time.sh $result
|
||||
break;
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
if [ ! -z "$ENR_URL" ]; then
|
||||
while [ 1 -eq 1 ]; do
|
||||
echo "Waiting on ENR for boot node..."
|
||||
sleep 5
|
||||
result=`wget --no-check-certificate --quiet -O - --timeout=0 $ENR_URL`
|
||||
if [ ! -z "$result" ]; then
|
||||
export ENR="$result"
|
||||
break;
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
export JWTSECRET="/opt/testnet/build/cl/jwtsecret"
|
||||
echo -n "$JWT" > $JWTSECRET
|
||||
|
||||
./beacon_node.sh 2>&1 | tee /var/log/lighthouse_bn.log &
|
||||
beacon_pid=$!
|
||||
./validator_client.sh 2>&1 | tee /var/log/lighthouse_vc.log &
|
||||
validator_pid=$!
|
||||
|
||||
wait $beacon_pid $validator_pid
|
||||
fi
|
||||
Executable
+50
@@ -0,0 +1,50 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Exports the complete fixturenet-eth ethdb data to a tarball (default, ./ethdb.tgz), waiting for a minimum
|
||||
# block height (default 1000) to be reached before exporting.
|
||||
|
||||
# Usage: export-ethdb.sh [min_block_number=1000] [output_file=./ethdb.tgz]
|
||||
|
||||
if [[ -n "$CERC_SCRIPT_DEBUG" ]]; then
|
||||
set -x
|
||||
fi
|
||||
|
||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
|
||||
GETH_EXPORT_MIN_BLOCK=${1:-${GETH_EXPORT_MIN_BLOCK:-1000}}
|
||||
|
||||
# Wait for block.
|
||||
${SCRIPT_DIR}/status.sh $GETH_EXPORT_MIN_BLOCK
|
||||
if [[ $? -ne 0 ]]; then
|
||||
echo "Unable to export ethdb." 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
GETH_CONTAINER=`docker ps -q -f "name=${CERC_SO_COMPOSE_PROJECT}-fixturenet-eth-geth-2-1"`
|
||||
if [[ -z "$GETH_CONTAINER" ]]; then
|
||||
echo "not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Make sure we have the necessary tools
|
||||
docker exec $GETH_CONTAINER sh -c 'apk add --no-cache jq curl'
|
||||
|
||||
# Gather metadata.
|
||||
docker exec $GETH_CONTAINER sh -c 'rm -rf /root/tmp && mkdir -p /root/tmp/export'
|
||||
docker exec $GETH_CONTAINER sh -c 'ln -s /opt/testnet/build/el/geth.json /root/tmp/export/genesis.json && ln -s /root/ethdata /root/tmp/export/'
|
||||
docker exec $GETH_CONTAINER sh -c 'cat /root/tmp/export/genesis.json | jq ".config" > /root/tmp/export/genesis.config.json'
|
||||
docker exec $GETH_CONTAINER sh -c 'curl -s --location "localhost:8545" --header "Content-Type: application/json" --data "{\"jsonrpc\": \"2.0\", \"id\": 1, \"method\": \"eth_getBlockByNumber\", \"params\": [\"0x0\", false]}" > /root/tmp/export/eth_getBlockByNumber_0x0.json'
|
||||
docker exec $GETH_CONTAINER sh -c 'curl -s --location "localhost:8545" --header "Content-Type: application/json" --data "{\"jsonrpc\": \"2.0\", \"id\": 1, \"method\": \"eth_blockNumber\", \"params\": []}" > /root/tmp/export/eth_blockNumber.json'
|
||||
|
||||
# Stop geth and zip up ethdb.
|
||||
echo -n "Exporting ethdb.... "
|
||||
docker exec $GETH_CONTAINER sh -c "killall geth && sleep 2 && tar chzf /root/tmp/ethdb.tgz -C /root/tmp/export ."
|
||||
|
||||
# Copy ethdb to host.
|
||||
GETH_EXPORT_FILE=${2:-${GETH_EXPORT_FILE:-./ethdb.tgz}}
|
||||
docker cp $GETH_CONTAINER:/root/tmp/ethdb.tgz $GETH_EXPORT_FILE
|
||||
echo "$GETH_EXPORT_FILE"
|
||||
docker exec $GETH_CONTAINER sh -c "rm -rf /root/tmp"
|
||||
|
||||
# Restart the container to get geth back up and running.
|
||||
docker restart $GETH_CONTAINER >/dev/null
|
||||
Executable
+10
@@ -0,0 +1,10 @@
|
||||
#!/usr/bin/env bash
|
||||
# Wrapper to facilitate using status.sh inside the container
|
||||
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
|
||||
set -x
|
||||
fi
|
||||
export LIGHTHOUSE_BASE_URL="http://fixturenet-eth-lighthouse-1:8001"
|
||||
export GETH_BASE_URL="http://fixturenet-eth-geth-1:8545"
|
||||
# See: https://stackoverflow.com/a/246128/1701505
|
||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
$SCRIPT_DIR/status.sh
|
||||
+97
@@ -0,0 +1,97 @@
|
||||
#!/usr/bin/env bash
|
||||
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
|
||||
set -x
|
||||
fi
|
||||
|
||||
MIN_BLOCK_NUM=${1:-${MIN_BLOCK_NUM:-3}}
|
||||
STATUSES=(
|
||||
"geth to generate DAG"
|
||||
"beacon phase0"
|
||||
"beacon altair"
|
||||
"beacon bellatrix pre-merge"
|
||||
"beacon bellatrix merge"
|
||||
"block number $MIN_BLOCK_NUM"
|
||||
)
|
||||
STATUS=0
|
||||
|
||||
LIGHTHOUSE_BASE_URL=${LIGHTHOUSE_BASE_URL}
|
||||
GETH_BASE_URL=${GETH_BASE_URL}
|
||||
|
||||
# TODO: Docker commands below should be replaced by some interface into stack orchestrator
|
||||
# or some execution environment-neutral mechanism.
|
||||
if [ -z "$LIGHTHOUSE_BASE_URL" ]; then
|
||||
LIGHTHOUSE_CONTAINER=`docker ps -q -f "name=fixturenet-eth-lighthouse-1-1"`
|
||||
if [ -z "$LIGHTHOUSE_CONTAINER" ]; then
|
||||
echo "Lighthouse container not found." 1>&2
|
||||
exit 1
|
||||
fi
|
||||
LIGHTHOUSE_PORT=`docker port $LIGHTHOUSE_CONTAINER 8001 | cut -d':' -f2`
|
||||
LIGHTHOUSE_BASE_URL="http://localhost:${LIGHTHOUSE_PORT}"
|
||||
fi
|
||||
|
||||
if [ -z "$GETH_BASE_URL" ]; then
|
||||
GETH_CONTAINER=`docker ps -q -f "name=fixturenet-eth-geth-1-1"`
|
||||
if [ -z "$GETH_CONTAINER" ]; then
|
||||
echo "Lighthouse container not found." 1>&2
|
||||
exit 1
|
||||
fi
|
||||
GETH_PORT=`docker port $GETH_CONTAINER 8545 | cut -d':' -f2`
|
||||
GETH_BASE_URL="http://localhost:${GETH_PORT}"
|
||||
fi
|
||||
|
||||
MARKER="."
|
||||
|
||||
function inc_status() {
|
||||
echo " done"
|
||||
STATUS=$((STATUS + 1))
|
||||
if [ $STATUS -lt ${#STATUSES[@]} ]; then
|
||||
echo -n "Waiting for ${STATUSES[$STATUS]}..."
|
||||
fi
|
||||
}
|
||||
|
||||
echo -n "Waiting for ${STATUSES[$STATUS]}..."
|
||||
while [ $STATUS -lt ${#STATUSES[@]} ]; do
|
||||
sleep 1
|
||||
echo -n "$MARKER"
|
||||
case $STATUS in
|
||||
0)
|
||||
result=`wget --no-check-certificate --quiet -O - --method POST --header 'Content-Type: application/json' \
|
||||
--body-data '{ "jsonrpc": "2.0", "id": 1, "method": "eth_getBlockByNumber", "params": ["0x3", false] }' $GETH_BASE_URL | jq -r '.result'`
|
||||
if [ ! -z "$result" ] && [ "null" != "$result" ]; then
|
||||
inc_status
|
||||
fi
|
||||
;;
|
||||
1)
|
||||
result=`wget --no-check-certificate --quiet -O - "$LIGHTHOUSE_BASE_URL/eth/v2/beacon/blocks/head" | jq -r '.data.message.slot'`
|
||||
if [ ! -z "$result" ] && [ $result -gt 0 ]; then
|
||||
inc_status
|
||||
fi
|
||||
;;
|
||||
2)
|
||||
result=`wget --no-check-certificate --quiet -O - "$LIGHTHOUSE_BASE_URL/eth/v2/beacon/blocks/head" | jq -r '.version'`
|
||||
if [ ! -z "$result" ] && ([ "$result" == "altair" ] || [ "$result" == "bellatrix" ]); then
|
||||
inc_status
|
||||
fi
|
||||
;;
|
||||
3)
|
||||
result=`wget --no-check-certificate --quiet -O - "$LIGHTHOUSE_BASE_URL/eth/v2/beacon/blocks/head" | jq -r '.version'`
|
||||
if [ ! -z "$result" ] && [ "$result" == "bellatrix" ]; then
|
||||
inc_status
|
||||
fi
|
||||
;;
|
||||
4)
|
||||
result=`wget --no-check-certificate --quiet -O - "$LIGHTHOUSE_BASE_URL/eth/v2/beacon/blocks/head" | jq -r '.data.message.body.execution_payload.block_number'`
|
||||
if [ ! -z "$result" ] && [ $result -gt 0 ]; then
|
||||
inc_status
|
||||
fi
|
||||
;;
|
||||
5)
|
||||
result=`wget --no-check-certificate --quiet -O - "$LIGHTHOUSE_BASE_URL/eth/v2/beacon/blocks/head" | jq -r '.data.message.body.execution_payload.block_number'`
|
||||
if [ ! -z "$result" ] && [ $result -gt $MIN_BLOCK_NUM ]; then
|
||||
inc_status
|
||||
else
|
||||
MARKER="$result "
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
done
|
||||
@@ -0,0 +1,25 @@
|
||||
FROM cerc/fixturenet-eth-genesis:local as fnetgen
|
||||
|
||||
# Using the same golang image as used to build geth: https://github.com/cerc-io/go-ethereum/blob/HEAD/Dockerfile
|
||||
FROM golang:1.20-alpine as delve
|
||||
RUN go install github.com/go-delve/delve/cmd/dlv@latest
|
||||
|
||||
FROM cerc/plugeth-statediff:local as statediff
|
||||
# FIXME: fork of plugeth, use stock after upstreaming patches
|
||||
FROM cerc/plugeth:local as geth
|
||||
|
||||
FROM alpine:3.17
|
||||
|
||||
RUN apk add --no-cache bash wget python3 bind-tools postgresql-client
|
||||
|
||||
COPY run-el.sh /opt/testnet/run.sh
|
||||
|
||||
COPY --from=delve /go/bin/dlv /usr/local/bin/
|
||||
COPY --from=geth /usr/local/bin/geth /usr/local/bin/
|
||||
COPY --from=fnetgen /opt/genesis /opt/testnet
|
||||
COPY --from=statediff /usr/local/lib/statediff.so /usr/local/lib/plugeth/
|
||||
|
||||
# Initialize the geth db with our config
|
||||
RUN geth --datadir ~/ethdata init /opt/testnet/build/el/geth.json && rm -f ~/ethdata/geth/nodekey
|
||||
|
||||
ENTRYPOINT ["/opt/testnet/run.sh"]
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
#!/usr/bin/env bash
|
||||
# Build cerc/fixturenet-plugeth-plugeth
|
||||
set -x
|
||||
|
||||
source ${CERC_CONTAINER_BASE_DIR}/build-base.sh
|
||||
|
||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
|
||||
if [ ! -e "${SCRIPT_DIR}/run-el.sh" ]; then
|
||||
cp -fp ${SCRIPT_DIR}/../cerc-fixturenet-eth-geth/run-el.sh ${SCRIPT_DIR}/
|
||||
fi
|
||||
|
||||
docker build -t cerc/fixturenet-plugeth-plugeth:local -f ${SCRIPT_DIR}/Dockerfile ${build_command_args} $SCRIPT_DIR
|
||||
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
# Build a local version of the foundry-rs/foundry image
|
||||
source ${CERC_CONTAINER_BASE_DIR}/build-base.sh
|
||||
docker build -t cerc/foundry:local -f ${CERC_REPO_BASE_DIR}/foundry/Dockerfile-debian ${build_command_args} ${CERC_REPO_BASE_DIR}/foundry
|
||||
@@ -0,0 +1,21 @@
|
||||
# Note: cerc/foundry is Debian based
|
||||
FROM cerc/foundry:local
|
||||
|
||||
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
|
||||
&& apt-get -y install --no-install-recommends jq curl netcat
|
||||
|
||||
WORKDIR /root
|
||||
|
||||
ARG GENESIS_FILE_PATH=genesis.json
|
||||
|
||||
COPY stateful ./stateful
|
||||
COPY start-private-network.sh .
|
||||
COPY deploy-local-network.sh .
|
||||
COPY $GENESIS_FILE_PATH ./genesis.json
|
||||
# TODO: figure out if this works for aarm64
|
||||
COPY --from=cerc/go-ethereum:local /usr/local/bin/geth /bin/geth
|
||||
RUN chmod +x /bin/geth
|
||||
|
||||
EXPOSE 8545
|
||||
EXPOSE 8546
|
||||
ENTRYPOINT ["./start-private-network.sh"]
|
||||
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
# Build cerc/go-ethereum-foundry
|
||||
|
||||
source ${CERC_CONTAINER_BASE_DIR}/build-base.sh
|
||||
|
||||
# See: https://stackoverflow.com/a/246128/1701505
|
||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
|
||||
docker build -t cerc/go-ethereum-foundry:local --build-arg GENESIS_FILE_PATH=genesis-automine.json ${build_command_args} ${SCRIPT_DIR}
|
||||
+220
@@ -0,0 +1,220 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
OPTS="./deploy-local-network.sh [<options>] <args>...
|
||||
./deploy-local-network.sh --help
|
||||
--
|
||||
db-user=name database user
|
||||
db-password=password database password
|
||||
db-name=name database name
|
||||
db-host=address database host
|
||||
db-port=port database port
|
||||
db-write=bool turn on database write mode
|
||||
db-type=name the type of database
|
||||
db-driver=name the driver used for the database
|
||||
db-waitforsync=bool Should the statediff service start once geth has synced to head (default: false)
|
||||
rpc-port=port change RPC port (default: 8545)
|
||||
rpc-addr=address change RPC address (default: 127.0.0.1)
|
||||
chain-id=number change chain ID (default: 99)
|
||||
extra-args=name extra args to pass to geth on startup
|
||||
period=seconds use a block time instead of instamine
|
||||
accounts=number create multiple accounts (default: 1)
|
||||
address=address eth address to add to genesis
|
||||
save=name after finishing, save snapshot
|
||||
load=name start from a previously saved snapshot
|
||||
dir=directory testnet directory
|
||||
"
|
||||
|
||||
eval "$(
|
||||
git rev-parse --parseopt -- "$@" <<<"$OPTS" || echo exit $?
|
||||
)"
|
||||
|
||||
DB_USER=vdbm
|
||||
DB_PASSWORD=password
|
||||
DB_NAME=cerc_public
|
||||
DB_HOST=127.0.0.1
|
||||
DB_PORT=5432
|
||||
DB_TYPE=postgres
|
||||
DB_DRIVER=sqlx
|
||||
DB_WAIT_FOR_SYNC=false
|
||||
RPC_PORT=8545
|
||||
RPC_ADDRESS=127.0.0.1
|
||||
PERIOD=0
|
||||
CHAINID=99
|
||||
ACCOUNTS=0
|
||||
ADDRESS=
|
||||
EXTRA_START_ARGS=
|
||||
gethdir=$HOME/testnet
|
||||
|
||||
while [[ $1 ]]; do
|
||||
case $1 in
|
||||
--) shift; break;;
|
||||
--db-user) shift; DB_USER=$1;;
|
||||
--db-password) shift; DB_PASSWORD=$1;;
|
||||
--db-name) shift; DB_NAME=$1;;
|
||||
--db-host) shift; DB_HOST=$1;;
|
||||
--db-port) shift; DB_PORT=$1;;
|
||||
--db-write) shift; DB_WRITE=$1;;
|
||||
--db-type) shift; DB_TYPE=$1;;
|
||||
--db-driver) shift; DB_DRIVER=$1;;
|
||||
--db-waitforsync) shift; DB_WAIT_FOR_SYNC=$1;;
|
||||
--rpc-port) shift; RPC_PORT=$1;;
|
||||
--rpc-addr) shift; RPC_ADDRESS=$1;;
|
||||
--chain-id) shift; CHAINID=$1;;
|
||||
--extra-args) shift; EXTRA_START_ARGS=$1;;
|
||||
--period) shift; PERIOD=$1;;
|
||||
--accounts) shift; ACCOUNTS=$1;;
|
||||
--save) shift; SAVE=$1;;
|
||||
--address) shift; ADDRESS=$1;;
|
||||
--load) shift; LOAD=$1;;
|
||||
--dir) shift; gethdir=$1;;
|
||||
*) printf "${0##*/}: internal error: %q\\n" "$1"; exit 1
|
||||
esac; shift
|
||||
done
|
||||
|
||||
mkdir -p "$gethdir/config/"
|
||||
|
||||
# Set a password
|
||||
if [[ ! -f "$gethdir/config/password" ]]
|
||||
then
|
||||
echo "password" > "$gethdir/config/password"
|
||||
fi
|
||||
|
||||
# Create a genesis file if there is no existing chain.
|
||||
if [[ ! -f "$gethdir/config/genesis.json" ]]
|
||||
then
|
||||
for i in $(seq 0 "$ACCOUNTS"); do
|
||||
address+=( "$(
|
||||
geth 2>/dev/null account new --datadir "$gethdir" --password=$gethdir/config/password \
|
||||
| grep -o -E "0x[A-Fa-f0-9]*" )" )
|
||||
balance+=(' "'"${address[i]}"'": { "balance": "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"}')
|
||||
EXTRA_DATA="0x3132333400000000000000000000000000000000000000000000000000000000${address[0]#0x}0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
|
||||
done
|
||||
if [[ "$USE_GENESIS" != "true" ]]
|
||||
then
|
||||
echo "NOT USING GENESIS FILE!!"
|
||||
echo "USE_GENESIS = $USE_GENESIS"
|
||||
JSON_VAL='{
|
||||
"config": {
|
||||
"chainId": '"$CHAINID"',
|
||||
"homesteadBlock": 0,
|
||||
"eip150Block": 0,
|
||||
"eip155Block": 0,
|
||||
"eip158Block": 0,
|
||||
"byzantiumBlock": 0,
|
||||
"constantinopleBlock": 0,
|
||||
"petersburgBlock": 0,
|
||||
"istanbulBlock": 0,
|
||||
"clique": {
|
||||
"period": '"$PERIOD"',
|
||||
"epoch": 3000
|
||||
}
|
||||
},
|
||||
"difficulty": "0x1",
|
||||
"gaslimit": "0xffffffffffff",
|
||||
"extraData": "'"$EXTRA_DATA"'",
|
||||
"alloc": {'"$balance"'}
|
||||
}'
|
||||
echo $JSON_VAL | jq . > $gethdir/config/genesis.json
|
||||
|
||||
geth 2>/dev/null --datadir "$gethdir" init "$gethdir/config/genesis.json"
|
||||
printf "%s\n" "${address[@]}" > "$gethdir/config/account"
|
||||
else
|
||||
echo "Using local genesis file"
|
||||
jq '. + {"extraData": "'"$EXTRA_DATA"'"} + {"alloc": {'"$balance"'}}' ./genesis.json> "$gethdir/config/genesis.json"
|
||||
geth 2>/dev/null --datadir "$gethdir" init "$gethdir/config/genesis.json"
|
||||
printf "%s\n" "${address[@]}" > "$gethdir/config/account"
|
||||
fi
|
||||
else
|
||||
address=( $(cat $gethdir/config/account) )
|
||||
fi
|
||||
|
||||
export ETH_RPC_URL=http://$RPC_ADDRESS:$RPC_PORT
|
||||
|
||||
port=$((RPC_PORT + 30000))
|
||||
|
||||
geth version
|
||||
echo >&2 "testnet: RPC URL: $ETH_RPC_URL"
|
||||
echo >&2 "testnet: DB ADDRESS: $DB_HOST"
|
||||
echo >&2 "testnet: TCP port: $port"
|
||||
echo >&2 "testnet: Chain ID: $CHAINID"
|
||||
echo >&2 "testnet: Database: $gethdir"
|
||||
echo >&2 "testnet: Geth log: $gethdir/geth.log"
|
||||
|
||||
echo "$ETH_RPC_URL" > "$gethdir/config/rpc-url"
|
||||
echo "$port" > "$gethdir/config/node-port"
|
||||
|
||||
set +m
|
||||
# Uncomment below once waitforsync has been merged
|
||||
# geth \
|
||||
# 2> >(tee "$gethdir/geth.log" | grep --line-buffered Success | sed 's/^/geth: /' >&2) \
|
||||
# --datadir "$gethdir" --networkid "$CHAINID" --port="$port" \
|
||||
# --mine --miner.threads=1 --allow-insecure-unlock \
|
||||
# --http --http.api "web3,eth,net,debug,personal,statediff" --http.corsdomain '*' --http.vhosts '*' --nodiscover \
|
||||
# --http.addr="$RPC_ADDRESS" --http.port="$RPC_PORT" --syncmode=full --gcmode=archive \
|
||||
# --statediff --statediff.db.host="$DB_HOST" --statediff.db.port="$DB_PORT" --statediff.db.user="$DB_USER" \
|
||||
# --statediff.db.password="$DB_PASSWORD" --statediff.db.name="$DB_NAME" \
|
||||
# --statediff.db.nodeid 1 --statediff.db.clientname test1 --statediff.writing="$DB_WRITE" \
|
||||
# --statediff.db.type="$DB_TYPE" --statediff.db.driver="$DB_DRIVER" --statediff.waitforsync="$DB_WAIT_FOR_SYNC" \
|
||||
# --ws --ws.addr="0.0.0.0" --unlock="$(IFS=,; echo "${address[*]}")" --password=<(exit) &
|
||||
|
||||
echo "Starting Geth with following flags"
|
||||
echo \
|
||||
2> >(tee "$gethdir/geth.log" | grep --line-buffered Success | sed 's/^/geth: /' >&2) \
|
||||
--datadir "$gethdir" --networkid "$CHAINID" --port="$port" \
|
||||
--mine --miner.threads=1 --allow-insecure-unlock \
|
||||
--http --http.api "admin,debug,eth,miner,net,personal,txpool,web3,statediff" --http.corsdomain '*' --http.vhosts '*' --nodiscover \
|
||||
--http.addr="$RPC_ADDRESS" --http.port="$RPC_PORT" --syncmode=full --gcmode=archive \
|
||||
--statediff --statediff.db.host="$DB_HOST" --statediff.db.port="$DB_PORT" --statediff.db.user="$DB_USER" \
|
||||
--statediff.db.password="$DB_PASSWORD" --statediff.db.name="$DB_NAME" \
|
||||
--statediff.db.nodeid 1 --statediff.db.clientname test1 --statediff.writing="$DB_WRITE" \
|
||||
--statediff.db.type="$DB_TYPE" --statediff.db.driver="$DB_DRIVER" \
|
||||
--ws --ws.addr="0.0.0.0" --ws.origins '*' --ws.api=admin,debug,eth,miner,net,personal,txpool,web3 \
|
||||
--nat=none --miner.gasprice 16000000000 --nat=none \
|
||||
--unlock="$(IFS=,; echo "${address[*]}")" --password="$gethdir/config/password" \
|
||||
$EXTRA_START_ARGS &
|
||||
geth \
|
||||
2> >(tee "$gethdir/geth.log" | grep --line-buffered Success | sed 's/^/geth: /' >&2) \
|
||||
--datadir "$gethdir" --networkid "$CHAINID" --port="$port" \
|
||||
--mine --miner.threads=1 --allow-insecure-unlock \
|
||||
--http --http.api "admin,debug,eth,miner,net,personal,txpool,web3,statediff" --http.corsdomain '*' --http.vhosts '*' --nodiscover \
|
||||
--http.addr="$RPC_ADDRESS" --http.port="$RPC_PORT" --syncmode=full --gcmode=archive \
|
||||
--statediff --statediff.db.host="$DB_HOST" --statediff.db.port="$DB_PORT" --statediff.db.user="$DB_USER" \
|
||||
--statediff.db.password="$DB_PASSWORD" --statediff.db.name="$DB_NAME" \
|
||||
--statediff.db.nodeid 1 --statediff.db.clientname test1 --statediff.writing="$DB_WRITE" \
|
||||
--statediff.db.type="$DB_TYPE" --statediff.db.driver="$DB_DRIVER" \
|
||||
--ws --ws.addr="0.0.0.0" --ws.origins '*' --ws.api=admin,debug,eth,miner,net,personal,txpool,web3 \
|
||||
--nat=none --miner.gasprice 16000000000 --nat=none \
|
||||
--unlock="$(IFS=,; echo "${address[*]}")" --password="$gethdir/config/password" \
|
||||
$EXTRA_START_ARGS &
|
||||
|
||||
gethpid=$!
|
||||
echo "Geth started"
|
||||
echo "Geth PID: $gethpid"
|
||||
|
||||
clean() {
|
||||
( set -x; kill -INT $gethpid; wait )
|
||||
if [[ $SAVE ]]; then
|
||||
echo >&2 "testnet: saving $gethdir/snapshots/$SAVE"
|
||||
mkdir -p "$gethdir/snapshots/$SAVE"
|
||||
cp -r "$gethdir/keystore" "$gethdir/snapshots/$SAVE"
|
||||
cp -r "$gethdir/config" "$gethdir/snapshots/$SAVE"
|
||||
geth >/dev/null 2>&1 --datadir "$gethdir" \
|
||||
export "$gethdir/snapshots/$SAVE/backup"
|
||||
fi
|
||||
}
|
||||
trap clean EXIT
|
||||
|
||||
echo "Curling: $ETH_RPC_URL"
|
||||
until curl -s "$ETH_RPC_URL"; do sleep 1; done
|
||||
|
||||
echo "Curling: $ETH_RPC_URL complete"
|
||||
export ETH_KEYSTORE=$gethdir/keystore
|
||||
export ETH_PASSWORD=$gethdir/config/password
|
||||
|
||||
printf 'testnet: Account: %s (default)\n' "${address[0]}" >&2
|
||||
|
||||
[[ "${#address[@]}" -gt 1 ]] && printf 'testnet: Account: %s\n' "${address[@]:1}" >&2
|
||||
|
||||
echo "Geth Start up completed!"
|
||||
while true; do sleep 3600; done
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"config": {
|
||||
"chainId": 99,
|
||||
"homesteadBlock": 0,
|
||||
"eip150Block": 0,
|
||||
"eip155Block": 0,
|
||||
"eip158Block": 0,
|
||||
"byzantiumBlock": 0,
|
||||
"constantinopleBlock": 0,
|
||||
"petersburgBlock": 0,
|
||||
"istanbulBlock": 0,
|
||||
"clique": {
|
||||
"period": 5,
|
||||
"epoch": 3000
|
||||
}
|
||||
},
|
||||
"difficulty": "0x1",
|
||||
"gaslimit": "0xffffffffffff"
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"config": {
|
||||
"chainId": 99,
|
||||
"homesteadBlock": 0,
|
||||
"eip150Block": 0,
|
||||
"eip155Block": 0,
|
||||
"eip158Block": 0,
|
||||
"byzantiumBlock": 0,
|
||||
"constantinopleBlock": 0,
|
||||
"petersburgBlock": 0,
|
||||
"istanbulBlock": 0,
|
||||
"clique": {
|
||||
"period": 0,
|
||||
"epoch": 3000
|
||||
}
|
||||
},
|
||||
"difficulty": "0x1",
|
||||
"gaslimit": "0xffffffffffff"
|
||||
}
|
||||
Executable
+64
@@ -0,0 +1,64 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -ex
|
||||
|
||||
# clean up
|
||||
trap 'killall geth' EXIT
|
||||
trap "exit 1" SIGINT SIGTERM
|
||||
|
||||
ETHDIR="/root/ethereum"
|
||||
mkdir -p $ETHDIR
|
||||
/bin/bash deploy-local-network.sh --rpc-addr 0.0.0.0 --db-user $DB_USER --db-password $DB_PASSWORD --db-name $DB_NAME \
|
||||
--db-host $DB_HOST --db-port $DB_PORT --db-write $DB_WRITE --dir "$ETHDIR" --address $ADDRESS \
|
||||
--db-type $DB_TYPE --db-driver $DB_DRIVER --db-waitforsync $DB_WAIT_FOR_SYNC --chain-id $CHAIN_ID --extra-args "$EXTRA_START_ARGS" &
|
||||
|
||||
# give it a few secs to start up
|
||||
COUNT=0
|
||||
ATTEMPTS=15
|
||||
until $(nc -v localhost 8545) || [[ $COUNT -eq $ATTEMPTS ]]; do echo -e "$(( COUNT++ ))... \c"; sleep 10; done
|
||||
[[ $COUNT -eq $ATTEMPTS ]] && echo "Could not connect to localhost 8545" && (exit 1)
|
||||
|
||||
# Run tests
|
||||
cd stateful
|
||||
forge build
|
||||
forge test --fork-url http://localhost:8545
|
||||
|
||||
# Deploy contracts
|
||||
|
||||
ETH_KEYSTORE_FILES=()
|
||||
echo "ETH KEYSTORE: $ETHDIR/keystore"
|
||||
for entry in `ls $ETHDIR/keystore`; do
|
||||
ETH_KEYSTORE_FILES+=("${ETHDIR}/keystore/${entry}")
|
||||
done
|
||||
|
||||
echo "ETH_KEYSTORE_FILES: $ETH_KEYSTORE_FILES"
|
||||
ETH_KEYSTORE_FILE=${ETH_KEYSTORE_FILES[0]}
|
||||
|
||||
mkdir -p ~/transaction_info
|
||||
echo $ETH_KEYSTORE_FILE > ~/transaction_info/CURRENT_ETH_KEYSTORE_FILE
|
||||
echo $ETHDIR > ~/transaction_info/ETHDIR
|
||||
|
||||
if [ "${#ETH_KEYSTORE_FILES[@]}" -eq 1 ]; then
|
||||
echo "Only one KEYSTORE"
|
||||
else
|
||||
echo "WARNING: More than one file in keystore: ${ETH_KEYSTORE_FILES}"
|
||||
fi
|
||||
|
||||
DEPLOYED_ADDRESS=$(forge create --keystore $(cat ~/transaction_info/CURRENT_ETH_KEYSTORE_FILE) --rpc-url http://127.0.0.1:8545 --constructor-args 1 --password $(cat ${ETHDIR}/config/password) --legacy /root/stateful/src/Stateful.sol:Stateful | grep "Deployed to:" | cut -d " " -f 3)
|
||||
echo "Contract has been deployed to: $DEPLOYED_ADDRESS"
|
||||
|
||||
echo $DEPLOYED_ADDRESS > ~/transaction_info/STATEFUL_TEST_DEPLOYED_ADDRESS
|
||||
# Call a transaction
|
||||
|
||||
#TX_OUT=$(cast send --keystore $ETH_KEYSTORE_FILE --rpc-url http://127.0.0.1:8545 --password "" --legacy $DEPLOYED_ADDRESS "off()")
|
||||
TX_OUT=$(cast send --keystore $(cat ~/transaction_info/CURRENT_ETH_KEYSTORE_FILE) --rpc-url http://127.0.0.1:8545 --password $(cat $(cat ~/transaction_info/ETHDIR)/config/password) --legacy $(cat ~/transaction_info/STATEFUL_TEST_DEPLOYED_ADDRESS) "inc()")
|
||||
echo 'cast send --keystore $(cat ~/transaction_info/CURRENT_ETH_KEYSTORE_FILE) --rpc-url http://127.0.0.1:8545 --password $(cat $(cat ~/transaction_info/ETHDIR)/config/password) --legacy $(cat ~/transaction_info/STATEFUL_TEST_DEPLOYED_ADDRESS) "inc()" ' > ~/transaction_info/NEW_TRANSACTION
|
||||
# Simply run the command below whenever you want to call the smart contract and create a new block
|
||||
chmod +x ~/transaction_info/NEW_TRANSACTION
|
||||
|
||||
|
||||
echo "TX OUTPUT: $TX_OUT"
|
||||
|
||||
|
||||
# Run forever
|
||||
tail -f /dev/null
|
||||
@@ -0,0 +1,7 @@
|
||||
[default]
|
||||
src = 'src'
|
||||
out = 'out'
|
||||
libs = ['lib']
|
||||
remappings = ['ds-test/=lib/ds-test/src/']
|
||||
|
||||
# See more config options https://github.com/gakonst/foundry/tree/master/config
|
||||
+674
@@ -0,0 +1,674 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
all:; dapp build
|
||||
|
||||
test:
|
||||
-dapp --use solc:0.4.23 build
|
||||
-dapp --use solc:0.4.26 build
|
||||
-dapp --use solc:0.5.17 build
|
||||
-dapp --use solc:0.6.12 build
|
||||
-dapp --use solc:0.7.5 build
|
||||
|
||||
demo:
|
||||
DAPP_SRC=demo dapp --use solc:0.7.5 build
|
||||
-hevm dapp-test --verbose 3
|
||||
|
||||
.PHONY: test demo
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
{ solidityPackage, dappsys }: solidityPackage {
|
||||
name = "ds-test";
|
||||
src = ./src;
|
||||
}
|
||||
+223
@@ -0,0 +1,223 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
pragma solidity >=0.4.23;
|
||||
|
||||
import "../src/test.sol";
|
||||
|
||||
contract DemoTest is DSTest {
|
||||
function test_this() public pure {
|
||||
require(true);
|
||||
}
|
||||
function test_logs() public {
|
||||
emit log("-- log(string)");
|
||||
emit log("a string");
|
||||
|
||||
emit log("-- log_named_uint(string, uint)");
|
||||
log_named_uint("uint", 512);
|
||||
|
||||
emit log("-- log_named_int(string, int)");
|
||||
log_named_int("int", -512);
|
||||
|
||||
emit log("-- log_named_address(string, address)");
|
||||
log_named_address("address", address(this));
|
||||
|
||||
emit log("-- log_named_bytes32(string, bytes32)");
|
||||
log_named_bytes32("bytes32", "a string");
|
||||
|
||||
emit log("-- log_named_bytes(string, bytes)");
|
||||
log_named_bytes("bytes", hex"cafefe");
|
||||
|
||||
emit log("-- log_named_string(string, string)");
|
||||
log_named_string("string", "a string");
|
||||
|
||||
emit log("-- log_named_decimal_uint(string, uint, uint)");
|
||||
log_named_decimal_uint("decimal uint", 1.0e18, 18);
|
||||
|
||||
emit log("-- log_named_decimal_int(string, int, uint)");
|
||||
log_named_decimal_int("decimal int", -1.0e18, 18);
|
||||
}
|
||||
event log_old_named_uint(bytes32,uint);
|
||||
function test_old_logs() public {
|
||||
log_old_named_uint("key", 500);
|
||||
log_named_bytes32("bkey", "val");
|
||||
}
|
||||
function test_trace() public view {
|
||||
this.echo("string 1", "string 2");
|
||||
}
|
||||
function test_multiline() public {
|
||||
emit log("a multiline\\n" "string");
|
||||
emit log("a multiline " "string");
|
||||
log_bytes("a string");
|
||||
log_bytes("a multiline\n" "string");
|
||||
log_bytes("a multiline\\n" "string");
|
||||
emit log(unicode"Ώ");
|
||||
logs(hex"0000");
|
||||
log_named_bytes("0x0000", hex"0000");
|
||||
logs(hex"ff");
|
||||
}
|
||||
function echo(string memory s1, string memory s2) public pure
|
||||
returns (string memory, string memory)
|
||||
{
|
||||
return (s1, s2);
|
||||
}
|
||||
|
||||
function prove_this(uint x) public {
|
||||
log_named_uint("sym x", x);
|
||||
assertGt(x + 1, 0);
|
||||
}
|
||||
|
||||
function test_logn() public {
|
||||
assembly {
|
||||
log0(0x01, 0x02)
|
||||
log1(0x01, 0x02, 0x03)
|
||||
log2(0x01, 0x02, 0x03, 0x04)
|
||||
log3(0x01, 0x02, 0x03, 0x04, 0x05)
|
||||
}
|
||||
}
|
||||
|
||||
event MyEvent(uint, uint indexed, uint, uint indexed);
|
||||
function test_events() public {
|
||||
emit MyEvent(1, 2, 3, 4);
|
||||
}
|
||||
|
||||
function test_asserts() public {
|
||||
string memory err = "this test has failed!";
|
||||
emit log("## assertTrue(bool)\n");
|
||||
assertTrue(false);
|
||||
emit log("\n");
|
||||
assertTrue(false, err);
|
||||
|
||||
emit log("\n## assertEq(address,address)\n");
|
||||
assertEq(address(this), msg.sender);
|
||||
emit log("\n");
|
||||
assertEq(address(this), msg.sender, err);
|
||||
|
||||
emit log("\n## assertEq32(bytes32,bytes32)\n");
|
||||
assertEq32("bytes 1", "bytes 2");
|
||||
emit log("\n");
|
||||
assertEq32("bytes 1", "bytes 2", err);
|
||||
|
||||
emit log("\n## assertEq(bytes32,bytes32)\n");
|
||||
assertEq32("bytes 1", "bytes 2");
|
||||
emit log("\n");
|
||||
assertEq32("bytes 1", "bytes 2", err);
|
||||
|
||||
emit log("\n## assertEq(uint,uint)\n");
|
||||
assertEq(uint(0), 1);
|
||||
emit log("\n");
|
||||
assertEq(uint(0), 1, err);
|
||||
|
||||
emit log("\n## assertEq(int,int)\n");
|
||||
assertEq(-1, -2);
|
||||
emit log("\n");
|
||||
assertEq(-1, -2, err);
|
||||
|
||||
emit log("\n## assertEqDecimal(int,int,uint)\n");
|
||||
assertEqDecimal(-1.0e18, -1.1e18, 18);
|
||||
emit log("\n");
|
||||
assertEqDecimal(-1.0e18, -1.1e18, 18, err);
|
||||
|
||||
emit log("\n## assertEqDecimal(uint,uint,uint)\n");
|
||||
assertEqDecimal(uint(1.0e18), 1.1e18, 18);
|
||||
emit log("\n");
|
||||
assertEqDecimal(uint(1.0e18), 1.1e18, 18, err);
|
||||
|
||||
emit log("\n## assertGt(uint,uint)\n");
|
||||
assertGt(uint(0), 0);
|
||||
emit log("\n");
|
||||
assertGt(uint(0), 0, err);
|
||||
|
||||
emit log("\n## assertGt(int,int)\n");
|
||||
assertGt(-1, -1);
|
||||
emit log("\n");
|
||||
assertGt(-1, -1, err);
|
||||
|
||||
emit log("\n## assertGtDecimal(int,int,uint)\n");
|
||||
assertGtDecimal(-2.0e18, -1.1e18, 18);
|
||||
emit log("\n");
|
||||
assertGtDecimal(-2.0e18, -1.1e18, 18, err);
|
||||
|
||||
emit log("\n## assertGtDecimal(uint,uint,uint)\n");
|
||||
assertGtDecimal(uint(1.0e18), 1.1e18, 18);
|
||||
emit log("\n");
|
||||
assertGtDecimal(uint(1.0e18), 1.1e18, 18, err);
|
||||
|
||||
emit log("\n## assertGe(uint,uint)\n");
|
||||
assertGe(uint(0), 1);
|
||||
emit log("\n");
|
||||
assertGe(uint(0), 1, err);
|
||||
|
||||
emit log("\n## assertGe(int,int)\n");
|
||||
assertGe(-1, 0);
|
||||
emit log("\n");
|
||||
assertGe(-1, 0, err);
|
||||
|
||||
emit log("\n## assertGeDecimal(int,int,uint)\n");
|
||||
assertGeDecimal(-2.0e18, -1.1e18, 18);
|
||||
emit log("\n");
|
||||
assertGeDecimal(-2.0e18, -1.1e18, 18, err);
|
||||
|
||||
emit log("\n## assertGeDecimal(uint,uint,uint)\n");
|
||||
assertGeDecimal(uint(1.0e18), 1.1e18, 18);
|
||||
emit log("\n");
|
||||
assertGeDecimal(uint(1.0e18), 1.1e18, 18, err);
|
||||
|
||||
emit log("\n## assertLt(uint,uint)\n");
|
||||
assertLt(uint(0), 0);
|
||||
emit log("\n");
|
||||
assertLt(uint(0), 0, err);
|
||||
|
||||
emit log("\n## assertLt(int,int)\n");
|
||||
assertLt(-1, -1);
|
||||
emit log("\n");
|
||||
assertLt(-1, -1, err);
|
||||
|
||||
emit log("\n## assertLtDecimal(int,int,uint)\n");
|
||||
assertLtDecimal(-1.0e18, -1.1e18, 18);
|
||||
emit log("\n");
|
||||
assertLtDecimal(-1.0e18, -1.1e18, 18, err);
|
||||
|
||||
emit log("\n## assertLtDecimal(uint,uint,uint)\n");
|
||||
assertLtDecimal(uint(2.0e18), 1.1e18, 18);
|
||||
emit log("\n");
|
||||
assertLtDecimal(uint(2.0e18), 1.1e18, 18, err);
|
||||
|
||||
emit log("\n## assertLe(uint,uint)\n");
|
||||
assertLe(uint(1), 0);
|
||||
emit log("\n");
|
||||
assertLe(uint(1), 0, err);
|
||||
|
||||
emit log("\n## assertLe(int,int)\n");
|
||||
assertLe(0, -1);
|
||||
emit log("\n");
|
||||
assertLe(0, -1, err);
|
||||
|
||||
emit log("\n## assertLeDecimal(int,int,uint)\n");
|
||||
assertLeDecimal(-1.0e18, -1.1e18, 18);
|
||||
emit log("\n");
|
||||
assertLeDecimal(-1.0e18, -1.1e18, 18, err);
|
||||
|
||||
emit log("\n## assertLeDecimal(uint,uint,uint)\n");
|
||||
assertLeDecimal(uint(2.0e18), 1.1e18, 18);
|
||||
emit log("\n");
|
||||
assertLeDecimal(uint(2.0e18), 1.1e18, 18, err);
|
||||
|
||||
emit log("\n## assertEq(string,string)\n");
|
||||
string memory s1 = "string 1";
|
||||
string memory s2 = "string 2";
|
||||
assertEq(s1, s2);
|
||||
emit log("\n");
|
||||
assertEq(s1, s2, err);
|
||||
|
||||
emit log("\n## assertEq0(bytes,bytes)\n");
|
||||
assertEq0(hex"abcdef01", hex"abcdef02");
|
||||
log("\n");
|
||||
assertEq0(hex"abcdef01", hex"abcdef02", err);
|
||||
}
|
||||
}
|
||||
|
||||
contract DemoTestWithSetUp {
|
||||
function setUp() public {
|
||||
}
|
||||
function test_pass() public pure {
|
||||
}
|
||||
}
|
||||
+434
@@ -0,0 +1,434 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
pragma solidity >=0.4.23;
|
||||
|
||||
contract DSTest {
|
||||
event log (string);
|
||||
event logs (bytes);
|
||||
|
||||
event log_address (address);
|
||||
event log_bytes32 (bytes32);
|
||||
event log_int (int);
|
||||
event log_uint (uint);
|
||||
event log_bytes (bytes);
|
||||
event log_string (string);
|
||||
|
||||
event log_named_address (string key, address val);
|
||||
event log_named_bytes32 (string key, bytes32 val);
|
||||
event log_named_decimal_int (string key, int val, uint decimals);
|
||||
event log_named_decimal_uint (string key, uint val, uint decimals);
|
||||
event log_named_int (string key, int val);
|
||||
event log_named_uint (string key, uint val);
|
||||
event log_named_bytes (string key, bytes val);
|
||||
event log_named_string (string key, string val);
|
||||
|
||||
bool public IS_TEST = true;
|
||||
bool public failed;
|
||||
|
||||
address constant HEVM_ADDRESS =
|
||||
address(bytes20(uint160(uint256(keccak256('hevm cheat code')))));
|
||||
|
||||
modifier mayRevert() { _; }
|
||||
modifier testopts(string memory) { _; }
|
||||
|
||||
function fail() internal {
|
||||
failed = true;
|
||||
}
|
||||
|
||||
modifier logs_gas() {
|
||||
uint startGas = gasleft();
|
||||
_;
|
||||
uint endGas = gasleft();
|
||||
emit log_named_uint("gas", startGas - endGas);
|
||||
}
|
||||
|
||||
function assertTrue(bool condition) internal {
|
||||
if (!condition) {
|
||||
emit log("Error: Assertion Failed");
|
||||
fail();
|
||||
}
|
||||
}
|
||||
|
||||
function assertTrue(bool condition, string memory err) internal {
|
||||
if (!condition) {
|
||||
emit log_named_string("Error", err);
|
||||
assertTrue(condition);
|
||||
}
|
||||
}
|
||||
|
||||
function assertEq(address a, address b) internal {
|
||||
if (a != b) {
|
||||
emit log("Error: a == b not satisfied [address]");
|
||||
emit log_named_address(" Expected", b);
|
||||
emit log_named_address(" Actual", a);
|
||||
fail();
|
||||
}
|
||||
}
|
||||
function assertEq(address a, address b, string memory err) internal {
|
||||
if (a != b) {
|
||||
emit log_named_string ("Error", err);
|
||||
assertEq(a, b);
|
||||
}
|
||||
}
|
||||
|
||||
function assertEq(bytes32 a, bytes32 b) internal {
|
||||
if (a != b) {
|
||||
emit log("Error: a == b not satisfied [bytes32]");
|
||||
emit log_named_bytes32(" Expected", b);
|
||||
emit log_named_bytes32(" Actual", a);
|
||||
fail();
|
||||
}
|
||||
}
|
||||
function assertEq(bytes32 a, bytes32 b, string memory err) internal {
|
||||
if (a != b) {
|
||||
emit log_named_string ("Error", err);
|
||||
assertEq(a, b);
|
||||
}
|
||||
}
|
||||
function assertEq32(bytes32 a, bytes32 b) internal {
|
||||
assertEq(a, b);
|
||||
}
|
||||
function assertEq32(bytes32 a, bytes32 b, string memory err) internal {
|
||||
assertEq(a, b, err);
|
||||
}
|
||||
|
||||
function assertEq(int a, int b) internal {
|
||||
if (a != b) {
|
||||
emit log("Error: a == b not satisfied [int]");
|
||||
emit log_named_int(" Expected", b);
|
||||
emit log_named_int(" Actual", a);
|
||||
fail();
|
||||
}
|
||||
}
|
||||
function assertEq(int a, int b, string memory err) internal {
|
||||
if (a != b) {
|
||||
emit log_named_string("Error", err);
|
||||
assertEq(a, b);
|
||||
}
|
||||
}
|
||||
function assertEq(uint a, uint b) internal {
|
||||
if (a != b) {
|
||||
emit log("Error: a == b not satisfied [uint]");
|
||||
emit log_named_uint(" Expected", b);
|
||||
emit log_named_uint(" Actual", a);
|
||||
fail();
|
||||
}
|
||||
}
|
||||
function assertEq(uint a, uint b, string memory err) internal {
|
||||
if (a != b) {
|
||||
emit log_named_string("Error", err);
|
||||
assertEq(a, b);
|
||||
}
|
||||
}
|
||||
function assertEqDecimal(int a, int b, uint decimals) internal {
|
||||
if (a != b) {
|
||||
emit log("Error: a == b not satisfied [decimal int]");
|
||||
emit log_named_decimal_int(" Expected", b, decimals);
|
||||
emit log_named_decimal_int(" Actual", a, decimals);
|
||||
fail();
|
||||
}
|
||||
}
|
||||
function assertEqDecimal(int a, int b, uint decimals, string memory err) internal {
|
||||
if (a != b) {
|
||||
emit log_named_string("Error", err);
|
||||
assertEqDecimal(a, b, decimals);
|
||||
}
|
||||
}
|
||||
function assertEqDecimal(uint a, uint b, uint decimals) internal {
|
||||
if (a != b) {
|
||||
emit log("Error: a == b not satisfied [decimal uint]");
|
||||
emit log_named_decimal_uint(" Expected", b, decimals);
|
||||
emit log_named_decimal_uint(" Actual", a, decimals);
|
||||
fail();
|
||||
}
|
||||
}
|
||||
function assertEqDecimal(uint a, uint b, uint decimals, string memory err) internal {
|
||||
if (a != b) {
|
||||
emit log_named_string("Error", err);
|
||||
assertEqDecimal(a, b, decimals);
|
||||
}
|
||||
}
|
||||
|
||||
function assertGt(uint a, uint b) internal {
|
||||
if (a <= b) {
|
||||
emit log("Error: a > b not satisfied [uint]");
|
||||
emit log_named_uint(" Value a", a);
|
||||
emit log_named_uint(" Value b", b);
|
||||
fail();
|
||||
}
|
||||
}
|
||||
function assertGt(uint a, uint b, string memory err) internal {
|
||||
if (a <= b) {
|
||||
emit log_named_string("Error", err);
|
||||
assertGt(a, b);
|
||||
}
|
||||
}
|
||||
function assertGt(int a, int b) internal {
|
||||
if (a <= b) {
|
||||
emit log("Error: a > b not satisfied [int]");
|
||||
emit log_named_int(" Value a", a);
|
||||
emit log_named_int(" Value b", b);
|
||||
fail();
|
||||
}
|
||||
}
|
||||
function assertGt(int a, int b, string memory err) internal {
|
||||
if (a <= b) {
|
||||
emit log_named_string("Error", err);
|
||||
assertGt(a, b);
|
||||
}
|
||||
}
|
||||
function assertGtDecimal(int a, int b, uint decimals) internal {
|
||||
if (a <= b) {
|
||||
emit log("Error: a > b not satisfied [decimal int]");
|
||||
emit log_named_decimal_int(" Value a", a, decimals);
|
||||
emit log_named_decimal_int(" Value b", b, decimals);
|
||||
fail();
|
||||
}
|
||||
}
|
||||
function assertGtDecimal(int a, int b, uint decimals, string memory err) internal {
|
||||
if (a <= b) {
|
||||
emit log_named_string("Error", err);
|
||||
assertGtDecimal(a, b, decimals);
|
||||
}
|
||||
}
|
||||
function assertGtDecimal(uint a, uint b, uint decimals) internal {
|
||||
if (a <= b) {
|
||||
emit log("Error: a > b not satisfied [decimal uint]");
|
||||
emit log_named_decimal_uint(" Value a", a, decimals);
|
||||
emit log_named_decimal_uint(" Value b", b, decimals);
|
||||
fail();
|
||||
}
|
||||
}
|
||||
function assertGtDecimal(uint a, uint b, uint decimals, string memory err) internal {
|
||||
if (a <= b) {
|
||||
emit log_named_string("Error", err);
|
||||
assertGtDecimal(a, b, decimals);
|
||||
}
|
||||
}
|
||||
|
||||
function assertGe(uint a, uint b) internal {
|
||||
if (a < b) {
|
||||
emit log("Error: a >= b not satisfied [uint]");
|
||||
emit log_named_uint(" Value a", a);
|
||||
emit log_named_uint(" Value b", b);
|
||||
fail();
|
||||
}
|
||||
}
|
||||
function assertGe(uint a, uint b, string memory err) internal {
|
||||
if (a < b) {
|
||||
emit log_named_string("Error", err);
|
||||
assertGe(a, b);
|
||||
}
|
||||
}
|
||||
function assertGe(int a, int b) internal {
|
||||
if (a < b) {
|
||||
emit log("Error: a >= b not satisfied [int]");
|
||||
emit log_named_int(" Value a", a);
|
||||
emit log_named_int(" Value b", b);
|
||||
fail();
|
||||
}
|
||||
}
|
||||
function assertGe(int a, int b, string memory err) internal {
|
||||
if (a < b) {
|
||||
emit log_named_string("Error", err);
|
||||
assertGe(a, b);
|
||||
}
|
||||
}
|
||||
function assertGeDecimal(int a, int b, uint decimals) internal {
|
||||
if (a < b) {
|
||||
emit log("Error: a >= b not satisfied [decimal int]");
|
||||
emit log_named_decimal_int(" Value a", a, decimals);
|
||||
emit log_named_decimal_int(" Value b", b, decimals);
|
||||
fail();
|
||||
}
|
||||
}
|
||||
function assertGeDecimal(int a, int b, uint decimals, string memory err) internal {
|
||||
if (a < b) {
|
||||
emit log_named_string("Error", err);
|
||||
assertGeDecimal(a, b, decimals);
|
||||
}
|
||||
}
|
||||
function assertGeDecimal(uint a, uint b, uint decimals) internal {
|
||||
if (a < b) {
|
||||
emit log("Error: a >= b not satisfied [decimal uint]");
|
||||
emit log_named_decimal_uint(" Value a", a, decimals);
|
||||
emit log_named_decimal_uint(" Value b", b, decimals);
|
||||
fail();
|
||||
}
|
||||
}
|
||||
function assertGeDecimal(uint a, uint b, uint decimals, string memory err) internal {
|
||||
if (a < b) {
|
||||
emit log_named_string("Error", err);
|
||||
assertGeDecimal(a, b, decimals);
|
||||
}
|
||||
}
|
||||
|
||||
function assertLt(uint a, uint b) internal {
|
||||
if (a >= b) {
|
||||
emit log("Error: a < b not satisfied [uint]");
|
||||
emit log_named_uint(" Value a", a);
|
||||
emit log_named_uint(" Value b", b);
|
||||
fail();
|
||||
}
|
||||
}
|
||||
function assertLt(uint a, uint b, string memory err) internal {
|
||||
if (a >= b) {
|
||||
emit log_named_string("Error", err);
|
||||
assertLt(a, b);
|
||||
}
|
||||
}
|
||||
function assertLt(int a, int b) internal {
|
||||
if (a >= b) {
|
||||
emit log("Error: a < b not satisfied [int]");
|
||||
emit log_named_int(" Value a", a);
|
||||
emit log_named_int(" Value b", b);
|
||||
fail();
|
||||
}
|
||||
}
|
||||
function assertLt(int a, int b, string memory err) internal {
|
||||
if (a >= b) {
|
||||
emit log_named_string("Error", err);
|
||||
assertLt(a, b);
|
||||
}
|
||||
}
|
||||
function assertLtDecimal(int a, int b, uint decimals) internal {
|
||||
if (a >= b) {
|
||||
emit log("Error: a < b not satisfied [decimal int]");
|
||||
emit log_named_decimal_int(" Value a", a, decimals);
|
||||
emit log_named_decimal_int(" Value b", b, decimals);
|
||||
fail();
|
||||
}
|
||||
}
|
||||
function assertLtDecimal(int a, int b, uint decimals, string memory err) internal {
|
||||
if (a >= b) {
|
||||
emit log_named_string("Error", err);
|
||||
assertLtDecimal(a, b, decimals);
|
||||
}
|
||||
}
|
||||
function assertLtDecimal(uint a, uint b, uint decimals) internal {
|
||||
if (a >= b) {
|
||||
emit log("Error: a < b not satisfied [decimal uint]");
|
||||
emit log_named_decimal_uint(" Value a", a, decimals);
|
||||
emit log_named_decimal_uint(" Value b", b, decimals);
|
||||
fail();
|
||||
}
|
||||
}
|
||||
function assertLtDecimal(uint a, uint b, uint decimals, string memory err) internal {
|
||||
if (a >= b) {
|
||||
emit log_named_string("Error", err);
|
||||
assertLtDecimal(a, b, decimals);
|
||||
}
|
||||
}
|
||||
|
||||
function assertLe(uint a, uint b) internal {
|
||||
if (a > b) {
|
||||
emit log("Error: a <= b not satisfied [uint]");
|
||||
emit log_named_uint(" Value a", a);
|
||||
emit log_named_uint(" Value b", b);
|
||||
fail();
|
||||
}
|
||||
}
|
||||
function assertLe(uint a, uint b, string memory err) internal {
|
||||
if (a > b) {
|
||||
emit log_named_string("Error", err);
|
||||
assertLe(a, b);
|
||||
}
|
||||
}
|
||||
function assertLe(int a, int b) internal {
|
||||
if (a > b) {
|
||||
emit log("Error: a <= b not satisfied [int]");
|
||||
emit log_named_int(" Value a", a);
|
||||
emit log_named_int(" Value b", b);
|
||||
fail();
|
||||
}
|
||||
}
|
||||
function assertLe(int a, int b, string memory err) internal {
|
||||
if (a > b) {
|
||||
emit log_named_string("Error", err);
|
||||
assertLe(a, b);
|
||||
}
|
||||
}
|
||||
function assertLeDecimal(int a, int b, uint decimals) internal {
|
||||
if (a > b) {
|
||||
emit log("Error: a <= b not satisfied [decimal int]");
|
||||
emit log_named_decimal_int(" Value a", a, decimals);
|
||||
emit log_named_decimal_int(" Value b", b, decimals);
|
||||
fail();
|
||||
}
|
||||
}
|
||||
function assertLeDecimal(int a, int b, uint decimals, string memory err) internal {
|
||||
if (a > b) {
|
||||
emit log_named_string("Error", err);
|
||||
assertLeDecimal(a, b, decimals);
|
||||
}
|
||||
}
|
||||
function assertLeDecimal(uint a, uint b, uint decimals) internal {
|
||||
if (a > b) {
|
||||
emit log("Error: a <= b not satisfied [decimal uint]");
|
||||
emit log_named_decimal_uint(" Value a", a, decimals);
|
||||
emit log_named_decimal_uint(" Value b", b, decimals);
|
||||
fail();
|
||||
}
|
||||
}
|
||||
function assertLeDecimal(uint a, uint b, uint decimals, string memory err) internal {
|
||||
if (a > b) {
|
||||
emit log_named_string("Error", err);
|
||||
assertGeDecimal(a, b, decimals);
|
||||
}
|
||||
}
|
||||
|
||||
function assertEq(string memory a, string memory b) internal {
|
||||
if (keccak256(abi.encodePacked(a)) != keccak256(abi.encodePacked(b))) {
|
||||
emit log("Error: a == b not satisfied [string]");
|
||||
emit log_named_string(" Value a", a);
|
||||
emit log_named_string(" Value b", b);
|
||||
fail();
|
||||
}
|
||||
}
|
||||
function assertEq(string memory a, string memory b, string memory err) internal {
|
||||
if (keccak256(abi.encodePacked(a)) != keccak256(abi.encodePacked(b))) {
|
||||
emit log_named_string("Error", err);
|
||||
assertEq(a, b);
|
||||
}
|
||||
}
|
||||
|
||||
function checkEq0(bytes memory a, bytes memory b) internal pure returns (bool ok) {
|
||||
ok = true;
|
||||
if (a.length == b.length) {
|
||||
for (uint i = 0; i < a.length; i++) {
|
||||
if (a[i] != b[i]) {
|
||||
ok = false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ok = false;
|
||||
}
|
||||
}
|
||||
function assertEq0(bytes memory a, bytes memory b) internal {
|
||||
if (!checkEq0(a, b)) {
|
||||
emit log("Error: a == b not satisfied [bytes]");
|
||||
emit log_named_bytes(" Expected", a);
|
||||
emit log_named_bytes(" Actual", b);
|
||||
fail();
|
||||
}
|
||||
}
|
||||
function assertEq0(bytes memory a, bytes memory b, string memory err) internal {
|
||||
if (!checkEq0(a, b)) {
|
||||
emit log_named_string("Error", err);
|
||||
assertEq0(a, b);
|
||||
}
|
||||
}
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
// SPDX-License-Identifier: UNLICENSED
|
||||
pragma solidity 0.8.10;
|
||||
|
||||
contract Stateful {
|
||||
uint x;
|
||||
|
||||
constructor(uint y) public {
|
||||
x = y;
|
||||
}
|
||||
|
||||
function off() public {
|
||||
require(x == 1);
|
||||
x = 0;
|
||||
}
|
||||
|
||||
function on() public {
|
||||
require(x == 0);
|
||||
x = 1;
|
||||
}
|
||||
function inc() public {
|
||||
x = x + 1;
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
// SPDX-License-Identifier: UNLICENSED
|
||||
pragma solidity 0.8.10;
|
||||
|
||||
import "ds-test/test.sol";
|
||||
import {Stateful} from "../Stateful.sol";
|
||||
|
||||
contract StatefulTest is DSTest {
|
||||
Stateful contractA;
|
||||
//contractA A;
|
||||
uint x;
|
||||
function setUp() public {
|
||||
x = 1;
|
||||
contractA = new Stateful(x);
|
||||
}
|
||||
|
||||
function testExample() public {
|
||||
contractA.off();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
# Build cerc/go-ethereum
|
||||
source ${CERC_CONTAINER_BASE_DIR}/build-base.sh
|
||||
docker build -t cerc/go-ethereum:local ${build_command_args} ${CERC_REPO_BASE_DIR}/go-ethereum
|
||||
@@ -0,0 +1,16 @@
|
||||
FROM golang:1.21-bullseye AS builder
|
||||
|
||||
# Copy files into image
|
||||
WORKDIR /app
|
||||
COPY . .
|
||||
|
||||
# Build the binary
|
||||
RUN go build -v -o nitro .
|
||||
|
||||
# Reduce image size
|
||||
FROM debian:bullseye-slim
|
||||
RUN apt-get update
|
||||
RUN apt-get install -y ca-certificates jq netcat
|
||||
RUN rm -rf /var/lib/apt/lists/*
|
||||
WORKDIR /app
|
||||
COPY --from=builder /app/nitro .
|
||||
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
# Build cerc/go-nitro
|
||||
|
||||
source ${CERC_CONTAINER_BASE_DIR}/build-base.sh
|
||||
|
||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
|
||||
docker build -t cerc/go-nitro:local -f ${SCRIPT_DIR}/Dockerfile ${build_command_args} ${CERC_REPO_BASE_DIR}/go-nitro
|
||||
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
# Build cerc/go-opera
|
||||
source ${CERC_CONTAINER_BASE_DIR}/build-base.sh
|
||||
|
||||
# Repo's dockerfile gives build error because it's hardcoded for go 1.17; go 1.19 is required
|
||||
sed -i 's/FROM golang:1\.[0-9]*-alpine as builder/FROM golang:1.19-alpine as builder/' ${CERC_REPO_BASE_DIR}/go-opera/docker/Dockerfile.opera
|
||||
|
||||
docker build -f ${CERC_REPO_BASE_DIR}/go-opera/docker/Dockerfile.opera -t cerc/go-opera:local ${build_command_args} ${CERC_REPO_BASE_DIR}/go-opera
|
||||
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
# Build a local version of the graphprotocol/graph-node image (among reasons: the upstream image is not built for arm)
|
||||
source ${CERC_CONTAINER_BASE_DIR}/build-base.sh
|
||||
docker build -t cerc/graph-node:local -f ${CERC_REPO_BASE_DIR}/graph-node/docker/Dockerfile ${build_command_args} ${CERC_REPO_BASE_DIR}/graph-node
|
||||
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
# Build cerc/ipld-eth-beacon-db
|
||||
source ${CERC_CONTAINER_BASE_DIR}/build-base.sh
|
||||
docker build -t cerc/ipld-eth-beacon-db:local ${build_command_args} ${build_command_args} ${CERC_REPO_BASE_DIR}/ipld-eth-beacon-db
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
# Build cerc/ipld-eth-beacon-indexer
|
||||
source ${CERC_CONTAINER_BASE_DIR}/build-base.sh
|
||||
docker build -t cerc/ipld-eth-beacon-indexer:local ${build_command_args} ${CERC_REPO_BASE_DIR}/ipld-eth-beacon-indexer
|
||||
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
# Build cerc/ipld-eth-db
|
||||
source ${CERC_CONTAINER_BASE_DIR}/build-base.sh
|
||||
docker build -t cerc/ipld-eth-db:local ${build_command_args} ${CERC_REPO_BASE_DIR}/ipld-eth-db
|
||||
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
# Build cerc/ipld-eth-server
|
||||
source ${CERC_CONTAINER_BASE_DIR}/build-base.sh
|
||||
docker build -t cerc/ipld-eth-server:local ${build_command_args} ${CERC_REPO_BASE_DIR}/ipld-eth-server
|
||||
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
# Build cerc/keycloak-reg-api
|
||||
|
||||
source ${CERC_CONTAINER_BASE_DIR}/build-base.sh
|
||||
|
||||
# See: https://stackoverflow.com/a/246128/1701505
|
||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
|
||||
docker build -t cerc/keycloak-reg-api:local ${build_command_args} ${CERC_REPO_BASE_DIR}/keycloak-reg-api
|
||||
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
# Build cerc/keycloak-reg-ui
|
||||
|
||||
source ${CERC_CONTAINER_BASE_DIR}/build-base.sh
|
||||
|
||||
# See: https://stackoverflow.com/a/246128/1701505
|
||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
|
||||
docker build -t cerc/keycloak-reg-ui:local ${build_command_args} ${CERC_REPO_BASE_DIR}/keycloak-reg-ui
|
||||
@@ -0,0 +1,4 @@
|
||||
FROM quay.io/keycloak/keycloak:20.0
|
||||
WORKDIR /opt/keycloak/providers
|
||||
RUN curl -L https://github.com/aerogear/keycloak-metrics-spi/releases/download/2.5.3/keycloak-metrics-spi-2.5.3.jar --output keycloak-metrics-spi.jar
|
||||
RUN curl -L https://github.com/cerc-io/keycloak-api-key-demo/releases/download/v0.3/api-key-module-0.3.jar --output api-key-module.jar
|
||||
@@ -0,0 +1,10 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
#Build cerc/keycloack
|
||||
|
||||
source ${CERC_CONTAINER_BASE_DIR}/build-base.sh
|
||||
|
||||
# See: https://stackoverflow.com/a/246128/1701505
|
||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
|
||||
docker build -t cerc/keycloak:local ${build_command_args} ${SCRIPT_DIR}
|
||||
@@ -0,0 +1,15 @@
|
||||
FROM cerc/webapp-base:local
|
||||
|
||||
# This container pulls npm packages from a local registry configured via these env vars
|
||||
ARG CERC_NPM_REGISTRY_URL
|
||||
ARG CERC_NPM_AUTH_TOKEN
|
||||
|
||||
# Configure the local npm registry
|
||||
RUN npm config set @cerc-io:registry ${CERC_NPM_REGISTRY_URL} \
|
||||
&& npm config set @lirewine:registry ${CERC_NPM_REGISTRY_URL} \
|
||||
&& npm config set -- ${CERC_NPM_REGISTRY_URL}:_authToken ${CERC_NPM_AUTH_TOKEN}
|
||||
|
||||
# Globally install the payload web app package
|
||||
RUN yarn global add @cerc-io/console-app
|
||||
|
||||
COPY ./config.yml /config
|
||||
@@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
# Build cerc/laconic-registry-cli
|
||||
|
||||
source ${CERC_CONTAINER_BASE_DIR}/build-base.sh
|
||||
|
||||
# See: https://stackoverflow.com/a/246128/1701505
|
||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
|
||||
docker build -t cerc/laconic-console-host:local ${build_command_args} -f ${SCRIPT_DIR}/Dockerfile \
|
||||
--add-host gitea.local:host-gateway \
|
||||
--build-arg CERC_NPM_AUTH_TOKEN --build-arg CERC_NPM_REGISTRY_URL ${SCRIPT_DIR}
|
||||
@@ -0,0 +1,6 @@
|
||||
# Config for laconic-console running in a fixturenet with laconicd
|
||||
|
||||
services:
|
||||
wns:
|
||||
server: 'LACONIC_HOSTED_ENDPOINT:9473/api'
|
||||
webui: 'LACONIC_HOSTED_ENDPOINT:9473/console'
|
||||
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
# Build the laconic.com image
|
||||
source ${CERC_CONTAINER_BASE_DIR}/build-base.sh
|
||||
docker build -t cerc/laconic-dot-com:local -f ${CERC_REPO_BASE_DIR}/laconic.com/Dockerfile ${build_command_args} ${CERC_REPO_BASE_DIR}/laconic.com
|
||||
@@ -0,0 +1,65 @@
|
||||
# Originally from: https://github.com/devcontainers/images/blob/main/src/javascript-node/.devcontainer/Dockerfile
|
||||
# [Choice] Node.js version (use -bullseye variants on local arm64/Apple Silicon): 18, 16, 14, 18-bullseye, 16-bullseye, 14-bullseye, 18-buster, 16-buster, 14-buster
|
||||
ARG VARIANT=18-bullseye
|
||||
FROM node:${VARIANT}
|
||||
|
||||
ARG USERNAME=node
|
||||
ARG NPM_GLOBAL=/usr/local/share/npm-global
|
||||
|
||||
# This container pulls npm packages from a local registry configured via these env vars
|
||||
ARG CERC_NPM_REGISTRY_URL
|
||||
ARG CERC_NPM_AUTH_TOKEN
|
||||
|
||||
# Add NPM global to PATH.
|
||||
ENV PATH=${NPM_GLOBAL}/bin:${PATH}
|
||||
# Prevents npm from printing version warnings
|
||||
ENV NPM_CONFIG_UPDATE_NOTIFIER=false
|
||||
|
||||
RUN \
|
||||
# Configure global npm install location, use group to adapt to UID/GID changes
|
||||
if ! cat /etc/group | grep -e "^npm:" > /dev/null 2>&1; then groupadd -r npm; fi \
|
||||
&& usermod -a -G npm ${USERNAME} \
|
||||
&& umask 0002 \
|
||||
&& mkdir -p ${NPM_GLOBAL} \
|
||||
&& touch /usr/local/etc/npmrc \
|
||||
&& chown ${USERNAME}:npm ${NPM_GLOBAL} /usr/local/etc/npmrc \
|
||||
&& chmod g+s ${NPM_GLOBAL} \
|
||||
&& npm config -g set prefix ${NPM_GLOBAL} \
|
||||
&& su ${USERNAME} -c "npm config -g set prefix ${NPM_GLOBAL}" \
|
||||
# Install eslint
|
||||
&& su ${USERNAME} -c "umask 0002 && npm install -g eslint" \
|
||||
&& npm cache clean --force > /dev/null 2>&1
|
||||
|
||||
# [Optional] Uncomment this section to install additional OS packages.
|
||||
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
|
||||
&& apt-get -y install --no-install-recommends jq
|
||||
|
||||
# [Optional] Uncomment if you want to install an additional version of node using nvm
|
||||
# ARG EXTRA_NODE_VERSION=10
|
||||
# RUN su node -c "source /usr/local/share/nvm/nvm.sh && nvm install ${EXTRA_NODE_VERSION}"
|
||||
|
||||
# [Optional] Uncomment if you want to install more global node modules
|
||||
# RUN su node -c "npm install -g <your-package-list-here>"
|
||||
|
||||
# Configure the local npm registry
|
||||
RUN npm config set @cerc-io:registry ${CERC_NPM_REGISTRY_URL} \
|
||||
&& npm config set @lirewine:registry ${CERC_NPM_REGISTRY_URL} \
|
||||
&& npm config set -- ${CERC_NPM_REGISTRY_URL}:_authToken ${CERC_NPM_AUTH_TOKEN}
|
||||
|
||||
# TODO: the image at this point could be made a base image for several different CLI images
|
||||
# that install different Node-based CLI commands
|
||||
|
||||
# Globally install the cli package
|
||||
RUN yarn global add @cerc-io/laconic-registry-cli
|
||||
|
||||
# Add scripts
|
||||
RUN mkdir /scripts
|
||||
RUN mkdir /scripts/demo-records
|
||||
ENV PATH="${PATH}:/scripts"
|
||||
COPY ./create-demo-records.sh /scripts
|
||||
COPY ./demo-records /scripts/demo-records
|
||||
COPY ./import-key.sh /scripts
|
||||
COPY ./import-address.sh /scripts
|
||||
|
||||
# Default command sleeps forever so docker doesn't kill it
|
||||
CMD ["sh", "-c", "while :; do sleep 600; done"]
|
||||
@@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
# Build cerc/laconic-registry-cli
|
||||
|
||||
source ${CERC_CONTAINER_BASE_DIR}/build-base.sh
|
||||
|
||||
# See: https://stackoverflow.com/a/246128/1701505
|
||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
|
||||
docker build -t cerc/laconic-registry-cli:local ${build_command_args} -f ${SCRIPT_DIR}/Dockerfile \
|
||||
--add-host gitea.local:host-gateway \
|
||||
--build-arg CERC_NPM_AUTH_TOKEN --build-arg CERC_NPM_REGISTRY_URL ${SCRIPT_DIR}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env bash
|
||||
# Create some demo/test records in the registry
|
||||
set -e
|
||||
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
|
||||
set -x
|
||||
fi
|
||||
|
||||
registry_command="laconic cns"
|
||||
demo_records_dir="scripts/demo-records"
|
||||
|
||||
# Check we have funds
|
||||
funds_response=$(${registry_command} account get --address $(cat my-address.txt))
|
||||
funds_balance=$(echo ${funds_response} | jq -r .[0].balance[0].quantity)
|
||||
echo "Balance is: ${funds_balance}"
|
||||
|
||||
# Create a bond
|
||||
bond_create_result=$(${registry_command} bond create --type aphoton --quantity 1000000000)
|
||||
bond_id=$(echo ${bond_create_result} | jq -r .bondId)
|
||||
echo "Created bond with id: ${bond_id}"
|
||||
|
||||
## Publish the demo records
|
||||
if [ -d $demo_records_dir ]; then
|
||||
for demo_record in "${demo_records_dir}"/*; do
|
||||
publish_response=$(${registry_command} record publish --filename ${demo_record} --bond-id ${bond_id})
|
||||
published_record_id=$(echo ${publish_response} | jq -r .id)
|
||||
echo "Published ${demo_record} with id: ${published_record_id}"
|
||||
cat ${demo_record}
|
||||
done
|
||||
fi
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
record:
|
||||
type: WebsiteRegistrationRecord
|
||||
url: 'https://hello-urbit.laconic.com'
|
||||
repo_registration_record_cid: QmTZQ8ZJS6mALjEM2wY71msFno6zzxFftVCiZELj9xREPx
|
||||
build_artifact_cid: '~lostex-rabdur-labtul-moltev/hello-urbit'
|
||||
tls_cert_cid: QmR1acEmQt7Tjmhp9cFtymie2eFcrHURQKt9kGto1TQTW1
|
||||
version: 0.2.4
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
record:
|
||||
type: WebsiteRegistrationRecord
|
||||
url: 'https://dev-hello-urbit.laconic.com'
|
||||
repo_registration_record_cid: QmPbKkK7gKojnGAgKAE6bK5qBY8BcYp2YDB1e4b28NxvVv
|
||||
build_artifact_cid: '~lostex-rabdur-labtul-moltev/hello-urbit-dev'
|
||||
tls_cert_cid: QmWbCv4k9Q9P6XptHNJN6EupDyKVLSLRV6W6T2sAYkfBxr
|
||||
version: 0.2.5
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
record:
|
||||
type: WebsiteRegistrationRecord
|
||||
url: 'https://app.osmosis.zone'
|
||||
repo_registration_record_cid: QmSnuWmxptJZdLJpKRarxBMS2Ju2oANVrgbr2xWbie9b2D
|
||||
build_artifact_cid: '~larryx-woldyr/osmosis:latest'
|
||||
tls_cert_cid: QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR
|
||||
version: 1.3.5
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
record:
|
||||
type: WebsiteRegistrationRecord
|
||||
url: 'https://dev.osmosis.zone'
|
||||
repo_registration_record_cid: QmPbKkK7gKojnGAgKAE6bK5qBY8BcYp2YDB1e4b28NxvVv
|
||||
build_artifact_cid: '~larryx-woldyr/osmosis:dev'
|
||||
tls_cert_cid: QmWbCv4k9Q9P6XptHNJN6EupDyKVLSLRV6W6T2sAYkfBxr
|
||||
version: 1.3.6
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
record:
|
||||
type: WebsiteRegistrationRecord
|
||||
url: 'https://pwa-1-1-3.iglootools.xyz'
|
||||
repo_registration_record_cid: QmSnuWmxptJZdLJpKRarxBMS2Ju2oANVrgbr2xWbie9b2D
|
||||
build_artifact_cid: https://ipfs.io/ipfs/QmP8jTG1m9GSDJLCbeWhVSVgEzCPPwXRdCRuJtQ5Tz9Kc9
|
||||
tls_cert_cid: QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR
|
||||
version: 1.1.3
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
record:
|
||||
type: WebsiteRegistrationRecord
|
||||
url: 'https://pwa-1-2-3.iglootools.xyz'
|
||||
repo_registration_record_cid: QmVjYQ59z3fuKfYUV1aXhDR82JAKxdqB5JMPfUsHkJUkJq
|
||||
build_artifact_cid: https://ipfs.io/ipfs/QmN2yevgjC92gzGi2BY6Q2yBWmR6JNWQ9yscoPPyy1V2Hv
|
||||
tls_cert_cid: QmTAnmDMSnzqAN3yyXtFD4KpyATkeze62ZkbmXHjJ8xQW8
|
||||
version: 1.2.3
|
||||
@@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
echo ${1} > my-address.txt
|
||||
@@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
sed 's/REPLACE_WITH_MYKEY/'${1}'/' registry-cli-config-template.yml > config.yml
|
||||
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
# Build cerc/laconicd
|
||||
source ${CERC_CONTAINER_BASE_DIR}/build-base.sh
|
||||
docker build -t cerc/laconicd:local ${build_command_args} ${CERC_REPO_BASE_DIR}/laconicd
|
||||
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
# Build the lasso image
|
||||
source ${CERC_CONTAINER_BASE_DIR}/build-base.sh
|
||||
docker build -t cerc/lasso:local -f ${CERC_REPO_BASE_DIR}/lasso/Dockerfile ${build_command_args} ${CERC_REPO_BASE_DIR}/lasso
|
||||
@@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
# Build cerc/lighthouse-cli
|
||||
|
||||
source ${CERC_CONTAINER_BASE_DIR}/build-base.sh
|
||||
|
||||
project_dir=${CERC_REPO_BASE_DIR}/lighthouse
|
||||
docker build -t cerc/lighthouse-cli:local --build-arg PORTABLE=true -f ${project_dir}/lcli/Dockerfile ${build_command_args} ${project_dir}
|
||||
@@ -0,0 +1,9 @@
|
||||
ARG TAG_SUFFIX="-modern"
|
||||
FROM sigp/lighthouse:v4.3.0${TAG_SUFFIX}
|
||||
|
||||
RUN apt-get update; apt-get install bash netcat curl less jq wget -y;
|
||||
|
||||
WORKDIR /root/
|
||||
ADD start-lighthouse.sh .
|
||||
|
||||
ENTRYPOINT [ "./start-lighthouse.sh" ]
|
||||
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
# Build cerc/lighthouse
|
||||
|
||||
source ${CERC_CONTAINER_BASE_DIR}/build-base.sh
|
||||
|
||||
# See: https://stackoverflow.com/a/246128/1701505
|
||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
|
||||
docker build -t cerc/lighthouse:local ${build_command_args} --build-arg TAG_SUFFIX="" ${SCRIPT_DIR}
|
||||
@@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
# This bash script will be used to start the lighthouse client
|
||||
# The 0.0.0.0 is not safe.
|
||||
|
||||
lighthouse bn \
|
||||
--http --http-address 0.0.0.0 --metrics --private --network $NETWORK &
|
||||
|
||||
tail -f /dev/null
|
||||
@@ -0,0 +1,141 @@
|
||||
#####################################
|
||||
FROM golang:1.19.12-bullseye AS lotus-builder
|
||||
MAINTAINER Lotus Development Team
|
||||
|
||||
RUN apt-get update && apt-get install -y ca-certificates build-essential clang ocl-icd-opencl-dev ocl-icd-libopencl1 jq libhwloc-dev
|
||||
|
||||
ENV XDG_CACHE_HOME="/tmp"
|
||||
|
||||
### taken from https://github.com/rust-lang/docker-rust/blob/master/1.63.0/buster/Dockerfile
|
||||
ENV RUSTUP_HOME=/usr/local/rustup \
|
||||
CARGO_HOME=/usr/local/cargo \
|
||||
PATH=/usr/local/cargo/bin:$PATH \
|
||||
RUST_VERSION=1.63.0
|
||||
|
||||
RUN set -eux; \
|
||||
dpkgArch="$(dpkg --print-architecture)"; \
|
||||
case "${dpkgArch##*-}" in \
|
||||
amd64) rustArch='x86_64-unknown-linux-gnu'; rustupSha256='5cc9ffd1026e82e7fb2eec2121ad71f4b0f044e88bca39207b3f6b769aaa799c' ;; \
|
||||
arm64) rustArch='aarch64-unknown-linux-gnu'; rustupSha256='e189948e396d47254103a49c987e7fb0e5dd8e34b200aa4481ecc4b8e41fb929' ;; \
|
||||
*) echo >&2 "unsupported architecture: ${dpkgArch}"; exit 1 ;; \
|
||||
esac; \
|
||||
url="https://static.rust-lang.org/rustup/archive/1.25.1/${rustArch}/rustup-init"; \
|
||||
wget "$url"; \
|
||||
echo "${rustupSha256} *rustup-init" | sha256sum -c -; \
|
||||
chmod +x rustup-init; \
|
||||
./rustup-init -y --no-modify-path --profile minimal --default-toolchain $RUST_VERSION --default-host ${rustArch}; \
|
||||
rm rustup-init; \
|
||||
chmod -R a+w $RUSTUP_HOME $CARGO_HOME; \
|
||||
rustup --version; \
|
||||
cargo --version; \
|
||||
rustc --version;
|
||||
|
||||
COPY ./ /opt/filecoin
|
||||
WORKDIR /opt/filecoin
|
||||
|
||||
#RUN scripts/docker-git-state-check.sh
|
||||
|
||||
### make configurable filecoin-ffi build
|
||||
ARG FFI_BUILD_FROM_SOURCE=0
|
||||
ENV FFI_BUILD_FROM_SOURCE=${FFI_BUILD_FROM_SOURCE}
|
||||
|
||||
RUN make clean deps
|
||||
|
||||
ARG RUSTFLAGS=""
|
||||
ARG GOFLAGS=""
|
||||
|
||||
#RUN make buildall
|
||||
RUN make 2k
|
||||
|
||||
#####################################
|
||||
FROM ubuntu:20.04 AS lotus-base
|
||||
MAINTAINER Lotus Development Team
|
||||
|
||||
# Base resources
|
||||
COPY --from=lotus-builder /etc/ssl/certs /etc/ssl/certs
|
||||
COPY --from=lotus-builder /lib/*/libdl.so.2 /lib/
|
||||
COPY --from=lotus-builder /lib/*/librt.so.1 /lib/
|
||||
COPY --from=lotus-builder /lib/*/libgcc_s.so.1 /lib/
|
||||
COPY --from=lotus-builder /lib/*/libutil.so.1 /lib/
|
||||
COPY --from=lotus-builder /usr/lib/*/libltdl.so.7 /lib/
|
||||
COPY --from=lotus-builder /usr/lib/*/libnuma.so.1 /lib/
|
||||
COPY --from=lotus-builder /usr/lib/*/libhwloc.so.* /lib/
|
||||
COPY --from=lotus-builder /usr/lib/*/libOpenCL.so.1 /lib/
|
||||
|
||||
RUN useradd -r -u 532 -U fc \
|
||||
&& mkdir -p /etc/OpenCL/vendors \
|
||||
&& echo "libnvidia-opencl.so.1" > /etc/OpenCL/vendors/nvidia.icd
|
||||
|
||||
#####################################
|
||||
FROM lotus-base AS lotus
|
||||
MAINTAINER Lotus Development Team
|
||||
|
||||
COPY --from=lotus-builder /opt/filecoin/lotus /usr/local/bin/
|
||||
COPY --from=lotus-builder /opt/filecoin/lotus-shed /usr/local/bin/
|
||||
#COPY scripts/docker-lotus-entrypoint.sh /
|
||||
#COPY myscripts/setup-node.sh /docker-entrypoint-scripts.d/setup-node.sh
|
||||
|
||||
ARG DOCKER_LOTUS_IMPORT_SNAPSHOT https://snapshots.mainnet.filops.net/minimal/latest
|
||||
ENV DOCKER_LOTUS_IMPORT_SNAPSHOT ${DOCKER_LOTUS_IMPORT_SNAPSHOT}
|
||||
ENV FILECOIN_PARAMETER_CACHE /var/tmp/filecoin-proof-parameters
|
||||
ENV LOTUS_PATH /var/lib/lotus
|
||||
ENV DOCKER_LOTUS_IMPORT_WALLET ""
|
||||
|
||||
RUN mkdir /var/lib/lotus /var/tmp/filecoin-proof-parameters
|
||||
RUN chown fc: /var/lib/lotus /var/tmp/filecoin-proof-parameters
|
||||
|
||||
VOLUME /var/lib/lotus
|
||||
VOLUME /var/tmp/filecoin-proof-parameters
|
||||
|
||||
USER fc
|
||||
|
||||
EXPOSE 1234
|
||||
|
||||
ENTRYPOINT ["/docker-lotus-entrypoint.sh"]
|
||||
|
||||
CMD ["-help"]
|
||||
|
||||
#####################################
|
||||
FROM lotus-base AS lotus-all-in-one
|
||||
|
||||
# Install netcat for healthcheck
|
||||
RUN apt-get update && apt-get install -y netcat && apt-get install -y iproute2
|
||||
|
||||
ENV FILECOIN_PARAMETER_CACHE /var/tmp/filecoin-proof-parameters
|
||||
ENV LOTUS_MINER_PATH /var/lib/lotus-miner
|
||||
ENV LOTUS_PATH /var/lib/lotus
|
||||
ENV LOTUS_WORKER_PATH /var/lib/lotus-worker
|
||||
ENV WALLET_PATH /var/lib/lotus-wallet
|
||||
|
||||
COPY --from=lotus-builder /opt/filecoin/lotus /usr/local/bin/
|
||||
COPY --from=lotus-builder /opt/filecoin/lotus-seed /usr/local/bin/
|
||||
COPY --from=lotus-builder /opt/filecoin/lotus-shed /usr/local/bin/
|
||||
#COPY --from=lotus-builder /opt/filecoin/lotus-wallet /usr/local/bin/
|
||||
#COPY --from=lotus-builder /opt/filecoin/lotus-gateway /usr/local/bin/
|
||||
COPY --from=lotus-builder /opt/filecoin/lotus-miner /usr/local/bin/
|
||||
COPY --from=lotus-builder /opt/filecoin/lotus-worker /usr/local/bin/
|
||||
#COPY --from=lotus-builder /opt/filecoin/lotus-stats /usr/local/bin/
|
||||
#COPY --from=lotus-builder /opt/filecoin/lotus-fountain /usr/local/bin/
|
||||
|
||||
RUN mkdir /var/tmp/filecoin-proof-parameters
|
||||
RUN mkdir /var/lib/lotus
|
||||
RUN mkdir /var/lib/lotus-miner
|
||||
RUN mkdir /var/lib/lotus-worker
|
||||
RUN mkdir /var/lib/lotus-wallet
|
||||
RUN chown fc: /var/tmp/filecoin-proof-parameters
|
||||
RUN chown fc: /var/lib/lotus
|
||||
RUN chown fc: /var/lib/lotus-miner
|
||||
RUN chown fc: /var/lib/lotus-worker
|
||||
RUN chown fc: /var/lib/lotus-wallet
|
||||
|
||||
|
||||
#VOLUME /var/tmp/filecoin-proof-parameters
|
||||
#VOLUME /var/lib/lotus
|
||||
#VOLUME /var/lib/lotus-miner
|
||||
#VOLUME /var/lib/lotus-worker
|
||||
#VOLUME /var/lib/lotus-wallet
|
||||
|
||||
EXPOSE 1234
|
||||
EXPOSE 2345
|
||||
EXPOSE 3456
|
||||
EXPOSE 1777
|
||||
@@ -0,0 +1,12 @@
|
||||
#!/usr/bin/env bash
|
||||
# Build cerc/lotus
|
||||
source ${CERC_CONTAINER_BASE_DIR}/build-base.sh
|
||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
|
||||
# Use a release version tag to match the modified Dockerfile replaced in next step
|
||||
git -C ${CERC_REPO_BASE_DIR}/lotus checkout v1.23.3
|
||||
|
||||
# Replace repo's Dockerfile with modified one
|
||||
cp ${SCRIPT_DIR}/Dockerfile ${CERC_REPO_BASE_DIR}/lotus/Dockerfile
|
||||
|
||||
docker build -t cerc/lotus:local ${build_command_args} ${CERC_REPO_BASE_DIR}/lotus
|
||||
@@ -0,0 +1,13 @@
|
||||
FROM node:18.15.0-alpine3.16
|
||||
|
||||
RUN apk --update --no-cache add git python3 alpine-sdk bash
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN echo "Installing dependencies..." && \
|
||||
yarn install && \
|
||||
cd packages/snap
|
||||
|
||||
CMD ["bash", "-c", "yarn start"]
|
||||
@@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
# Build cerc/mobymask-snap
|
||||
|
||||
source ${CERC_CONTAINER_BASE_DIR}/build-base.sh
|
||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
|
||||
docker build -t cerc/mobymask-snap:local -f ${SCRIPT_DIR}/Dockerfile ${build_command_args} ${CERC_REPO_BASE_DIR}/mobymask-snap
|
||||
@@ -0,0 +1,43 @@
|
||||
# Originally from: https://github.com/devcontainers/images/blob/main/src/javascript-node/.devcontainer/Dockerfile
|
||||
# [Choice] Node.js version (use -bullseye variants on local arm64/Apple Silicon): 18, 16, 14, 18-bullseye, 16-bullseye, 14-bullseye, 18-buster, 16-buster, 14-buster
|
||||
ARG VARIANT=18-bullseye
|
||||
FROM node:${VARIANT}
|
||||
|
||||
ARG USERNAME=node
|
||||
ARG NPM_GLOBAL=/usr/local/share/npm-global
|
||||
|
||||
# Add NPM global to PATH.
|
||||
ENV PATH=${NPM_GLOBAL}/bin:${PATH}
|
||||
# Prevents npm from printing version warnings
|
||||
ENV NPM_CONFIG_UPDATE_NOTIFIER=false
|
||||
|
||||
RUN \
|
||||
# Configure global npm install location, use group to adapt to UID/GID changes
|
||||
if ! cat /etc/group | grep -e "^npm:" > /dev/null 2>&1; then groupadd -r npm; fi \
|
||||
&& usermod -a -G npm ${USERNAME} \
|
||||
&& umask 0002 \
|
||||
&& mkdir -p ${NPM_GLOBAL} \
|
||||
&& touch /usr/local/etc/npmrc \
|
||||
&& chown ${USERNAME}:npm ${NPM_GLOBAL} /usr/local/etc/npmrc \
|
||||
&& chmod g+s ${NPM_GLOBAL} \
|
||||
&& npm config -g set prefix ${NPM_GLOBAL} \
|
||||
&& su ${USERNAME} -c "npm config -g set prefix ${NPM_GLOBAL}" \
|
||||
# Install eslint
|
||||
&& su ${USERNAME} -c "umask 0002 && npm install -g eslint" \
|
||||
&& npm cache clean --force > /dev/null 2>&1
|
||||
|
||||
# Install additional OS packages.
|
||||
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
|
||||
&& apt-get -y install --no-install-recommends jq bash netcat
|
||||
|
||||
RUN mkdir -p /scripts
|
||||
|
||||
# Install simple web server for now (use nginx perhaps later)
|
||||
RUN yarn global add http-server
|
||||
|
||||
WORKDIR /app
|
||||
COPY . .
|
||||
RUN yarn install
|
||||
|
||||
# Expose port for http
|
||||
EXPOSE 80
|
||||
@@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
# Build cerc/mobymask-ui
|
||||
|
||||
source ${CERC_CONTAINER_BASE_DIR}/build-base.sh
|
||||
|
||||
# See: https://stackoverflow.com/a/246128/1701505
|
||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
|
||||
CERC_NPM_REGISTRY_URL="https://git.vdb.to/api/packages/cerc-io/npm/"
|
||||
|
||||
docker build -t cerc/mobymask-ui:local ${build_command_args} -f ${SCRIPT_DIR}/Dockerfile ${CERC_REPO_BASE_DIR}/mobymask-ui
|
||||
@@ -0,0 +1,13 @@
|
||||
FROM node:16.17.1-alpine3.16
|
||||
|
||||
RUN apk --update --no-cache add python3 alpine-sdk jq bash curl wget
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN yarn
|
||||
|
||||
# Add scripts
|
||||
RUN mkdir /scripts
|
||||
ENV PATH="${PATH}:/scripts"
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user