Skip to content
This repository has been archived by the owner on Aug 19, 2022. It is now read-only.

Updates #11

Merged
merged 7 commits into from
Jul 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ARG GROUP_ID
RUN apt-get update
RUN apt-get update --fix-missing
RUN DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install tzdata
RUN apt-get -y install zip unzip libncurses5 wget git build-essential cmake curl libboost-all-dev libcurl4-openssl-dev libgmp-dev libssl-dev libusb-1.0.0-dev libzstd-dev time pkg-config llvm-11-dev nginx npm yarn
RUN apt-get -y install zip unzip libncurses5 wget git build-essential cmake curl libboost-all-dev libcurl4-openssl-dev libgmp-dev libssl-dev libusb-1.0.0-dev libzstd-dev time pkg-config llvm-11-dev nginx npm yarn jq gdb lldb
RUN npm install -D webpack-cli
RUN npm install -D webpack
RUN npm install -D webpack-dev-server
Expand All @@ -23,6 +23,7 @@ RUN mv my_init /sbin

RUN ./bootstrap_env.sh
RUN ./setup_system.sh
RUN cp -R /usr/lib/x86_64-linux-gnu/* /usr/lib

RUN if [ ${USER_ID:-0} -ne 0 ] && [ ${GROUP_ID:-0} -ne 0 ]; then \
userdel -f www-data && \
Expand All @@ -38,6 +39,7 @@ RUN if [ ${USER_ID:-0} -ne 0 ] && [ ${GROUP_ID:-0} -ne 0 ]; then \
USER www-data

RUN mkdir /home/www-data/nodes
RUN cp /app/config.ini /home/www-data/config.ini

# thanks to github.com/phusion
# this should solve reaping issues of stopped nodes
Expand Down
3 changes: 2 additions & 1 deletion bootstrap.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#!/usr/bin/env bash

SDIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

GROUP_ID=$(id -g ${USER})
# for mac users
if [[ $(uname) == "Darwin" ]]; then
GROUP_ID=200
fi
docker build --build-arg USER_ID=$(id -u ${USER}) --build-arg GROUP_ID=${GROUP_ID} -t dune $SDIR
docker build --no-cache --build-arg USER_ID=$(id -u ${USER}) --build-arg GROUP_ID=${GROUP_ID} -t dune $SDIR
44 changes: 17 additions & 27 deletions scripts/bootstrap_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,32 @@

ARCH=`uname -m`

# TODO change to eosnetworkfoundation after releases are made
ORG="larryk85"
ORG="eosnetworkfoundation"
NODE_VERSION="3.1.0-rc2"
CDT_VERSION="3.0.0-rc1"

# TODO change to 3.1.0
NODE_VERSION="v1.0"
NODE_PKG_NAME="mandel_3.0.5"

# TODO change to 3.0.0
CDT_VERSION="v1.0"
CDT_PKG_NAME="cdt_1.8.1"

# TODO change to mandel
NODE_REPO="ENF-Binaries"
# TODO change to mandel.cdt
CDT_REPO="ENF-Binaries"
CONTRACTS_REPO="mandel-contracts"
CONTAINER_PACKAGE=eosnetworkfoundation/experimental-binaries
GH_ANON_BEARER=$(curl -s "https://ghcr.io/token?service=registry.docker.io&scope=repository:${CONTAINER_PACKAGE}:pull" | jq -r .token)
curl -s -L -H "Authorization: Bearer ${GH_ANON_BEARER}" https://ghcr.io/v2/${CONTAINER_PACKAGE}/blobs/$(curl -s -L -H "Authorization: Bearer ${GH_ANON_BEARER}" https://ghcr.io/v2/${CONTAINER_PACKAGE}/manifests/v3.1.0-rc2 | jq -r .layers[0].digest) | tar zx

if [ "${ARCH}" = "x86_64" ]; then
wget https://github.com/${ORG}/${NODE_REPO}/releases/download/${NODE_VERSION}/${NODE_PKG_NAME}_amd64.deb
apt install ./${NODE_PKG_NAME}_amd64.deb

wget https://github.com/${ORG}/${CDT_REPO}/releases/download/${CDT_VERSION}/${CDT_PKG_NAME}_amd64.deb
apt install ./${CDT_PKG_NAME}_amd64.deb
wget https://github.com/${ORG}/mandel/releases/download/v${NODE_VERSION}/mandel-${NODE_VERSION}-ubuntu20.04-x86_64.deb
apt install ./mandel-${NODE_VERSION}-ubuntu20.04-x86_64.deb
apt install ./mandel-dev-${NODE_VERSION}-ubuntu20.04-x86_64.deb
wget https://github.com/${ORG}/mandel.cdt/releases/download/v${CDT_VERSION}/cdt_${CDT_VERSION}_amd64.deb
apt install ./cdt_${CDT_VERSION}_amd64.deb
else
wget https://github.com/${ORG}/${NODE_REPO}/releases/download/${NODE_VERSION}/${NODE_PKG_NAME}_arm64.deb
apt install ./${NODE_PKG_NAME}_arm64.deb

wget https://github.com/${ORG}/${CDT_REPO}/releases/download/${CDT_VERSION}/${CDT_PKG_NAME}_arm64.deb
apt install ./${CDT_PKG_NAME}_arm64.deb
apt install ./mandel-${NODE_VERSION}-ubuntu20.04-aarch64.deb
apt install ./mandel-dev-${NODE_VERSION}-ubuntu20.04-aarch64.deb
wget https://github.com/${ORG}/${CDT_REPO}/releases/download/v${CDT_VERSION}/cdt_${CDT_VERSION}_arm64.deb
apt install ./cdt_${CDT_VERSION}_arm64.deb
fi

git clone https://github.com/eosnetworkfoundation/mandel-contracts
cd mandel-contracts
git pull
git checkout larryk85/mandel-update
git checkout main
mkdir build
cd build
cmake ..
make -j4
make -j4
2 changes: 1 addition & 1 deletion scripts/config.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
wasm-runtime = eos-vm-jit
wasm-runtime = eos-vm
abi-serializer-max-time-ms = 15
chain-state-db-size-mb = 65536
# chain-threads = 2
Expand Down
22 changes: 16 additions & 6 deletions src/dune/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from dune import dune_error
from dune import dune_node_not_found
from args import arg_parser
from args import parse_optional

import os

Expand All @@ -12,7 +13,7 @@
dune_sys = dune()

if parser.is_forwarding():
dune_sys.execute_cmd(parser.get_forwarded_args())
dune_sys.execute_interactive_cmd(parser.get_forwarded_args())
else:
args = parser.parse()

Expand Down Expand Up @@ -89,10 +90,22 @@

elif args.cmake_build != None:
if len(args.cmake_build) > 1:
dune_sys.build_cmake_proj(args.cmake_build[0], args.cmake_build[1].split())
dune_sys.build_cmake_proj(args.cmake_build[0], parse_optional(args.cmake_build[1]))
else:
dune_sys.build_cmake_proj(args.cmake_build[0], [])

elif args.ctest != None:
if len(args.ctest) > 1:
dune_sys.ctest_runner(args.ctest[0], parse_optional(args.ctest[1]))
else:
dune_sys.ctest_runner(args.ctest[0], [])

elif args.gdb != None:
if len(args.gdb) > 1:
dune_sys.gdb(args.gdb[0], parse_optional(args.gdb[1]))
else:
dune_sys.gdb(args.gdb[0], [])

elif args.deploy != None:
dune_sys.deploy_contract(dune_sys._docker.abs_host_path(args.deploy[0]), args.deploy[1])

Expand Down Expand Up @@ -123,13 +136,10 @@

elif args.get_table != None:
dune_sys.get_table(args.get_table[0], args.get_table[1], args.get_table[2])

elif args.start_webapp != None:
dune_sys.start_webapp(args.start_webapp)

except KeyboardInterrupt:
pass
except dune_node_not_found as err:
print('Node not found ['+err.name()+']')
except dune_error as err:
print("Internal Error")
print("Internal Error")
33 changes: 32 additions & 1 deletion src/dune/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,35 @@ def __call__(self, parser, namespace, values, option_string=None):
fixed_list.append(values[2].strip())
fixed_list.append(values[3])
setattr(namespace, self.dest, fixed_list)

def fix_args(args):
arg_list = list()
arg_so_far = ""
state = False
for arg in args:
if not state:
if arg.startswith('['):
state = True
arg_so_far = arg[1:]
continue
else:
arg_list.append(arg)
continue
if state:
if arg.endswith(']'):
arg_so_far = arg_so_far + arg[:-1]
state = False
arg_list.append(arg_so_far)
arg_so_far = ""
continue
else:
arg_so_far = arg_so_far + arg

return arg_list

def parse_optional(cmd):
cmd = cmd[1:-1] # remove containing []
return cmd.split()
class arg_parser:
def __init__(self):
self._parser = argparse.ArgumentParser(description='DUNE: Docker Utilities for Node Execution')
Expand All @@ -29,7 +58,9 @@ def __init__(self):
self._parser.add_argument('--create-account', nargs='+', metavar=["NAME","CREATOR (Optional)", "PUB_KEY (Optional)", "PRIV_KEY (Optional)"], help='create an EOSIO account and an optional creator (the default is eosio)')
self._parser.add_argument('--create-cmake-app', nargs=2, metavar=["PROJ_NAME", "DIR"], help='create a smart contract project at from a specific host location')
self._parser.add_argument('--create-bare-app', nargs=2, metavar=["PROJ_NAME", "DIR"], help='create a smart contract project at from a specific host location')
self._parser.add_argument('--cmake-build', nargs='+', metavar=["DIR", "FLAGS (Optional)"], help='build a smart contract project at the directory given')
self._parser.add_argument('--cmake-build', nargs='+', metavar=["DIR", "FLAGS (Optional)"], help='build a smart contract project at the directory given optional flags are of the form [-DFLAG1=On -DFLAG2=Off]')
self._parser.add_argument('--ctest', nargs='+', metavar=["DIR", "FLAGS (Optional)"], help='run the ctest tests for a smart contract project at the directory given optional flags are of the form [-VV]')
self._parser.add_argument('--gdb', nargs='+', metavar=["DIR", "FLAGS (Optional)"], help='run the ctest tests for a smart contract project at the directory given optional flags are of the form [-VV]')
self._parser.add_argument('--deploy', nargs=2, metavar=["DIR", "ACCOUNT"], help='deploy a smart contract and ABI to account given')
self._parser.add_argument('--destroy-container', action='store_true', help='destroy context container <Warning, this will destroy your state and block log>')
self._parser.add_argument('--stop-container', action='store_true', help='stop the context container')
Expand Down
10 changes: 9 additions & 1 deletion src/dune/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,20 @@ def destroy(self):
self.execute_docker_cmd(['container', 'stop', self._container])
self.execute_docker_cmd(['container', 'rm', self._container])

def execute_cmd_at(self, dir, cmd):
proc = subprocess.Popen(['docker', 'container', 'exec', '-w', dir, self._container]+cmd)
proc.communicate()

def execute_cmd(self, cmd):
return self.execute_docker_cmd(['container', 'exec', self._container] + cmd)

def execute_interactive_cmd(self, cmd):
proc = subprocess.Popen(['docker', 'container', 'exec', '-i', self._container]+cmd)
proc.communicate()

def execute_cmd2(self, cmd):
proc = subprocess.Popen(['docker', 'container', 'exec', self._container] + cmd)
proc.communicate()

def execute_bg_cmd(self, cmd):
return self.execute_cmd(cmd+['&'])
return self.execute_cmd(cmd+['&'])
12 changes: 12 additions & 0 deletions src/dune/dune.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ def start_node(self, n, snapshot=None):
self.set_active(n)
print("Active ["+n.name()+"]")
print(stdout)
print(stderr)
else:
print(stderr)

Expand Down Expand Up @@ -285,6 +286,9 @@ def create_account(self, n, c=None, pub=None, priv=None):
def execute_cmd(self, args):
self._docker.execute_cmd2(args)

def execute_interactive_cmd(self, args):
self._docker.execute_interactive_cmd(args);

def build_cmake_proj(self, dir, flags):
container_dir = self._docker.abs_host_path(dir)
build_dir = container_dir+'/build'
Expand All @@ -293,6 +297,14 @@ def build_cmake_proj(self, dir, flags):
self._docker.execute_cmd2(['cmake', '-S', container_dir, '-B', build_dir]+flags)
self._docker.execute_cmd2(['cmake', '--build', build_dir])

def ctest_runner(self, dir, flags):
container_dir = self._docker.abs_host_path(dir)
self._docker.execute_cmd_at(container_dir, ['ctest']+flags)

def gdb(self, exec, flags):
container_exec = self._docker.abs_host_path(exec)
self._docker.execute_interactive_cmd(['gdb', container_exec]+flags)

def build_other_proj(self, cmd):
self._docker.execute_cmd2([cmd])

Expand Down