Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
ibudisteanu committed Dec 18, 2021
2 parents 1f0646c + 6a59375 commit 43565c0
Show file tree
Hide file tree
Showing 123 changed files with 2,238 additions and 3,439 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ serverPoolDB*/

transactionsDB*/

## This gets added by running install scripts.
vue-Frontend/

certificates/ca_bundle.crt
certificates/certificate.crt
certificates/private.key
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v16
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
FROM node:8-alpine
FROM node:16-alpine

# Install build packages and npm global packages
RUN apk update && \
apk add --no-cache make gcc g++ python certbot && \
apk add --no-cache make gcc g++ python2 certbot && \
npm install -g cross-env webpack webpack-cli pm2

# Copy files
Expand All @@ -15,7 +15,7 @@ RUN npm install
RUN npm run build_terminal

# Clean Everything
RUN apk del make gcc g++ python && \
RUN apk del make gcc g++ python2 && \
rm -rf /tmp/* /var/cache/apk/* && \
npm cache clean --force

Expand Down
52 changes: 52 additions & 0 deletions Dockerfile.dev-env
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
FROM ubuntu:20.04

ENV TERM xterm
ENV TZ UTC
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

RUN mkdir -p /workspace/.nvm
RUN mkdir -p /workspace/Node-WebDollar
WORKDIR /workspace/
ENV HOME /workspace/

ENV NVM_DIR /workspace/.nvm
ENV NODE_VERSION 16

RUN apt-get update && apt-get install -y git curl wget build-essential software-properties-common clang cmake libtool autoconf psmisc opencl-headers ocl-icd-libopencl1 pciutils python2

# Install nvm with node and npm
RUN curl https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash \
&& . $NVM_DIR/nvm.sh \
&& nvm install $NODE_VERSION \
&& nvm alias default $NODE_VERSION \
&& nvm use default

ENV NODE_PATH $NVM_DIR/v$NODE_VERSION/lib/node_modules
ENV PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH

#RUN git clone https://github.com/WebDollar/Node-WebDollar.git miner

# Build the custom argon2 package
RUN git clone https://github.com/WebDollar/argon2
WORKDIR /workspace/argon2
RUN autoreconf -i
RUN bash configure
RUN cmake -DCMAKE_BUILD_TYPE=Release .
RUN make

ENV NODE_TLS_REJECT_UNAUTHORIZED 0
WORKDIR /workspace/Node-WebDollar
RUN mkdir -p ./dist_bundle/CPU/
RUN cp -a ../argon2/* dist_bundle/CPU/

ENV PYTHON /usr/bin/python2

# this container runs as root, add a dummy sudo
# creates a tiny script that just runs the command passed to it.
#> eval "$@"
#
# this is needed since many of the scripts in this project use sudo.
RUN echo "#!/bin/bash\\neval \"\$@\"" > /usr/bin/sudo && \
chmod +x /usr/bin/sudo

CMD [ "/bin/bash" ]
114 changes: 67 additions & 47 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ docker run -d --restart=always -v /webdollar/data:/blockchainDB3 -e NOSSL=true -

## 0. Node.js

**Required: v8.x**
It doesn't work with the new version 9.x
**Required: v16.x**

[nvm](https://github.com/nvm-sh/nvm) is the recommended tooling to get the right version. Simply run `nvm use` from the root of this project.


**Windows**: You can download Node.js from this URL: https://nodejs.org/en/download/

Expand Down Expand Up @@ -62,53 +64,14 @@ npm install --global --production windows-build-tools
npm install
```

#### 3.2 node-gyp on Linux

Installing Argon2 node.js
```shell
sudo apt install linuxbrew-wrapper
```
In case you receive some errors, try ```sudo apt-get -f install```

To check the version `gcc --version`
In case the GCC is not installed, install gcc `brew install gcc`

```shell
sudo apt-get install clang
npm install -g node-gyp
```

`gcc --version` will help you to find the version of GCC you have installed. Webdollar is known to work on GCC 5 and GCC 6.

Replace `g++-5` with your version
Verify if you can access `g++-5` or whatever version you have.
then install
```shell
env CXX=g++-5 npm install
env CXX=g++-5 npm install argon2
```
#### 3.2 Error for updating to 1.3.21

Tutorial based on https://github.com/ranisalt/node-argon2/issues/29



### Install x509 on Windows
Open a powershell terminal
```shell
npm install --python=python2.7
git clone https://github.com/ReadyTalk/win32.git
mkdir C:\OpenSSL-Win64\lib\
cp .\win32\msvc\lib\libeay32.lib C:\OpenSSL-Win64\lib\
rm -r -fo .\win32\
```
Or a command prompt (``cmd.exe``):
```shell
npm install --python=python2.7
git clone https://github.com/ReadyTalk/win32.git
md C:\OpenSSL-Win64\lib\
copy /y .\win32\msvc\lib\libeay32.lib C:\OpenSSL-Win64\lib\
rd /s /q .\win32\
```
Install node v16 via nvm
`nvm install 16`
`nvm use 16`
`nvm use default 16`

## 4. SSL (Secure Socket Layer) Certificate

Expand Down Expand Up @@ -147,7 +110,41 @@ If you are under a **router/firewall**, you need to port forward the port used b
npm run commands
```

#### 5.2 Running Full Node
#### 5.2 Run terminal non-interactive menu

After building the terminal project

```shell
npm run build_terminal_menu
npm run build_terminal_worker
```

it is possible to run the terminal project as a non-interactive script:

```shell
node --max_old_space_size=10240 dist_bundle/terminal-menu-bundle.js -- --import-address wallet.json --list-addresses --mining-address 0 --mine-in-pool https://webdollar.io/pool/url/here
```

the first part of the command (`node --max_old_space_size=10240 dist_bundle/terminal-menu-bundle.js`) launches the terminal project.

The next portion of the command (`--`) starts it in non-interactive mode.
Without `--`, the terminal menu defaults to interactive.

The next parts are the commands to run in order.

Alternatively, you can use the `./webd` command in the root of this project. The cli must be built first.
`./webd` assumes non-interactive, so `--` can be omitted from the command. To run interactively `npm run commands` works best.

```shell
./webd --import-address wallet.json --list-addresses --mining-address 0 --mine-in-pool https://webdollar.io/pool/url/here --set-password 'my 12 word password'
```

To display the list of commands, run:
```shell
./webd (-h|--help)
```

#### 5.3 Running Full Node

Install pm2.
```shell
Expand Down Expand Up @@ -211,6 +208,29 @@ npm run start

Follow the tutorial: [PM2 to run the Node Indefinitely](/docs/PM2-Tutorial.md)

## Development Environment

### Dockerized
It is possible to run the development environment in a docker container.
This is useful if you are unable to configure and install the custom argon2
flavor required by this project. The docker container has this project set up to be
built in it, and comes pre-installed with the tools you need for this project.

#### Building

Run `docker-compose build` to build the workspace container.

To force a rebuild, you can either remove the previous workspace (`docker rm webdollar-dev-env`)
or you can run `docker-compose build --no-cache`.

#### Running

Once you've build the workspace container, simply run it to launch an interactive shell with all the tools you need to develop.

`docker-compose run webdollar-dev-env`

This entire folder is mounted into the container, so any files you change in the workspace will be available to the container immediately.

# To do:

1. Pool Mining
Expand Down
62 changes: 46 additions & 16 deletions build-argon2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@ whitebg=$(tput setab 7 && tput bold)
stand=$(tput sgr0)

### System dialog VARS
showinfo="$green[info]$stand"
showerror="$red[error]$stand"
showexecute="$yellow[running]$stand"
showok="$magenta[OK]$stand"
showdone="$blue[DONE]$stand"
showinput="$cyan[input]$stand"
showwarning="$red[warning]$stand"
showremove="$green[removing]$stand"
shownone="$magenta[none]$stand"
redhashtag="$redbg$white#$stand"
abortte="$cyan[abort to Exit]$stand"
showport="$yellow[PORT]$stand"
show_hint="$green[hint]$stand"
showinfo="${green}[info]$stand"
showerror="${red}[error]$stand"
showexecute="${yellow}[running]$stand"
showok="${magenta}[OK]$stand"
showdone="${blue}[DONE]$stand"
showinput="${cyan}[input]$stand"
showwarning="${red}[warning]$stand"
showremove="${green}[removing]$stand"
shownone="${magenta}[none]$stand"
redhashtag="${redbg}${white}#$stand"
abortte="${cyan}[abort to Exit]$stand"
showport="${yellow}[PORT]$stand"
show_hint="${green}[hint]$stand"
##

###
Expand Down Expand Up @@ -73,6 +73,7 @@ export show_hint
###

### GENERAL_VARS
# shellcheck disable=SC2003
is_Linux=$(expr substr "$(uname -s)" 1 5)
get_const_global="src/consts/const_global.js"
###
Expand Down Expand Up @@ -100,10 +101,14 @@ if [[ $is_Linux == Linux ]]; then
if cat /etc/*release | grep -q -o -m 1 Ubuntu; then # check cmake
if cmake --version | grep "3.10.*" > /dev/null || cmake --version | grep "3.12.*" > /dev/null; then
if cmake --version | grep "3.*.*" > /dev/null || cmake --version | grep "3.12.*" > /dev/null; then
echo "$showok ${blue}cmake$stand is already installed!"
elif ! which cmake; then
echo "$showexecute Installing cmake..." && sudo apt install -y cmake
elif ! cmake --version | grep "3.5.*" > /dev/null; then
if [[ $(cat /etc/*release | grep -m 1 VERSION | cut -d '"' -f2 | awk '{print$1}') == 18* ]]; then
Expand Down Expand Up @@ -623,7 +628,7 @@ fi
### ASK_USER_FUNCTION_END
### NODE_WEBDOLLAR_START
if [[ $(grep "name" package.json | sed s'/[",]//g' | awk '{print $2}') == node-webdollar ]]; then
if [[ $(grep "name" package.json | sed s'/[",]//g' | awk '{print $2}') =~ [node-webdollarwebdollar] ]]; then
if [[ $is_Linux == Linux ]]; then
Expand Down Expand Up @@ -652,11 +657,17 @@ if [[ $is_Linux == Linux ]]; then
echo "$showok CPU folder inside dist_bundle exists!"
echo "$showexecute Copying argon2/* files to dist_bundle/CPU" && cp -a argon2/* dist_bundle/CPU/
if [ -d argon2/.libs ]; then
cp -a argon2/.libs dist_bundle/CPU/
fi
else
if [[ ! -d dist_bundle/CPU ]]; then
echo "$showerror CPU folder inside dist_bundle not found!"
echo "$showexecute Creating one now..." && mkdir dist_bundle/CPU
echo "$showexecute Copying argon2/* files to dist_bundle/CPU" && cp -a argon2/* dist_bundle/CPU/
if [ -d argon2/.libs ]; then
cp -a argon2/.libs dist_bundle/CPU/
fi
fi
fi
Expand Down Expand Up @@ -684,11 +695,17 @@ if [[ $is_Linux == Linux ]]; then
echo "$showok CPU folder inside dist_bundle exists!"
echo "$showexecute Copying argon2/* files to dist_bundle/CPU" && cp -a argon2/* dist_bundle/CPU/
if [ -d argon2/.libs ]; then
cp -a argon2/.libs dist_bundle/CPU/
fi
else
if [[ ! -d dist_bundle/CPU ]]; then
echo "$showerror CPU folder inside dist_bundle not found!"
echo "$showexecute Creating one now..." && mkdir dist_bundle/CPU
echo "$showexecute Copying argon2/* files to dist_bundle/CPU" && cp -a argon2/* dist_bundle/CPU/
if [ -d argon2/.libs ]; then
cp -a argon2/.libs dist_bundle/CPU/
fi
fi
fi
else
Expand Down Expand Up @@ -721,11 +738,18 @@ if [[ $(lspci | grep VGA | grep -m 1 "controller:" | awk '{print$5}') == NVIDIA
echo "$showok GPU folder inside dist_bundle exists!"
echo "$showexecute Copying argon2-gpu/* files to dist_bundle/GPU" && cp -a argon2-gpu/* dist_bundle/GPU/
if [ -d argon2-gpu/.libs ]; then
cp -a argon2-gpu/.libs dist_bundle/GPU/
fi
else
if [[ ! -d dist_bundle/GPU ]]; then
echo "$showerror GPU folder inside dist_bundle not found!"
echo "$showexecute Creating one now..." && mkdir dist_bundle/GPU
echo "$showexecute Copying argon2-gpu/* files to dist_bundle/GPU" && cp -a argon2-gpu/* dist_bundle/GPU/
if [ -d argon2-gpu/.libs ]; then
cp -a argon2-gpu/.libs dist_bundle/GPU/
fi
fi
fi
Expand All @@ -750,11 +774,17 @@ if [[ $(lspci | grep VGA | grep -m 1 "controller:" | awk '{print$5}') == NVIDIA
echo "$showok GPU folder inside dist_bundle exists!"
echo "$showexecute Copying argon2-gpu/* files to dist_bundle/GPU" && cp -a argon2-gpu/* dist_bundle/GPU/
if [ -d argon2-gpu/.libs ]; then
cp -a argon2-gpu/.libs dist_bundle/GPU/
fi
else
if [[ ! -d dist_bundle/GPU ]]; then
echo "$showerror GPU folder inside dist_bundle not found!"
echo "$showexecute Creating one now..." && mkdir dist_bundle/GPU
echo "$showexecute Copying argon2-gpu/* files to dist_bundle/GPU" && cp -a argon2-gpu/* dist_bundle/GPU/
if [ -d argon2-gpu/.libs ]; then
cp -a argon2-gpu/.libs dist_bundle/GPU/
fi
fi
fi
else
Expand Down Expand Up @@ -798,7 +828,7 @@ else ### Node
else
if [[ ! $(ls -d argon2) == argon2 ]]; then
echo "$showerror You are not inside ${yellow}Node-WebDollar$stand folder."
echo "$showinfo Run this script inside ${yellow}Node-WebDollar$stand folder to compile ${yellow}argon2$stand."
echo -e "$showinfo Run this script inside ${yellow}Node-WebDollar$stand folder to compile ${yellow}argon2$stand"
fi
fi
fi ### NODE_WEBDOLLAR_END
Loading

0 comments on commit 43565c0

Please sign in to comment.