Skip to content

Commit

Permalink
Merge pull request #298 from zcoinofficial/refactor-mtp-L64
Browse files Browse the repository at this point in the history
MTP release
  • Loading branch information
Reuben Yap authored Oct 23, 2018
2 parents 3c7a181 + dd96f07 commit 0db59df
Show file tree
Hide file tree
Showing 83 changed files with 8,525 additions and 623 deletions.
14 changes: 14 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,24 @@ win32-build
test/config.ini
test/cache/*
src/test/buildenv.py
src/test/test_bitcoin

!src/leveldb*/Makefile

/doc/doxygen/

libzcoinconsensus.pc
contrib/devtools/split-debug.sh

src/test/test_bitcoin

libbitcoinconsensus.pc
qa/pull-tester/run-bitcoind-for-test.sh
qa/pull-tester/tests_config.py

# Qt Creator project files
zcoin.config
zcoin.creator
zcoin.creator.user
zcoin.files
zcoin.includes
5 changes: 3 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ dnl require autoconf 2.60 (AS_ECHO/AS_ECHO_N)
AC_PREREQ([2.60])
define(_CLIENT_VERSION_MAJOR, 0)
define(_CLIENT_VERSION_MINOR, 13)
define(_CLIENT_VERSION_REVISION, 6)
define(_CLIENT_VERSION_BUILD, 9)
define(_CLIENT_VERSION_REVISION, 7)
define(_CLIENT_VERSION_BUILD, 1)
define(_CLIENT_VERSION_IS_RELEASE, true)
define(_COPYRIGHT_YEAR, 2018)
define(_COPYRIGHT_HOLDERS,[The %s developers])
Expand Down Expand Up @@ -222,6 +222,7 @@ if test "x$CXXFLAGS_overridden" = "xno"; then
AX_CHECK_COMPILE_FLAG([-Wextra],[CXXFLAGS="$CXXFLAGS -Wextra"],,[[$CXXFLAG_WERROR]])
AX_CHECK_COMPILE_FLAG([-Wformat],[CXXFLAGS="$CXXFLAGS -Wformat"],,[[$CXXFLAG_WERROR]])
AX_CHECK_COMPILE_FLAG([-Wformat-security],[CXXFLAGS="$CXXFLAGS -Wformat-security"],,[[$CXXFLAG_WERROR]])
AX_CHECK_COMPILE_FLAG([-Wno-implicit-fallthrough],[CXXFLAGS="$CXXFLAGS -Wno-implicit-fallthrough"],,[[$CXXFLAG_WERROR]])

## Some compilers (gcc) ignore unknown -Wno-* options, but warn about all
## unknown options if any other warning is produced. Test the -Wfoo case, and
Expand Down
7 changes: 5 additions & 2 deletions contrib/gitian-build.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#!/usr/bin/env bash
# Copyright (c) 2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.

set -x

# What to do
sign=false
verify=false
Expand Down Expand Up @@ -258,7 +261,7 @@ echo "$me Building branch: ${COMMIT}"
# Setup build environment
if [[ $setup = true ]]
then
sudo apt-get install ruby apache2 git apt-cacher-ng python-vm-builder qemu-kvm qemu-utils
sudo apt-get install --assume-yes ruby apache2 git apt-cacher-ng python-vm-builder qemu-kvm qemu-utils

# Only clone valid git repositories
urlRegex='^(https?:\/\/*|git@*).*'
Expand All @@ -277,7 +280,7 @@ then
pushd ./gitian-builder
if [[ -n "$USE_LXC" ]]
then
sudo apt-get install lxc
sudo apt-get --assume-yes install lxc
bin/make-base-vm --suite trusty --arch amd64 --lxc
else
bin/make-base-vm --suite trusty --arch amd64
Expand Down
2 changes: 1 addition & 1 deletion contrib/gitian-descriptors/gitian-linux.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
name: "zcoin-linux-0.13.6"
name: "zcoin-linux-0.13.7"
enable_cache: true
suites:
- "trusty"
Expand Down
2 changes: 1 addition & 1 deletion contrib/gitian-descriptors/gitian-osx.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
name: "zcoin-osx-0.13.6"
name: "zcoin-osx-0.13.7"
enable_cache: true
suites:
- "trusty"
Expand Down
2 changes: 1 addition & 1 deletion contrib/gitian-descriptors/gitian-win.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
name: "zcoin-win-0.13.6"
name: "zcoin-win-0.13.7"
enable_cache: true
suites:
- "trusty"
Expand Down
1 change: 1 addition & 0 deletions depends/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ i686*
mips*
arm*
aarch64*
!Makefile
134 changes: 134 additions & 0 deletions doc/build_windows_wsl.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
# How to compile and execute Zcoin code on Windows 10

There are two possibilities of compiling Zcoin code on Windows 10.
Both of them are based on using [WSL/Ubuntu](https://msdn.microsoft.com/en-us/commandline/wsl/install_guide).
The main difference is in execution, using first method you will get .exe files, otherwise you need to use [Xming](http://www.straightrunning.com/XmingNotes/) to start **GUI**.

**We recommend using the first method**.

Prerequisites:

* Windows 10 x64
* [WSL/Ubuntu](https://msdn.microsoft.com/en-us/commandline/wsl/install_guide) installed
---
For the more complex second execution method, you need to install
* [Xming](http://www.straightrunning.com/XmingNotes/) latest version, if you are planning to compile using [unix compiling instruction](https://github.com/zcoinofficial/zcoin/blob/master/doc/build-unix.md)


## Pre common steps

1. Launch Ubuntu shell (search for Bash in the "Type here to search" box)
2. Upgrade outdated packages. This applies even if you just installed WSL.

```
sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get autoremove
```
3. Install build tools

`sudo apt-get install build-essential libtool autotools-dev automake pkg-config bsdmainutils git`

4. Make shared folder between two locations

Generally it's OK to read these files from generic Windows app, but Unix file permissions are stored in extended
attributes which are not properly updated by usual applications. For example, if you create a file/directory inside
WSL subsystem from Explorer it won't be visible by WSL program.

**To share files between two locations** we need to create a directory for the repository in your Windows home directory
and then create a link from the WSL to it:

* From Explorer create a directory named:

C:\Users\<username>\zcoin
* From Ubuntu bash window create a link to it:

ln -s /mnt/c/Users/<username>/zcoin zcoin

After creating link, please check that linked directory has blue font color, which means that is was successfully linked. Otherwise check path symbols. Error can be because of spaces, uppercase symbols e.t.c...

5. Clone git repository into newly created directory and go to the right branch

git clone https://github.com/zcoinofficial/zcoin.git
cd zcoin
If you are not authorized in git, configure git to always use LF and (optionally) specify your name/email. Global Windows git settings (if set)
won't be inherited if git is invoked from Ubuntu shell.

git config core.autocrlf input
git config user.name "Your Name"
git config user.email "your.email"
---
## First method - Windows execution files
1. Install cross-compilation tools

sudo apt-get install g++-mingw-w64-i686 mingw-w64-i686-dev g++-mingw-w64-x86-64 mingw-w64-x86-64-dev curl

1. Build fails when there are special symbols (space, parentheses etc) in path directories. Reset path to the simple one

export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

Also if WSL interop is enabled some parts might not get configured for cross-compilation and will ultimately fail.
Disable it for the WSL session:

sudo bash -c 'echo 0 > /proc/sys/fs/binfmt_misc/WSLInterop'

2. Dependencies won't compile in a directory shared with Windows. We need to copy everything to the space private to
WSL. Do not use .. here as it will lead you into different directory

cp -r depends ~/zcoin-depends

3. Go to depends folder and build dependencies (you may wish to build only 32-bit or 64-bit version)

cd ~/zcoin-depends
make HOST=i686-w64-mingw32 -j`nproc`
make HOST=x86_64-w64-mingw32 -j`nproc`
cd ~/zcoin
It takes a while. You need to do it only once unless you delete zcoin-depends directory

4. Generate configure script

./autogen.sh

5. Before starting to compile you need to update mingw alternatives

sudo update-alternatives --all

There are 3 choices for the alternative x86_64-w64-mingw32-gcc (providing /usr/bin/x86_64-w64-mingw32-gcc) - we need to select - **1** and press enter

Selection Path Priority Status
------------------------------------------------------------
0 /usr/bin/x86_64-w64-mingw32-gcc-win32 60 auto mode
* 1 /usr/bin/x86_64-w64-mingw32-gcc-posix 30 manual mode
2 /usr/bin/x86_64-w64-mingw32-gcc-win32 60 manual mode

Need to resolve **all mingw alternatives** in such a way.

Now do either step **7** OR step **8**, not both.

6. Build 32-bit debug build (from the zcoin root directory)

./configure --prefix=$HOME/zcoin-depends/i686-w64-mingw32
make -j`nproc`

7. Build 64-bit debug build (from the zcoin root directory)

./configure --prefix=$HOME/zcoin-depends/x86_64-w64-mingw32
make -j`nproc`

8. After check the directory to run GUI with __zcoin-qt.exe__

C:\Users\<username>\zcoin\src\qt
----
## Second method - Ubuntu + Xming
1. Use existing paper [build-unix](https://github.com/zcoinofficial/zcoin/blob/master/doc/build-unix.md) and
* Install all dependencies
* Build app
2. Start installed Xming in Windows
3. From Ubuntu bash window start output to Xming:

export DISPLAY=localhost:0.0
4. From Ubuntu bash window start zcoin-qt:

cd /mnt/c/Users/<username>/zcoin/src/qt
./zcoin-qt

4 changes: 2 additions & 2 deletions doc/debug-vs2017.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ Building

10. Build 32-bit debug build (from the zcoin root directory)
make clean
./configure --enable-debug --disable-hardening --disable-gcc-hardening --disable-linker-hardening --prefix=$HOME/zcoin-depends/i686-w64-mingw32
./configure "LDFLAGS=-g -Wl,--no-dynamicbase" --enable-debug --disable-hardening --disable-gcc-hardening --disable-linker-hardening --prefix=$HOME/zcoin-depends/i686-w64-mingw32
make -j4

11. Build 64-bit debug build (from the zcoin root directory)
make clean
./configure "CXXFLAGS=-Og -g" "CFLAGS=-Og -g" LDFLAGS=-g --disable-hardening --disable-gcc-hardening --disable-linker-hardening --prefix=$HOME/zcoin-depends/x86_64-w64-mingw32
./configure "CXXFLAGS=-Og -g" "CFLAGS=-Og -g" "LDFLAGS=-g -Wl,--no-dynamicbase" --disable-hardening --disable-gcc-hardening --disable-linker-hardening --prefix=$HOME/zcoin-depends/x86_64-w64-mingw32
make -j4
Note that --enable-debug won't work here because of buggy mingw toolchain

Expand Down
11 changes: 0 additions & 11 deletions libbitcoinconsensus.pc

This file was deleted.

22 changes: 20 additions & 2 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ BITCOIN_CORE_H = \
zmq/zmqnotificationinterface.h \
zmq/zmqpublishnotifier.h \
zerocoin.h \
zerocoin_params.h
zerocoin_params.h \
mtpstate.h

obj/build.h: FORCE
@$(MKDIR_P) $(builddir)/obj
Expand Down Expand Up @@ -251,6 +252,7 @@ libbitcoin_server_a_SOURCES = \
validationinterface.cpp \
versionbits.cpp \
zerocoin.cpp \
mtpstate.cpp \
$(BITCOIN_CORE_H)

if ENABLE_ZMQ
Expand Down Expand Up @@ -354,7 +356,21 @@ libbitcoin_consensus_a_SOURCES = \
crypto/Lyra2Z/sph_blake.h \
crypto/Lyra2Z/sph_types.h \
crypto/Lyra2Z/Sponge.c \
crypto/Lyra2Z/Sponge.h
crypto/Lyra2Z/Sponge.h \
crypto/MerkleTreeProof/mtp.h \
crypto/MerkleTreeProof/argon2.h \
crypto/MerkleTreeProof/thread.h \
crypto/MerkleTreeProof/merkle-tree.hpp \
crypto/MerkleTreeProof/core.h \
crypto/MerkleTreeProof/ref.h \
crypto/MerkleTreeProof/blake2/blake2.h \
crypto/MerkleTreeProof/blake2/blamka-round-opt.h \
crypto/MerkleTreeProof/blake2/blake2-impl.h \
crypto/MerkleTreeProof/blake2/blamka-round-ref.h \
crypto/MerkleTreeProof/thread.c \
crypto/MerkleTreeProof/core.c \
crypto/MerkleTreeProof/ref.c \
crypto/MerkleTreeProof/blake2/blake2b.c

# common: shared between zcoind, and zcoin-qt and non-server tools
libbitcoin_common_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
Expand Down Expand Up @@ -426,6 +442,8 @@ libbitcoin_util_a_SOURCES = \
libzerocoin/SpendMetaData.h \
libzerocoin/SpendMetaData.cpp \
libzerocoin/Zerocoin.h \
crypto/MerkleTreeProof/mtp.cpp \
crypto/MerkleTreeProof/merkle-tree.cpp \
$(BITCOIN_CORE_H)

if GLIBC_BACK_COMPAT
Expand Down
4 changes: 4 additions & 0 deletions src/Makefile.test.include
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ BITCOIN_TESTS =\
test/zerocoin_tests.cpp \
test/zerocoin_tests2.cpp \
test/zerocoin_tests3.cpp \
test/znode_tests.cpp \
test/mtp_trans_tests.cpp \
test/mtp_halving_tests.cpp \
test/mtp_tests.cpp \
test/arith_uint256_tests.cpp \
test/scriptnum10.h \
test/addrman_tests.cpp \
Expand Down
2 changes: 1 addition & 1 deletion src/chain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ CBlockIndex* CBlockIndex::GetAncestor(int height)
pindexWalk = pindexWalk->pskip;
heightWalk = heightSkip;
} else {
assert(pindexWalk->pprev);
//assert(pindexWalk->pprev);
pindexWalk = pindexWalk->pprev;
heightWalk--;
}
Expand Down
Loading

0 comments on commit 0db59df

Please sign in to comment.