Implement a hard fork to normalize claim names
Apply (self) review feedback Clean deps required for boost to rebuild with icu support (for now) Normalization bug fixes and improvements Clang-formatting
This commit is contained in:
parent
11542b8bf0
commit
3edbb2627e
24 changed files with 1122 additions and 380 deletions
120
build-aux/m4/ax_boost_locale.m4
Normal file
120
build-aux/m4/ax_boost_locale.m4
Normal file
|
@ -0,0 +1,120 @@
|
|||
# ===========================================================================
|
||||
# https://www.gnu.org/software/autoconf-archive/ax_boost_locale.html
|
||||
# ===========================================================================
|
||||
#
|
||||
# SYNOPSIS
|
||||
#
|
||||
# AX_BOOST_LOCALE
|
||||
#
|
||||
# DESCRIPTION
|
||||
#
|
||||
# Test for System library from the Boost C++ libraries. The macro requires
|
||||
# a preceding call to AX_BOOST_BASE. Further documentation is available at
|
||||
# <http://randspringer.de/boost/index.html>.
|
||||
#
|
||||
# This macro calls:
|
||||
#
|
||||
# AC_SUBST(BOOST_LOCALE_LIB)
|
||||
#
|
||||
# And sets:
|
||||
#
|
||||
# HAVE_BOOST_LOCALE
|
||||
#
|
||||
# LICENSE
|
||||
#
|
||||
# Copyright (c) 2012 Xiyue Deng <manphiz@gmail.com>
|
||||
#
|
||||
# Copying and distribution of this file, with or without modification, are
|
||||
# permitted in any medium without royalty provided the copyright notice
|
||||
# and this notice are preserved. This file is offered as-is, without any
|
||||
# warranty.
|
||||
|
||||
#serial 2
|
||||
|
||||
AC_DEFUN([AX_BOOST_LOCALE],
|
||||
[
|
||||
AC_ARG_WITH([boost-locale],
|
||||
AS_HELP_STRING([--with-boost-locale@<:@=special-lib@:>@],
|
||||
[use the Locale library from boost - it is possible to specify a certain library for the linker
|
||||
e.g. --with-boost-locale=boost_locale-gcc-mt ]),
|
||||
[
|
||||
if test "$withval" = "no"; then
|
||||
want_boost="no"
|
||||
elif test "$withval" = "yes"; then
|
||||
want_boost="yes"
|
||||
ax_boost_user_locale_lib=""
|
||||
else
|
||||
want_boost="yes"
|
||||
ax_boost_user_locale_lib="$withval"
|
||||
fi
|
||||
],
|
||||
[want_boost="yes"]
|
||||
)
|
||||
|
||||
if test "x$want_boost" = "xyes"; then
|
||||
AC_REQUIRE([AC_PROG_CC])
|
||||
AC_REQUIRE([AC_CANONICAL_BUILD])
|
||||
CPPFLAGS_SAVED="$CPPFLAGS"
|
||||
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
|
||||
export CPPFLAGS
|
||||
|
||||
LDFLAGS_SAVED="$LDFLAGS"
|
||||
LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
|
||||
export LDFLAGS
|
||||
|
||||
AC_CACHE_CHECK(whether the Boost::Locale library is available,
|
||||
ax_cv_boost_locale,
|
||||
[AC_LANG_PUSH([C++])
|
||||
CXXFLAGS_SAVE=$CXXFLAGS
|
||||
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <boost/locale.hpp>]],
|
||||
[[boost::locale::generator gen;
|
||||
std::locale::global(gen(""));]])],
|
||||
ax_cv_boost_locale=yes, ax_cv_boost_locale=no)
|
||||
CXXFLAGS=$CXXFLAGS_SAVE
|
||||
AC_LANG_POP([C++])
|
||||
])
|
||||
if test "x$ax_cv_boost_locale" = "xyes"; then
|
||||
AC_SUBST(BOOST_CPPFLAGS)
|
||||
|
||||
AC_DEFINE(HAVE_BOOST_LOCALE,,[define if the Boost::Locale library is available])
|
||||
BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'`
|
||||
|
||||
LDFLAGS_SAVE=$LDFLAGS
|
||||
if test "x$ax_boost_user_locale_lib" = "x"; then
|
||||
for libextension in `ls $BOOSTLIBDIR/libboost_locale*.so* $BOOSTLIBDIR/libboost_locale*.dylib* $BOOSTLIBDIR/libboost_locale*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^lib\(boost_locale.*\)\.so.*$;\1;' -e 's;^lib\(boost_locale.*\)\.dylib.*$;\1;' -e 's;^lib\(boost_locale.*\)\.a.*$;\1;'` ; do
|
||||
ax_lib=${libextension}
|
||||
AC_CHECK_LIB($ax_lib, exit,
|
||||
[BOOST_LOCALE_LIB="-l$ax_lib"; AC_SUBST(BOOST_LOCALE_LIB) link_locale="yes"; break],
|
||||
[link_locale="no"])
|
||||
done
|
||||
if test "x$link_locale" != "xyes"; then
|
||||
for libextension in `ls $BOOSTLIBDIR/boost_locale*.dll* $BOOSTLIBDIR/boost_locale*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^\(boost_locale.*\)\.dll.*$;\1;' -e 's;^\(boost_locale.*\)\.a.*$;\1;'` ; do
|
||||
ax_lib=${libextension}
|
||||
AC_CHECK_LIB($ax_lib, exit,
|
||||
[BOOST_LOCALE_LIB="-l$ax_lib"; AC_SUBST(BOOST_LOCALE_LIB) link_locale="yes"; break],
|
||||
[link_locale="no"])
|
||||
done
|
||||
fi
|
||||
|
||||
else
|
||||
for ax_lib in $ax_boost_user_locale_lib boost_locale-$ax_boost_user_locale_lib; do
|
||||
AC_CHECK_LIB($ax_lib, exit,
|
||||
[BOOST_LOCALE_LIB="-l$ax_lib"; AC_SUBST(BOOST_LOCALE_LIB) link_locale="yes"; break],
|
||||
[link_locale="no"])
|
||||
done
|
||||
|
||||
fi
|
||||
if test "x$ax_lib" = "x"; then
|
||||
AC_MSG_ERROR(Could not find a version of the library!)
|
||||
fi
|
||||
if test "x$link_locale" = "xno"; then
|
||||
AC_MSG_ERROR(Could not link against $ax_lib !)
|
||||
fi
|
||||
fi
|
||||
|
||||
CPPFLAGS="$CPPFLAGS_SAVED"
|
||||
LDFLAGS="$LDFLAGS_SAVED"
|
||||
fi
|
||||
])
|
||||
|
45
configure.ac
45
configure.ac
|
@ -134,6 +134,12 @@ AC_ARG_WITH([qrencode],
|
|||
[use_qr=$withval],
|
||||
[use_qr=auto])
|
||||
|
||||
AC_ARG_WITH([icu],
|
||||
[AS_HELP_STRING([--with-icu],
|
||||
[Required ICU root path])],
|
||||
[ICU_PREFIX=$withval],
|
||||
[ICU_PREFIX=auto])
|
||||
|
||||
AC_ARG_ENABLE([hardening],
|
||||
[AS_HELP_STRING([--disable-hardening],
|
||||
[do not attempt to harden the resulting executables (default is to harden)])],
|
||||
|
@ -200,7 +206,7 @@ fi
|
|||
## compatibility with the legacy buildsystem.
|
||||
##
|
||||
if test "x$CXXFLAGS_overridden" = "xno"; then
|
||||
CXXFLAGS="$CXXFLAGS -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter -Wno-self-assign"
|
||||
CXXFLAGS="$CXXFLAGS -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter"
|
||||
fi
|
||||
CPPFLAGS="$CPPFLAGS -DHAVE_BUILD_INFO -D__STDC_FORMAT_MACROS"
|
||||
|
||||
|
@ -583,6 +589,7 @@ AX_BOOST_FILESYSTEM
|
|||
AX_BOOST_PROGRAM_OPTIONS
|
||||
AX_BOOST_THREAD
|
||||
AX_BOOST_CHRONO
|
||||
AX_BOOST_LOCALE
|
||||
|
||||
|
||||
if test x$use_reduce_exports = xyes; then
|
||||
|
@ -645,7 +652,7 @@ fi
|
|||
|
||||
if test x$use_boost = xyes; then
|
||||
|
||||
BOOST_LIBS="$BOOST_LDFLAGS $BOOST_SYSTEM_LIB $BOOST_FILESYSTEM_LIB $BOOST_PROGRAM_OPTIONS_LIB $BOOST_THREAD_LIB $BOOST_CHRONO_LIB"
|
||||
BOOST_LIBS="$BOOST_LDFLAGS $BOOST_SYSTEM_LIB $BOOST_FILESYSTEM_LIB $BOOST_PROGRAM_OPTIONS_LIB $BOOST_THREAD_LIB $BOOST_CHRONO_LIB $BOOST_LOCALE_LIB"
|
||||
|
||||
|
||||
dnl If boost (prior to 1.57) was built without c++11, it emulated scoped enums
|
||||
|
@ -746,8 +753,19 @@ if test x$use_pkgconfig = xyes; then
|
|||
m4_ifdef(
|
||||
[PKG_CHECK_MODULES],
|
||||
[
|
||||
ICU_CPPFLAGS="-I$ICU_PREFIX/include"
|
||||
CPPFLAGS="$ICU_CPPFLAGS $CPPFLAGS"
|
||||
ICU_LIBS="-L$ICU_PREFIX/lib -licui18n -licuuc -licudata -dl"
|
||||
AC_MSG_WARN([Using ICU_CPPFLAGS $ICU_CPPFLAGS])
|
||||
AC_MSG_WARN([Using CPPFLAGS $CPPFLAGS])
|
||||
|
||||
AC_CHECK_HEADER([unicode/errorcode.h],,AC_MSG_ERROR(libicu headers missing))
|
||||
AC_CHECK_LIB([icudata], [main], ICU_LIBS="-L$ICU_PREFIX/lib -licui18n -licuuc -licudata -dl",
|
||||
AC_CHECK_LIB([icu18n], [main],ICU_LIBS=$ICU_LIBS, ICU_LIBS="-L$ICU_PREFIX/lib -lsicudt -lsicuin -lsicuio -lsicule -lsiculx -lsicutest -lsicutu -lsicuuc"))
|
||||
|
||||
PKG_CHECK_MODULES([SSL], [libssl],, [AC_MSG_ERROR(openssl not found.)])
|
||||
PKG_CHECK_MODULES([CRYPTO], [libcrypto],,[AC_MSG_ERROR(libcrypto not found.)])
|
||||
|
||||
BITCOIN_QT_CHECK([PKG_CHECK_MODULES([PROTOBUF], [protobuf], [have_protobuf=yes], [BITCOIN_QT_FAIL(libprotobuf not found)])])
|
||||
if test x$use_qr != xno; then
|
||||
BITCOIN_QT_CHECK([PKG_CHECK_MODULES([QR], [libqrencode], [have_qrencode=yes], [have_qrencode=no])])
|
||||
|
@ -771,11 +789,23 @@ if test x$use_pkgconfig = xyes; then
|
|||
]
|
||||
)
|
||||
else
|
||||
ICU_CPPFLAGS="-I$ICU_PREFIX/include"
|
||||
CPPFLAGS="$ICU_CPPFLAGS $CPPFLAGS"
|
||||
ICU_LIBS="-L$ICU_PREFIX/lib -licui18n -licuuc -licudata -dl"
|
||||
|
||||
AC_MSG_WARN([Using ICU_CPPFLAGS $ICU_CPPFLAGS])
|
||||
AC_MSG_WARN([Using ICU_LIBS $ICU_LIBS])
|
||||
AC_MSG_WARN([Using CPPFLAGS $CPPFLAGS])
|
||||
|
||||
AC_CHECK_HEADER([unicode/errorcode.h],,AC_MSG_ERROR(libicu headers missing))
|
||||
AC_CHECK_LIB([icudata], [main], ICU_LIBS="-L$ICU_PREFIX/lib -licui18n -licuuc -licudata -dl",
|
||||
AC_CHECK_LIB([icu18n], [main],ICU_LIBS=$ICU_LIBS, ICU_LIBS="-L$ICU_PREFIX/lib -lsicudt -lsicuin -lsicuio -lsicule -lsiculx -lsicutest -lsicutu -lsicuuc"))
|
||||
|
||||
AC_CHECK_HEADER([openssl/crypto.h],,AC_MSG_ERROR(libcrypto headers missing))
|
||||
AC_CHECK_LIB([crypto], [main],CRYPTO_LIBS=-lcrypto, AC_MSG_ERROR(libcrypto missing))
|
||||
AC_CHECK_LIB([crypto], [main],CRYPTO_LIBS=-lcrypto, AC_MSG_ERROR(libcrypto missing))
|
||||
|
||||
AC_CHECK_HEADER([openssl/ssl.h],, AC_MSG_ERROR(libssl headers missing),)
|
||||
AC_CHECK_LIB([ssl], [main],SSL_LIBS=-lssl, AC_MSG_ERROR(libssl missing))
|
||||
AC_CHECK_LIB([ssl], [main],SSL_LIBS=-lssl, AC_MSG_ERROR(libssl missing))
|
||||
|
||||
if test x$build_bitcoin_utils$build_bitcoind$bitcoin_enable_qt$use_tests != xnononono; then
|
||||
AC_CHECK_HEADER([event2/event.h],, AC_MSG_ERROR(libevent headers missing),)
|
||||
|
@ -846,9 +876,9 @@ AC_SUBST(UNIVALUE_LIBS)
|
|||
|
||||
CXXFLAGS_TEMP="$CXXFLAGS"
|
||||
LIBS_TEMP="$LIBS"
|
||||
CXXFLAGS="$CXXFLAGS $SSL_CFLAGS $CRYPTO_CFLAGS"
|
||||
CXXFLAGS="$CXXFLAGS $CPPFLAGS $SSL_CFLAGS $CRYPTO_CFLAGS $ICU_PREFIX/include"
|
||||
LIBS="$LIBS $SSL_LIBS $CRYPTO_LIBS"
|
||||
AC_CHECK_HEADER([openssl/ec.h],, AC_MSG_ERROR(OpenSSL ec header missing),)
|
||||
#AC_CHECK_HEADER([openssl/ec.h],, AC_MSG_ERROR(OpenSSL ec header missing),)
|
||||
CXXFLAGS="$CXXFLAGS_TEMP"
|
||||
LIBS="$LIBS_TEMP"
|
||||
|
||||
|
@ -1039,6 +1069,9 @@ AC_SUBST(LIBTOOL_APP_LDFLAGS)
|
|||
AC_SUBST(USE_UPNP)
|
||||
AC_SUBST(USE_QRCODE)
|
||||
AC_SUBST(BOOST_LIBS)
|
||||
AC_SUBST(ICU_PREFIX)
|
||||
AC_SUBST(ICU_CPPFLAGS)
|
||||
AC_SUBST(ICU_LIBS)
|
||||
AC_SUBST(TESTDEFS)
|
||||
AC_SUBST(LEVELDB_TARGET_FLAGS)
|
||||
AC_SUBST(MINIUPNPC_CPPFLAGS)
|
||||
|
|
|
@ -113,6 +113,7 @@ $(host_prefix)/.stamp_$(final_build_id): $(native_packages) $(packages)
|
|||
$(AT)mkdir -p $(@D)
|
||||
$(AT)echo copying packages: $^
|
||||
$(AT)echo to: $(@D)
|
||||
$(AT)echo "$(@D)" > /tmp/icu_install_dir
|
||||
$(AT)cd $(@D); $(foreach package,$^, tar xf $($(package)_cached); )
|
||||
$(AT)touch $@
|
||||
|
||||
|
|
|
@ -7,8 +7,9 @@ $(package)_sha256_hash=727a932322d94287b62abb1bd2d41723eec4356a7728909e38adb65ca
|
|||
define $(package)_set_vars
|
||||
$(package)_config_opts_release=variant=release
|
||||
$(package)_config_opts_debug=variant=debug
|
||||
$(package)_config_opts=--layout=tagged --build-type=complete --user-config=user-config.jam
|
||||
$(package)_config_opts+=threading=multi link=static -sNO_BZIP2=1 -sNO_ZLIB=1
|
||||
$(package)_config_opts=--layout=tagged --build-type=complete --user-config=user-config.jam boost.locale.iconv=off boost.locale.posix=off
|
||||
$(package)_config_opts+=threading=multi link=static -sNO_BZIP2=1 -sNO_ZLIB=1 -sICU_PATH=$(shell cat /tmp/icu_install_dir)
|
||||
$(package)_config_opts+=-sICU_LINK="-L$(shell cat /tmp/icu_install_dir) -lsicudt -lsicuin -lsicuio -lsicule -lsiculx -lsicutest -lsicutu -lsicuuc"
|
||||
$(package)_config_opts_linux=threadapi=pthread runtime-link=shared
|
||||
$(package)_config_opts_darwin=--toolset=darwin-4.2.1 runtime-link=shared
|
||||
$(package)_config_opts_mingw32=binary-format=pe target-os=windows threadapi=win32 runtime-link=static
|
||||
|
@ -19,9 +20,17 @@ $(package)_toolset_$(host_os)=gcc
|
|||
$(package)_archiver_$(host_os)=$($(package)_ar)
|
||||
$(package)_toolset_darwin=darwin
|
||||
$(package)_archiver_darwin=$($(package)_libtool)
|
||||
$(package)_config_libraries=chrono,filesystem,program_options,system,thread,test
|
||||
$(package)_config_libraries=chrono,filesystem,program_options,system,locale,regex,thread,test
|
||||
$(package)_cxxflags=-fvisibility=hidden
|
||||
$(package)_cxxflags_linux=-fPIC
|
||||
$(package)_config_env+=BOOST_ICU_ICONV="off"
|
||||
$(package)_config_env+=BOOST_ICU_POSIX="off"
|
||||
$(package)_config_env+=ICU_PREFIX=$(shell cat /tmp/icu_install_dir)
|
||||
$(package)_config_env+=BOOST_ICU_LIBS="-L$(shell cat /tmp/icu_install_dir) -lsicudt -lsicuin -lsicuio -lsicule -lsiculx -lsicutest -lsicutu -lsicuuc"
|
||||
$(package)_build_env+=BOOST_ICU_ICONV="off"
|
||||
$(package)_build_env+=BOOST_ICU_POSIX="off"
|
||||
$(package)_build_env+=ICU_PREFIX=$(shell cat /tmp/icu_install_dir)
|
||||
$(package)_build_env+=BOOST_ICU_LIBS="-L$(shell cat /tmp/icu_install_dir) -lsicudt -lsicuin -lsicuio -lsicule -lsiculx -lsicutest -lsicutu -lsicuuc"
|
||||
endef
|
||||
|
||||
define $(package)_preprocess_cmds
|
||||
|
@ -29,13 +38,13 @@ define $(package)_preprocess_cmds
|
|||
endef
|
||||
|
||||
define $(package)_config_cmds
|
||||
./bootstrap.sh --without-icu --with-libraries=$(boost_config_libraries)
|
||||
echo "int main() { return 0; }" > ./libs/locale/build/has_icu_test.cpp && echo "int main() { return 0; }" > ./libs/regex/build/has_icu_test.cpp && ./bootstrap.sh --with-icu=$(shell cat /tmp/icu_install_dir) --with-libraries=$(boost_config_libraries)
|
||||
endef
|
||||
|
||||
define $(package)_build_cmds
|
||||
./b2 -d2 -j2 -d1 --prefix=$($(package)_staging_prefix_dir) $($(package)_config_opts) stage
|
||||
./b2 link=static cxxflags=-fPIC -d0 -j4 --prefix=$($(package)_staging_prefix_dir) $($(package)_config_opts)
|
||||
endef
|
||||
|
||||
define $(package)_stage_cmds
|
||||
./b2 -d0 -j4 --prefix=$($(package)_staging_prefix_dir) $($(package)_config_opts) install
|
||||
./b2 link=static cxxflags=-fPIC -d0 -j4 --prefix=$($(package)_staging_prefix_dir) $($(package)_config_opts) install
|
||||
endef
|
||||
|
|
28
depends/packages/icu.mk
Normal file
28
depends/packages/icu.mk
Normal file
|
@ -0,0 +1,28 @@
|
|||
package=icu
|
||||
$(package)_version=55_1
|
||||
$(package)_download_path=http://download.icu-project.org/files/icu4c/55.1
|
||||
$(package)_file_name=$(package)4c-$($(package)_version)-src.tgz
|
||||
$(package)_sha256_hash=e16b22cbefdd354bec114541f7849a12f8fc2015320ca5282ee4fd787571457b
|
||||
$(package)_build_subdir=source
|
||||
|
||||
define $(package)_set_vars
|
||||
$(package)_config_opts=--enable-debug --disable-release --host=i686-w64-mingw32 --with-cross-build=/tmp/icu_staging/icu/source --enable-extras=no --enable-strict=no -enable-static --enable-shared=no --enable-tests=no --enable-samples=no --enable-dyload=no
|
||||
$(package)_config_opts_release=--disable-debug --enable-release
|
||||
$(package)_config_opts_mingw32=--host=i686-w64-mingw32
|
||||
$(package)_config_opts_linux=--with-pic
|
||||
endef
|
||||
|
||||
define $(package)_config_cmds
|
||||
$($(package)_autoconf)
|
||||
endef
|
||||
|
||||
define $(package)_build_cmds
|
||||
$(MAKE)
|
||||
endef
|
||||
|
||||
define $(package)_stage_cmds
|
||||
$(MAKE) DESTDIR=$($(package)_staging_dir) install
|
||||
endef
|
||||
|
||||
define $(package)_postprocess_cmds
|
||||
endef
|
|
@ -1,4 +1,4 @@
|
|||
packages:=boost openssl libevent
|
||||
packages:=icu boost openssl libevent
|
||||
darwin_packages:=zeromq
|
||||
linux_packages:=zeromq
|
||||
native_packages := native_ccache native_comparisontool
|
||||
|
@ -10,7 +10,6 @@ qt_linux_packages= qt expat dbus libxcb xcb_proto libXau xproto freetype fontcon
|
|||
qt_darwin_packages=qt
|
||||
qt_mingw32_packages=qt
|
||||
|
||||
|
||||
wallet_packages=bdb
|
||||
|
||||
upnp_packages=miniupnpc
|
||||
|
|
|
@ -6,13 +6,31 @@ sudo apt-get update
|
|||
sudo apt-get install -y --no-install-recommends \
|
||||
g++-mingw-w64-i686 mingw-w64-i686-dev g++-mingw-w64-x86-64 \
|
||||
mingw-w64-x86-64-dev build-essential libtool autotools-dev automake pkg-config \
|
||||
libssl-dev libevent-dev bsdmainutils curl ca-certificates
|
||||
libssl-dev libevent-dev bsdmainutils curl ca-certificates libicu-dev
|
||||
|
||||
#################################################################
|
||||
# Build ICU for Linux first so that we can cross compile it below
|
||||
#################################################################
|
||||
staging_dir=/tmp/icu_staging
|
||||
icu_linux_dir=$staging_dir/build_icu_linux
|
||||
mkdir -p $staging_dir
|
||||
pushd $staging_dir
|
||||
wget http://download.icu-project.org/files/icu4c/55.1/icu4c-55_1-src.tgz
|
||||
tar -xvzf icu4c-55_1-src.tgz
|
||||
pushd icu/source
|
||||
./runConfigureICU Linux --prefix=$icu_linux_dir --enable-extras=no --enable-strict=no -enable-static --enable-shared=no --enable-tests=no --enable-samples=no --enable-dyload=no
|
||||
make
|
||||
make install
|
||||
popd
|
||||
popd
|
||||
|
||||
cd depends
|
||||
make HOST=i686-w64-mingw32 NO_QT=1
|
||||
cd ..
|
||||
patch -p1 < packaging/remove_consensus.patch
|
||||
./autogen.sh
|
||||
./configure --prefix=`pwd`/depends/i686-w64-mingw32 --without-gui
|
||||
icu_mingw_dir=$(cat /tmp/icu_install_dir)
|
||||
CC="i686-w64-mingw32-gcc" ./configure --prefix=`pwd`/depends/i686-w64-mingw32 --host=i686-w64-mingw32 --build=i686-w64-mingw32 --without-gui --with-icu=$($icu_mingw_dir/bin/icu-config --prefix) --enable-static --disable-shared
|
||||
make
|
||||
|
||||
rm -rf $staging_dir
|
||||
|
|
|
@ -26,8 +26,8 @@ function HELP {
|
|||
exit 1
|
||||
}
|
||||
|
||||
CLONE=true
|
||||
CLEAN=false
|
||||
CLONE=false
|
||||
CLEAN=true
|
||||
CHECK_CODE_FORMAT=false
|
||||
BUILD_DEPENDENCIES=true
|
||||
BUILD_LBRYCRD=true
|
||||
|
@ -106,24 +106,22 @@ else
|
|||
# this file is created when the build starts
|
||||
START_TIME_FILE="$TRAVIS_BUILD_DIR/start_time"
|
||||
fi
|
||||
if [ ! -f "${START_TIME_FILE}" ]; then
|
||||
date +%s > "${START_TIME_FILE}"
|
||||
fi
|
||||
|
||||
rm -f ${START_TIME_FILE}
|
||||
date +%s > ${START_TIME_FILE}
|
||||
|
||||
NEXT_TIME=60
|
||||
function exit_at_40() {
|
||||
function exit_at_60() {
|
||||
if [ -f "${START_TIME_FILE}" ]; then
|
||||
NOW=$(date +%s)
|
||||
START=$(cat "${START_TIME_FILE}")
|
||||
TIMEOUT_SECS=2400 # 40 * 60
|
||||
TIMEOUT_SECS=3600 # 60 * 60
|
||||
TIME=$((NOW - START))
|
||||
if (( TIME > NEXT_TIME )); then
|
||||
echo "Build has taken $((TIME / 60)) minutes: $1"
|
||||
NEXT_TIME=$((TIME + 60))
|
||||
fi
|
||||
if [ "$TIMEOUT" = true ] && (( TIME > TIMEOUT_SECS )); then
|
||||
echo 'Exiting at 40 minutes to allow the cache to populate'
|
||||
echo 'Exiting at 60 minutes to allow the cache to populate'
|
||||
OUTPUT_LOG=false
|
||||
exit 1
|
||||
fi
|
||||
|
@ -145,7 +143,7 @@ function wait_and_echo() {
|
|||
# loop until the process is no longer running
|
||||
# check every $SLEEP seconds, echoing a message every minute
|
||||
while (ps -p "${PID}" > /dev/null); do
|
||||
exit_at_40 "$2"
|
||||
exit_at_60 "$2"
|
||||
sleep "${SLEEP}"
|
||||
done
|
||||
# restore the xtrace setting
|
||||
|
@ -244,8 +242,10 @@ function install_apt_packages() {
|
|||
|
||||
function build_dependencies() {
|
||||
if [ "${OS_NAME}" = "osx" ]; then
|
||||
PARALLEL="-j $(sysctl -n hw.ncpu)"
|
||||
install_brew_packages
|
||||
else
|
||||
PARALLEL="-j $(grep -c processor /proc/cpuinfo)"
|
||||
install_apt_packages
|
||||
fi
|
||||
|
||||
|
@ -260,8 +260,9 @@ function build_dependencies() {
|
|||
# TODO: if the repo exists, make sure its clean: revert to head.
|
||||
mkdir -p "${LOG_DIR}"
|
||||
|
||||
build_dependency "${BDB_PREFIX}" "${LOG_DIR}/bdb_build.log" build_bdb
|
||||
build_dependency "${OPENSSL_PREFIX}" "${LOG_DIR}/openssl_build.log" build_openssl
|
||||
build_dependency "${ICU_PREFIX}" "${LOG_DIR}/icu_build.log" build_icu
|
||||
build_dependency "${BDB_PREFIX}" "${LOG_DIR}/bdb_build.log" build_bdb
|
||||
|
||||
set +u
|
||||
export PKG_CONFIG_PATH="${PKG_CONFIG_PATH}:${OPENSSL_PREFIX}/lib/pkgconfig/"
|
||||
|
@ -279,7 +280,7 @@ function build_bdb() {
|
|||
cd db-4.8.30.NC/build_unix
|
||||
echo "Building bdb. tail -f $BDB_LOG to see the details and monitor progress"
|
||||
../dist/configure --prefix="${BDB_PREFIX}" --enable-cxx --disable-shared --with-pic > "${BDB_LOG}"
|
||||
background make "${BDB_LOG}" "Waiting for bdb to finish building"
|
||||
background "make ${PARALLEL}" "${BDB_LOG}" "Waiting for bdb to finish building"
|
||||
make install >> "${BDB_LOG}" 2>&1
|
||||
}
|
||||
|
||||
|
@ -297,18 +298,52 @@ function build_openssl() {
|
|||
./Configure --prefix="${OPENSSL_PREFIX}" --openssldir="${OPENSSL_PREFIX}/ssl" \
|
||||
${OS_ARCH} -fPIC -static no-shared no-dso > "${OPENSSL_LOG}"
|
||||
fi
|
||||
background make "${OPENSSL_LOG}" "Waiting for openssl to finish building"
|
||||
background "make ${PARALLEL}" "${OPENSSL_LOG}" "Waiting for openssl to finish building"
|
||||
make install >> "${OPENSSL_LOG}" 2>&1
|
||||
}
|
||||
|
||||
function build_boost() {
|
||||
BOOST_LOG="$1"
|
||||
cd boost_1_59_0
|
||||
|
||||
echo "int main() { return 0; }" > libs/regex/build/has_icu_test.cpp
|
||||
echo "int main() { return 0; }" > libs/locale/build/has_icu_test.cpp
|
||||
|
||||
export BOOST_ICU_LIBS="$(pkg-config icu-i18n --libs) -dl"
|
||||
export BOOST_LDFLAGS="${BOOST_PREFIX}/lib ${ICU_PREFIX}/lib ${BOOST_ICU_LIBS}"
|
||||
|
||||
echo "BOOST_ICU_LIBS: $BOOST_ICU_LIBS"
|
||||
echo "BOOST_LDFLAGS: $BOOST_ICU_LIBS"
|
||||
|
||||
echo "Building Boost. tail -f ${BOOST_LOG} to see the details and monitor progress"
|
||||
./bootstrap.sh --prefix="${BOOST_PREFIX}" > "${BOOST_LOG}" 2>&1
|
||||
background "./b2 link=static cxxflags=-fPIC install" \
|
||||
"${BOOST_LOG}" \
|
||||
"Waiting for boost to finish building"
|
||||
./bootstrap.sh --prefix="${BOOST_PREFIX}" "--with-icu=${ICU_PREFIX}" > "${BOOST_LOG}" 2>&1
|
||||
b2cmd="./b2 link=static cxxflags=-fPIC install boost.locale.iconv=off boost.locale.posix=off -sICU_PATH=${ICU_PREFIX} -sICU_LINK=${BOOST_ICU_LIBS}"
|
||||
background "${b2cmd}" "${BOOST_LOG}" "Waiting for boost to finish building"
|
||||
}
|
||||
|
||||
function build_icu() {
|
||||
ICU_LOG="$1"
|
||||
mkdir -p "${ICU_PREFIX}/icu"
|
||||
wget http://download.icu-project.org/files/icu4c/55.1/icu4c-55_1-src.tgz
|
||||
tar -xf icu4c-55_1-src.tgz
|
||||
rm -f icu4c-55_1-src.tgz
|
||||
pushd icu/source > /dev/null
|
||||
echo "Building icu. tail -f $ICU_LOG to see the details and monitor progress"
|
||||
./configure --prefix="${ICU_PREFIX}" --enable-draft --enable-tools \
|
||||
--enable-shared --disable-extras --disable-icuio \
|
||||
--disable-layout --disable-layoutex --disable-tests --disable-samples
|
||||
if [ ! -z ${TARGET+x} ]; then
|
||||
TMP_TARGET="${TARGET}"
|
||||
unset TARGET
|
||||
fi
|
||||
set +e
|
||||
background "make ${PARALLEL} VERBOSE=1" "${ICU_LOG}" "Waiting for icu to finish building"
|
||||
make install >> "${ICU_LOG}" 2>&1
|
||||
if [ ! -z ${TARGET+x} ]; then
|
||||
TARGET="${TMP_TARGET}"
|
||||
fi
|
||||
set -e
|
||||
popd > /dev/null
|
||||
}
|
||||
|
||||
function build_libevent() {
|
||||
|
@ -322,7 +357,7 @@ function build_libevent() {
|
|||
./configure --prefix="${LIBEVENT_PREFIX}" --enable-static --disable-shared --with-pic \
|
||||
LDFLAGS="-L${OPENSSL_PREFIX}/lib/" \
|
||||
CPPFLAGS="-I${OPENSSL_PREFIX}/include" >> "${LIBEVENT_LOG}" 2>&1
|
||||
background make "${LIBEVENT_LOG}" "Waiting for libevent to finish building"
|
||||
background "make ${PARALLEL}" "${LIBEVENT_LOG}" "Waiting for libevent to finish building"
|
||||
make install >> "${LIBEVENT_LOG}"
|
||||
}
|
||||
|
||||
|
@ -334,6 +369,7 @@ function build_dependency() {
|
|||
if [ ! -d "${PREFIX}" ]; then
|
||||
trap 'cleanup "${PREFIX}" "${LOG}"' INT TERM EXIT
|
||||
cd "${LBRYCRD_DEPENDENCIES}"
|
||||
rm -rf ${PREFIX}
|
||||
mkdir -p "${PREFIX}"
|
||||
"${BUILD}" "${LOG}"
|
||||
trap - INT TERM EXIT
|
||||
|
@ -350,19 +386,27 @@ function build_lbrycrd() {
|
|||
cd "${SOURCE_DIR}"
|
||||
fi
|
||||
./autogen.sh > "${LBRYCRD_LOG}" 2>&1
|
||||
LDFLAGS="-L${OPENSSL_PREFIX}/lib/ -L${BDB_PREFIX}/lib/ -L${LIBEVENT_PREFIX}/lib/ -static-libstdc++"
|
||||
CPPFLAGS="-I${OPENSSL_PREFIX}/include -I${BDB_PREFIX}/include -I${LIBEVENT_PREFIX}/include/"
|
||||
LDFLAGS="-L${OPENSSL_PREFIX}/lib/ -L${BDB_PREFIX}/lib/ -L${LIBEVENT_PREFIX}/lib/ -L${ICU_PREFIX}/lib/ -static-libstdc++"
|
||||
if [ "${OS_NAME}" = "osx" ]; then
|
||||
OPTIONS="--enable-cxx --enable-static --disable-shared --with-pic"
|
||||
CPPFLAGS="-I${OPENSSL_PREFIX}/include -I${BDB_PREFIX}/include -I${LIBEVENT_PREFIX}/include/ -I${ICU_PREFIX}/include"
|
||||
else
|
||||
OPTIONS=""
|
||||
CPPFLAGS="-I${OPENSSL_PREFIX}/include -I${BDB_PREFIX}/include -I${LIBEVENT_PREFIX}/include/ -I${ICU_PREFIX}/include -Wno-unused-local-typedefs"
|
||||
fi
|
||||
|
||||
CPPFLAGS="${CPPFLAGS}" LDFLAGS="${LDFLAGS}" \
|
||||
./configure --without-gui ${OPTIONS} \
|
||||
--with-boost="${BOOST_PREFIX}" \
|
||||
--with-icu="${ICU_PREFIX}" >> "${LBRYCRD_LOG}" 2>&1
|
||||
|
||||
|
||||
background "make ${PARALLEL}" "${LBRYCRD_LOG}" "Waiting for lbrycrd to finish building"
|
||||
if [ "${OS_NAME}" = "linux" ]; then
|
||||
LD_LIBRARY_PATH="${ICU_PREFIX}/lib" src/test/test_lbrycrd
|
||||
else
|
||||
DYLD_LIBRARY_PATH="${ICU_PREFIX}/lib" src/test/test_lbrycrd
|
||||
fi
|
||||
./configure --without-gui ${OPTIONS} \
|
||||
--with-boost="${BOOST_PREFIX}" \
|
||||
LDFLAGS="${LDFLAGS}" \
|
||||
CPPFLAGS="${CPPFLAGS}" >> "${LBRYCRD_LOG}" 2>&1
|
||||
background make "${LBRYCRD_LOG}" "Waiting for lbrycrd to finish building"
|
||||
src/test/test_lbrycrd
|
||||
strip src/lbrycrdd
|
||||
strip src/lbrycrd-cli
|
||||
strip src/lbrycrd-tx
|
||||
|
@ -379,6 +423,7 @@ function clang_format_diff(){
|
|||
LBRYCRD_DEPENDENCIES="$(pwd)/lbrycrd-dependencies"
|
||||
OUTPUT_DIR="$(pwd)/build"
|
||||
LOG_DIR="$(pwd)/logs"
|
||||
ICU_PREFIX="${OUTPUT_DIR}/icu"
|
||||
BDB_PREFIX="${OUTPUT_DIR}/bdb"
|
||||
OPENSSL_PREFIX="${OUTPUT_DIR}/openssl"
|
||||
BOOST_PREFIX="${OUTPUT_DIR}/boost"
|
||||
|
|
|
@ -29,7 +29,7 @@ $(LIBLEVELDB) $(LIBMEMENV):
|
|||
endif
|
||||
|
||||
BITCOIN_CONFIG_INCLUDES=-I$(builddir)/config
|
||||
BITCOIN_INCLUDES=-I$(builddir) -I$(builddir)/obj $(BOOST_CPPFLAGS) $(LEVELDB_CPPFLAGS) $(CRYPTO_CFLAGS) $(SSL_CFLAGS)
|
||||
BITCOIN_INCLUDES=-I$(builddir) -I$(builddir)/obj $(ICU_CPPFLAGS) $(BOOST_CPPFLAGS) $(LEVELDB_CPPFLAGS) $(CRYPTO_CFLAGS) $(SSL_CFLAGS) $(ICU_CFLAGS)
|
||||
|
||||
BITCOIN_INCLUDES += -I$(srcdir)/secp256k1/include
|
||||
BITCOIN_INCLUDES += $(UNIVALUE_CFLAGS)
|
||||
|
@ -354,7 +354,7 @@ nodist_libbitcoin_util_a_SOURCES = $(srcdir)/obj/build.h
|
|||
lbrycrdd_SOURCES = bitcoind.cpp
|
||||
lbrycrdd_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
|
||||
lbrycrdd_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
|
||||
lbrycrdd_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
|
||||
lbrycrdd_LDFLAGS = -L$(ICU_PREFIX)/lib $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
|
||||
|
||||
if TARGET_WINDOWS
|
||||
lbrycrdd_SOURCES += bitcoin-cli-res.rc
|
||||
|
@ -379,7 +379,7 @@ if ENABLE_WALLET
|
|||
lbrycrdd_LDADD += libbitcoin_wallet.a
|
||||
endif
|
||||
|
||||
lbrycrdd_LDADD += $(BOOST_LIBS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(MINIUPNPC_LIBS) $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS)
|
||||
lbrycrdd_LDADD += $(BOOST_LIBS) $(ICU_LIBS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(MINIUPNPC_LIBS) $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS)
|
||||
|
||||
#lbrycrd-cli binary #
|
||||
lbrycrd_cli_SOURCES = bitcoin-cli.cpp
|
||||
|
|
|
@ -31,7 +31,7 @@ bench_bench_bitcoin_LDADD += $(LIBBITCOIN_WALLET)
|
|||
endif
|
||||
|
||||
bench_bench_bitcoin_LDADD += $(BOOST_LIBS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(MINIUPNPC_LIBS) $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS)
|
||||
bench_bench_bitcoin_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
|
||||
bench_bench_bitcoin_LDFLAGS = -L$(ICU_PREFIX)/lib $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
|
||||
|
||||
CLEAN_BITCOIN_BENCH = bench/*.gcda bench/*.gcno
|
||||
|
||||
|
|
|
@ -380,9 +380,9 @@ if ENABLE_ZMQ
|
|||
qt_lbrycrd_qt_LDADD += $(LIBBITCOIN_ZMQ) $(ZMQ_LIBS)
|
||||
endif
|
||||
qt_lbrycrd_qt_LDADD += $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CONSENSUS) $(LIBBITCOIN_CRYPTO) $(LIBUNIVALUE) $(LIBLEVELDB) $(LIBMEMENV) \
|
||||
$(BOOST_LIBS) $(QT_LIBS) $(QT_DBUS_LIBS) $(QR_LIBS) $(PROTOBUF_LIBS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(MINIUPNPC_LIBS) $(LIBSECP256K1) \
|
||||
$(BOOST_LIBS) $(QT_LIBS) $(QT_DBUS_LIBS) $(QR_LIBS) $(PROTOBUF_LIBS) $(ICU_LIBS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(MINIUPNPC_LIBS) $(LIBSECP256K1) \
|
||||
$(EVENT_PTHREADS_LIBS) $(EVENT_LIBS)
|
||||
qt_lbrycrd_qt_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(QT_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
|
||||
qt_lbrycrd_qt_LDFLAGS = -L$(ICU_PREFIX)/lib $(RELDFLAGS) $(AM_LDFLAGS) $(QT_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
|
||||
qt_lbrycrd_qt_LIBTOOLFLAGS = --tag CXX
|
||||
|
||||
#locale/foo.ts -> locale/foo.qm
|
||||
|
|
|
@ -35,9 +35,9 @@ qt_test_test_lbrycrd_qt_LDADD += $(LIBBITCOIN_ZMQ) $(ZMQ_LIBS)
|
|||
endif
|
||||
qt_test_test_lbrycrd_qt_LDADD += $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CONSENSUS) $(LIBBITCOIN_CRYPTO) $(LIBUNIVALUE) $(LIBLEVELDB) \
|
||||
$(LIBMEMENV) $(BOOST_LIBS) $(QT_DBUS_LIBS) $(QT_TEST_LIBS) $(QT_LIBS) \
|
||||
$(QR_LIBS) $(PROTOBUF_LIBS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(MINIUPNPC_LIBS) $(LIBSECP256K1) \
|
||||
$(QR_LIBS) $(PROTOBUF_LIBS) $(ICU_LIBS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(MINIUPNPC_LIBS) $(LIBSECP256K1) \
|
||||
$(EVENT_PTHREADS_LIBS) $(EVENT_LIBS)
|
||||
qt_test_test_lbrycrd_qt_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(QT_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
|
||||
qt_test_test_lbrycrd_qt_LDFLAGS = -L$(ICU_PREFIX)/lib $(RELDFLAGS) $(AM_LDFLAGS) $(QT_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
|
||||
qt_test_test_lbrycrd_qt_CXXFLAGS = $(AM_CXXFLAGS) $(QT_PIE_FLAGS)
|
||||
|
||||
CLEAN_BITCOIN_QT_TEST = $(TEST_QT_MOC_CPP) qt/test/*.gcda qt/test/*.gcno
|
||||
|
|
|
@ -108,8 +108,8 @@ if ENABLE_WALLET
|
|||
test_test_lbrycrd_LDADD += $(LIBBITCOIN_WALLET)
|
||||
endif
|
||||
|
||||
test_test_lbrycrd_LDADD += $(LIBBITCOIN_CONSENSUS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(MINIUPNPC_LIBS)
|
||||
test_test_lbrycrd_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) -static
|
||||
test_test_lbrycrd_LDADD += $(LIBBITCOIN_CONSENSUS) $(ICU_LIBS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(MINIUPNPC_LIBS)
|
||||
test_test_lbrycrd_LDFLAGS = -L$(ICU_PREFIX)/lib $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) -static
|
||||
|
||||
if ENABLE_ZMQ
|
||||
test_test_lbrycrd_LDADD += $(ZMQ_LIBS)
|
||||
|
|
|
@ -136,6 +136,7 @@ public:
|
|||
consensus.nExtendedClaimExpirationForkHeight = 400155;
|
||||
consensus.fPowAllowMinDifficultyBlocks = false;
|
||||
consensus.fPowNoRetargeting = false;
|
||||
consensus.nNormalizedNameForkHeight = 1000000; // FIXME: pick a real fork height
|
||||
consensus.nRuleChangeActivationThreshold = 1916; // 95% of 2016
|
||||
consensus.nMinerConfirmationWindow = 2016; // nPowTargetTimespan / nPowTargetSpacing
|
||||
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 28;
|
||||
|
@ -223,6 +224,7 @@ public:
|
|||
consensus.nExtendedClaimExpirationForkHeight = 278160;
|
||||
consensus.fPowAllowMinDifficultyBlocks = true;
|
||||
consensus.fPowNoRetargeting = false;
|
||||
consensus.nNormalizedNameForkHeight = 1000000; // FIXME: pick a real fork height
|
||||
consensus.nRuleChangeActivationThreshold = 1512; // 75% for testchains
|
||||
consensus.nMinerConfirmationWindow = 2016; // nPowTargetTimespan / nPowTargetSpacing
|
||||
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 28;
|
||||
|
@ -303,6 +305,7 @@ public:
|
|||
consensus.nExtendedClaimExpirationForkHeight = 800;
|
||||
consensus.fPowAllowMinDifficultyBlocks = false;
|
||||
consensus.fPowNoRetargeting = false;
|
||||
consensus.nNormalizedNameForkHeight = 2000; // FIXME: pick a real fork height
|
||||
consensus.nRuleChangeActivationThreshold = 108; // 75% for testchains
|
||||
consensus.nMinerConfirmationWindow = 144; // Faster than normal for regtest (144 instead of 2016)
|
||||
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 28;
|
||||
|
|
File diff suppressed because it is too large
Load diff
135
src/claimtrie.h
135
src/claimtrie.h
|
@ -13,6 +13,12 @@
|
|||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/locale/conversion.hpp>
|
||||
#include <boost/locale/localization_backend.hpp>
|
||||
#include <boost/locale.hpp>
|
||||
#include <boost/ptr_container/ptr_vector.hpp>
|
||||
|
||||
// leveldb keys
|
||||
#define HASH_BLOCK 'h'
|
||||
#define CURRENT_HEIGHT 't'
|
||||
|
@ -28,6 +34,34 @@
|
|||
|
||||
uint256 getValueHash(COutPoint outPoint, int nHeightOfLastTakeover);
|
||||
|
||||
// lower-case and normalize any input string name
|
||||
// see: https://unicode.org/reports/tr15/#Norm_Forms
|
||||
inline std::string normalizeClaimName(const std::string& name)
|
||||
{
|
||||
static std::locale utf8;
|
||||
static bool initialized = false;
|
||||
if (!initialized) {
|
||||
static boost::locale::localization_backend_manager manager =
|
||||
boost::locale::localization_backend_manager::global();
|
||||
manager.select("icu");
|
||||
|
||||
static boost::locale::generator curLocale(manager);
|
||||
utf8 = curLocale("en_US.UTF8");
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
std::string normalized = boost::locale::normalize(name, boost::locale::norm_nfd, utf8);
|
||||
// Non-locale aware lowercase
|
||||
boost::algorithm::to_lower(normalized);
|
||||
|
||||
// Locale aware lowercase
|
||||
/* normalized = boost::locale::to_lower(normalized, utf8); */
|
||||
|
||||
LogPrintf("%s: Normalized \"%s\" (%lu, %lu) to \"%s\" (%lu, %lu)\n", __func__, name, name.size(), sizeof(name), normalized, normalized.size(), sizeof(normalized));
|
||||
// code points can be lost if we're not careful to make sure the string isn't shrinking here
|
||||
return (normalized.size() >= name.size()) ? normalized : name;
|
||||
}
|
||||
|
||||
class CClaimValue
|
||||
{
|
||||
public:
|
||||
|
@ -158,6 +192,67 @@ public:
|
|||
READWRITE(nHeightOfLastTakeover);
|
||||
}
|
||||
|
||||
CClaimTrieNode& cloneState(const CClaimTrieNode& other)
|
||||
{
|
||||
hash = other.hash;
|
||||
nHeightOfLastTakeover = other.nHeightOfLastTakeover;
|
||||
if (!claims.empty()) {
|
||||
claims.reserve(other.claims.size());
|
||||
std::copy(other.claims.begin(), other.claims.end(), claims.begin());
|
||||
}
|
||||
|
||||
std::string sPos;
|
||||
for (nodeMapType::const_iterator it = other.children.begin(); it != other.children.end(); ++it) {
|
||||
std::stringstream ss;
|
||||
ss << it->first;
|
||||
sPos = ss.str();
|
||||
|
||||
CClaimTrieNode* newNode = new CClaimTrieNode();
|
||||
newNode->cloneState(*it->second);
|
||||
if (!it->second->claims.empty()) {
|
||||
newNode->claims.reserve(it->second->claims.size());
|
||||
for (std::vector<CClaimValue>::const_iterator cit = it->second->claims.begin(); cit != it->second->claims.end(); ++cit)
|
||||
newNode->claims.push_back(*cit);
|
||||
}
|
||||
children[sPos[sPos.size() - 1]] = newNode;
|
||||
|
||||
claimTrieNodeList.push_back(newNode);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
// NOTE: While normalization is hardcoded into this method, it's
|
||||
// *only* used while enabling the normalization fork in order to
|
||||
// flatten the namespace.
|
||||
CClaimTrieNode& normalizeClone(const CClaimTrieNode& other)
|
||||
{
|
||||
hash = uint256S("0000000000000000000000000000000000000000000000000000000000000001");
|
||||
nHeightOfLastTakeover = other.nHeightOfLastTakeover;
|
||||
if (!claims.empty()) {
|
||||
claims.reserve(other.claims.size());
|
||||
std::copy(other.claims.begin(), other.claims.end(), claims.begin());
|
||||
}
|
||||
|
||||
std::string sPos;
|
||||
for (nodeMapType::const_iterator it = other.children.begin(); it != other.children.end(); ++it) {
|
||||
std::stringstream ss;
|
||||
ss << it->first;
|
||||
sPos = normalizeClaimName(ss.str());
|
||||
|
||||
CClaimTrieNode* newNode = new CClaimTrieNode();
|
||||
newNode->normalizeClone(*it->second);
|
||||
if (!it->second->claims.empty()) {
|
||||
newNode->claims.reserve(it->second->claims.size());
|
||||
for (std::vector<CClaimValue>::const_iterator cit = it->second->claims.begin(); cit != it->second->claims.end(); ++cit)
|
||||
newNode->claims.push_back(*cit);
|
||||
}
|
||||
children[sPos[sPos.size() - 1]] = newNode;
|
||||
|
||||
claimTrieNodeList.push_back(newNode);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool operator==(const CClaimTrieNode& other) const
|
||||
{
|
||||
return hash == other.hash && claims == other.claims;
|
||||
|
@ -298,18 +393,20 @@ class CClaimTrieCache;
|
|||
class CClaimTrie
|
||||
{
|
||||
public:
|
||||
CClaimTrie(bool fMemory = false, bool fWipe = false, int nProportionalDelayFactor = 32)
|
||||
: db(GetDataDir() / "claimtrie", 100, fMemory, fWipe, false)
|
||||
, nCurrentHeight(0), nExpirationTime(Params().GetConsensus().nOriginalClaimExpirationTime)
|
||||
, nProportionalDelayFactor(nProportionalDelayFactor)
|
||||
, root(uint256S("0000000000000000000000000000000000000000000000000000000000000001"))
|
||||
CClaimTrie(bool fMemory = false, bool fWipe = false, bool fNormalize = false, int nProportionalDelayFactor = 32)
|
||||
: db(GetDataDir() / "claimtrie", 100, fMemory, fWipe, false), nCurrentHeight(0), nExpirationTime(Params().GetConsensus().nOriginalClaimExpirationTime), nProportionalDelayFactor(nProportionalDelayFactor), root(uint256S("0000000000000000000000000000000000000000000000000000000000000001")), fNormalize(fNormalize)
|
||||
{}
|
||||
|
||||
// Does not change the current trie, but returns a normalized equivalent trie
|
||||
CClaimTrie* enableNormalizationFork(bool enable, int nHeight, CClaimTrieCache& trieCache);
|
||||
|
||||
uint256 getMerkleHash();
|
||||
|
||||
bool empty() const;
|
||||
void clear();
|
||||
|
||||
bool shouldNormalize();
|
||||
|
||||
bool checkConsistency() const;
|
||||
|
||||
bool WriteToDisk();
|
||||
|
@ -378,8 +475,9 @@ private:
|
|||
expirationQueueType& supportExpirationQueueCache);
|
||||
bool updateName(const std::string& name, CClaimTrieNode* updatedNode);
|
||||
bool updateHash(const std::string& name, uint256& hash);
|
||||
bool updateHashNormalized(const std::string& name, uint256& hash);
|
||||
bool updateTakeoverHeight(const std::string& name, int nTakeoverHeight);
|
||||
bool recursiveNullify(CClaimTrieNode* node, std::string& name);
|
||||
bool recursiveNullify(CClaimTrieNode* node, const std::string& name);
|
||||
|
||||
bool recursiveCheckConsistency(const CClaimTrieNode* node) const;
|
||||
|
||||
|
@ -414,6 +512,9 @@ private:
|
|||
void BatchWriteSupportExpirationQueueRows(CDBBatch& batch);
|
||||
template<typename K> bool keyTypeEmpty(char key, K& dummy) const;
|
||||
|
||||
void cloneState(const CClaimTrie&);
|
||||
void copyAndNormalizeQueues(const CClaimTrie&);
|
||||
|
||||
CClaimTrieNode root;
|
||||
uint256 hashBlock;
|
||||
|
||||
|
@ -427,6 +528,8 @@ private:
|
|||
|
||||
nodeCacheType dirtyNodes;
|
||||
supportMapType dirtySupportNodes;
|
||||
|
||||
bool fNormalize;
|
||||
};
|
||||
|
||||
class CClaimTrieProofNode
|
||||
|
@ -485,7 +588,7 @@ public:
|
|||
nCurrentHeight = base->nCurrentHeight;
|
||||
}
|
||||
|
||||
uint256 getMerkleHash() const;
|
||||
uint256 getMerkleHash(bool forceCompute = false) const;
|
||||
|
||||
bool empty() const;
|
||||
bool flush();
|
||||
|
@ -556,11 +659,20 @@ public:
|
|||
CAmount getEffectiveAmountForClaim(const claimsForNameType& claims, const uint160& claimId, std::vector<CSupportValue>* supports = NULL) const;
|
||||
|
||||
protected:
|
||||
// Should be private: Do not use unless you know what you're doing.
|
||||
CClaimTrieNode* addNodeToCache(const std::string& position, CClaimTrieNode* original) const;
|
||||
bool recursiveComputeMerkleHash(CClaimTrieNode* tnCurrent,
|
||||
const std::string& sPos,
|
||||
bool forceCompute = false) const;
|
||||
bool recursivePruneName(CClaimTrieNode* tnCurrent, unsigned int nPos, const std::string& sName, bool* pfNullified = NULL) const;
|
||||
|
||||
mutable nodeCacheType cache;
|
||||
|
||||
private:
|
||||
CClaimTrie* base;
|
||||
|
||||
bool fRequireTakeoverHeights;
|
||||
|
||||
mutable nodeCacheType cache;
|
||||
mutable nodeCacheType block_originals;
|
||||
mutable std::set<std::string> dirtyHashes;
|
||||
mutable hashMapType cacheHashes;
|
||||
|
@ -583,11 +695,6 @@ protected:
|
|||
uint256 computeHash() const;
|
||||
|
||||
bool reorderTrieNode(const std::string& name, bool fCheckTakeover) const;
|
||||
bool recursiveComputeMerkleHash(CClaimTrieNode* tnCurrent,
|
||||
std::string sPos) const;
|
||||
bool recursivePruneName(CClaimTrieNode* tnCurrent, unsigned int nPos,
|
||||
std::string sName,
|
||||
bool* pfNullified = NULL) const;
|
||||
|
||||
bool clear() const;
|
||||
|
||||
|
@ -644,8 +751,6 @@ protected:
|
|||
uint256 getLeafHashForProof(const std::string& currentPosition, unsigned char nodeChar,
|
||||
const CClaimTrieNode* currentNode) const;
|
||||
|
||||
CClaimTrieNode* addNodeToCache(const std::string& position, CClaimTrieNode* original) const;
|
||||
|
||||
bool getOriginalInfoForName(const std::string& name, CClaimValue& claim) const;
|
||||
|
||||
int getNumBlocksOfContinuousOwnership(const std::string& name) const;
|
||||
|
|
|
@ -56,6 +56,7 @@ struct Params {
|
|||
uint256 powLimit;
|
||||
bool fPowAllowMinDifficultyBlocks;
|
||||
bool fPowNoRetargeting;
|
||||
int nNormalizedNameForkHeight;
|
||||
int64_t nPowTargetSpacing;
|
||||
int64_t nPowTargetTimespan;
|
||||
/** how long it took claims to expire before the hard fork */
|
||||
|
|
17
src/init.cpp
17
src/init.cpp
|
@ -1425,6 +1425,23 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||
RandAddSeedPerfmon();
|
||||
|
||||
pclaimTrie->setExpirationTime(consensusParams.GetExpirationTime(chainActive.Height()));
|
||||
// Possible enhancement TODO: Instead of forcing a re-init, store
|
||||
// fork status on disk and just load at start-up (on initial
|
||||
// load).
|
||||
if ((chainActive.Height() >= (Params().GetConsensus().nNormalizedNameForkHeight - 1)) &&
|
||||
!pclaimTrie->shouldNormalize()) {
|
||||
LogPrintf("Reloading ClaimTrie with normalization enabled\n");
|
||||
|
||||
delete pclaimTrie;
|
||||
pclaimTrie = new CClaimTrie(false, fReindex, true);
|
||||
assert(pclaimTrie->shouldNormalize());
|
||||
|
||||
if (!pclaimTrie->ReadFromDisk(true)) {
|
||||
LogPrintf("Error re-loading the claim trie from disk");
|
||||
return false;
|
||||
}
|
||||
LogPrintf("Finished reloading ClaimTrie with normalization enabled\n");
|
||||
}
|
||||
|
||||
//// debug print
|
||||
LogPrintf("mapBlockIndex.size() = %u\n", mapBlockIndex.size());
|
||||
|
|
75
src/main.cpp
75
src/main.cpp
|
@ -2067,6 +2067,7 @@ static bool ApplyTxInUndo(const CTxInUndo& undo, CCoinsViewCache& view, CClaimTr
|
|||
std::vector<std::vector<unsigned char> > vvchParams;
|
||||
if (undo.fIsClaim && DecodeClaimScript(undo.txout.scriptPubKey, op, vvchParams))
|
||||
{
|
||||
const bool shouldNormalize = pclaimTrie->shouldNormalize();
|
||||
if (op == OP_CLAIM_NAME || op == OP_UPDATE_CLAIM)
|
||||
{
|
||||
uint160 claimId;
|
||||
|
@ -2084,7 +2085,8 @@ static bool ApplyTxInUndo(const CTxInUndo& undo, CCoinsViewCache& view, CClaimTr
|
|||
int nValidHeight = undo.nClaimValidHeight;
|
||||
if (nValidHeight > 0 && nValidHeight >= coins->nHeight)
|
||||
{
|
||||
LogPrintf("%s: (txid: %s, nOut: %d) Restoring %s to the claim trie due to a block being disconnected\n", __func__, out.hash.ToString(), out.n, name.c_str());
|
||||
LogPrintf("%s: (txid: %s, nOut: %d) Restoring %s to the claim trie due to a block being disconnected (normalize claim active: %s)\n",
|
||||
__func__, out.hash.ToString(), out.n, name.c_str(), (shouldNormalize ? "true" : "false"));
|
||||
if (!trieCache.undoSpendClaim(name, COutPoint(out.hash, out.n), claimId, undo.txout.nValue, coins->nHeight, nValidHeight))
|
||||
LogPrintf("%s: Something went wrong inserting the claim\n", __func__);
|
||||
}
|
||||
|
@ -2139,6 +2141,13 @@ bool DisconnectBlock(const CBlock& block, CValidationState& state, const CBlockI
|
|||
|
||||
assert(trieCache.decrementBlock(blockUndo.insertUndo, blockUndo.expireUndo, blockUndo.insertSupportUndo, blockUndo.expireSupportUndo, blockUndo.takeoverHeightUndo));
|
||||
|
||||
if (pindex->nHeight == Params().GetConsensus().nNormalizedNameForkHeight) {
|
||||
LogPrintf("Decremented past the normalization hard fork height\n");
|
||||
const uint256 prevHash = trieCache.getBestBlock();
|
||||
pclaimTrie = pclaimTrie->enableNormalizationFork(false, pindex->nHeight, trieCache);
|
||||
trieCache.setBestBlock(prevHash);
|
||||
}
|
||||
|
||||
// undo transactions in reverse order
|
||||
for (int i = block.vtx.size() - 1; i >= 0; i--) {
|
||||
const CTransaction &tx = block.vtx[i];
|
||||
|
@ -2168,6 +2177,7 @@ bool DisconnectBlock(const CBlock& block, CValidationState& state, const CBlockI
|
|||
std::vector<std::vector<unsigned char> > vvchParams;
|
||||
if (DecodeClaimScript(txout.scriptPubKey, op, vvchParams))
|
||||
{
|
||||
bool shouldNormalize = pclaimTrie->shouldNormalize();
|
||||
if (op == OP_CLAIM_NAME || op == OP_UPDATE_CLAIM)
|
||||
{
|
||||
uint160 claimId;
|
||||
|
@ -2204,7 +2214,8 @@ bool DisconnectBlock(const CBlock& block, CValidationState& state, const CBlockI
|
|||
uint160 supportedClaimId(vvchParams[1]);
|
||||
LogPrintf("--- %s[%lu]: OP_SUPPORT_CLAIM \"%s\" with claimId %s and tx prevout %s at index %d\n",
|
||||
__func__, pindex->nHeight, name, supportedClaimId.GetHex(), hash.ToString(), i);
|
||||
LogPrintf("%s: (txid: %s, nOut: %d) Removing support for claim id %s on %s due to its block being disconnected\n", __func__, hash.ToString(), i, supportedClaimId.ToString(), name.c_str());
|
||||
LogPrintf("%s: (txid: %s, nOut: %d) Removing support for claim id %s on %s due to its block being disconnected (normalize fork active: %s)\n",
|
||||
__func__, hash.ToString(), i, supportedClaimId.ToString(), name.c_str(), (shouldNormalize ? "true" : "false"));
|
||||
if (!trieCache.undoAddSupport(name, COutPoint(hash, i), pindex->nHeight))
|
||||
LogPrintf("%s: Something went wrong removing support for name %s in hash %s\n", __func__, name.c_str(), hash.ToString());
|
||||
}
|
||||
|
@ -2234,14 +2245,14 @@ bool DisconnectBlock(const CBlock& block, CValidationState& state, const CBlockI
|
|||
assert(trieCache.finalizeDecrement());
|
||||
trieCache.setBestBlock(pindex->pprev->GetBlockHash());
|
||||
assert(trieCache.getMerkleHash() == pindex->pprev->hashClaimTrie);
|
||||
|
||||
if (pindex->nHeight == Params().GetConsensus().nExtendedClaimExpirationForkHeight)
|
||||
{
|
||||
LogPrintf("Decremented past the extended claim expiration hard fork height");
|
||||
LogPrintf("Decremented past the extended claim expiration hard fork height\n");
|
||||
pclaimTrie->setExpirationTime(Params().GetConsensus().GetExpirationTime(pindex->nHeight-1));
|
||||
trieCache.forkForExpirationChange(false);
|
||||
}
|
||||
|
||||
|
||||
if (pfClean) {
|
||||
*pfClean = fClean;
|
||||
return true;
|
||||
|
@ -2413,6 +2424,11 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
|
|||
assert(hashPrevBlock == view.GetBestBlock());
|
||||
|
||||
// also verify that the trie cache's current state corresponds to the previous block
|
||||
if (hashPrevBlock != trieCache.getBestBlock()) {
|
||||
const std::string hash1 = hashPrevBlock.GetHex();
|
||||
const std::string hash2 = trieCache.getBestBlock().GetHex();
|
||||
LogPrint("%s: %s (%d) != %s (%d)\n", __func__, hash1, (int)hash1.size(), hash2, (int)hash2.size());
|
||||
}
|
||||
assert(hashPrevBlock == trieCache.getBestBlock());
|
||||
|
||||
// Special case for the genesis block, skipping connection of its transactions
|
||||
|
@ -2505,16 +2521,15 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
|
|||
// v 13 LBRYcrd hard fork to extend expiration time
|
||||
if (pindex->nHeight == Params().GetConsensus().nExtendedClaimExpirationForkHeight)
|
||||
{
|
||||
LogPrintf("Incremented past the extended claim expiration hard fork height");
|
||||
LogPrintf("Incremented past the extended claim expiration hard fork height\n");
|
||||
pclaimTrie->setExpirationTime(chainparams.GetConsensus().GetExpirationTime(pindex->nHeight));
|
||||
trieCache.forkForExpirationChange(true);
|
||||
}
|
||||
|
||||
|
||||
int64_t nTime2 = GetTimeMicros(); nTimeForks += nTime2 - nTime1;
|
||||
LogPrint("bench", " - Fork checks: %.2fms [%.2fs]\n", 0.001 * (nTime2 - nTime1), nTimeForks * 0.000001);
|
||||
|
||||
CBlockUndo blockundo;
|
||||
CBlockUndo blockUndo;
|
||||
|
||||
CCheckQueueControl<CScriptCheck> control(fScriptChecks && nScriptCheckThreads ? &scriptcheckqueue : NULL);
|
||||
|
||||
|
@ -2525,7 +2540,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
|
|||
CDiskTxPos pos(pindex->GetBlockPos(), GetSizeOfCompactSize(block.vtx.size()));
|
||||
std::vector<std::pair<uint256, CDiskTxPos> > vPos;
|
||||
vPos.reserve(block.vtx.size());
|
||||
blockundo.vtxundo.reserve(block.vtx.size() - 1);
|
||||
blockUndo.vtxundo.reserve(block.vtx.size() - 1);
|
||||
for (unsigned int i = 0; i < block.vtx.size(); i++)
|
||||
{
|
||||
const CTransaction &tx = block.vtx[i];
|
||||
|
@ -2627,6 +2642,8 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
|
|||
mClaimUndoHeights[i] = nValidAtHeight;
|
||||
std::pair<std::string, uint160> entry(name, claimId);
|
||||
spentClaims.push_back(entry);
|
||||
} else {
|
||||
LogPrintf("%s(): The claim was not found in the trie or queue and therefore can't be updated\n", __func__);
|
||||
}
|
||||
}
|
||||
else if (op == OP_SUPPORT_CLAIM)
|
||||
|
@ -2638,7 +2655,9 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
|
|||
__func__, pindex->nHeight, name,
|
||||
supportedClaimId.GetHex(), txin.prevout.hash.GetHex(), txin.prevout.n);
|
||||
int nValidAtHeight;
|
||||
LogPrintf("%s: Removing support for %s in %s. Tx: %s, nOut: %d, removed txid: %s\n", __func__, supportedClaimId.ToString(), name, txin.prevout.hash.ToString(), txin.prevout.n,tx.GetHash().ToString());
|
||||
LogPrintf("%s: Removing support for %s in %s. Tx: %s, nOut: %d, removed txid: %s\n",
|
||||
__func__, supportedClaimId.ToString(), name, txin.prevout.hash.ToString(),
|
||||
txin.prevout.n, tx.GetHash().ToString());
|
||||
if (trieCache.spendSupport(name, COutPoint(txin.prevout.hash, txin.prevout.n), coins->nHeight, nValidAtHeight))
|
||||
{
|
||||
mClaimUndoHeights[i] = nValidAtHeight;
|
||||
|
@ -2659,7 +2678,8 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
|
|||
{
|
||||
assert(vvchParams.size() == 2);
|
||||
std::string name(vvchParams[0].begin(), vvchParams[0].end());
|
||||
LogPrintf("%s: Inserting %s into the claim trie. Tx: %s, nOut: %d\n", __func__, name, tx.GetHash().GetHex(), i);
|
||||
LogPrintf("%s: Inserting %s into the claim trie. Tx: %s, nOut: %d\n",
|
||||
__func__, name, tx.GetHash().GetHex(), i);
|
||||
if (!trieCache.addClaim(name, COutPoint(tx.GetHash(), i), ClaimIdHash(tx.GetHash(), i), txout.nValue, pindex->nHeight))
|
||||
{
|
||||
LogPrintf("%s: Something went wrong inserting the claim\n", __func__);
|
||||
|
@ -2670,12 +2690,17 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
|
|||
assert(vvchParams.size() == 3);
|
||||
std::string name(vvchParams[0].begin(), vvchParams[0].end());
|
||||
uint160 claimId(vvchParams[1]);
|
||||
LogPrintf("%s: Got a claim update. Name: %s, claimId: %s, new txid: %s, nOut: %d\n", __func__, name, claimId.GetHex(), tx.GetHash().GetHex(), i);
|
||||
LogPrintf("%s: Got a claim update. Name: %s, claimId: %s, new txid: %s, nOut: %d\n",
|
||||
__func__, name, claimId.GetHex(), tx.GetHash().GetHex(), i);
|
||||
spentClaimsType::iterator itSpent;
|
||||
for (itSpent = spentClaims.begin(); itSpent != spentClaims.end(); ++itSpent)
|
||||
{
|
||||
if (itSpent->first == name && itSpent->second == claimId)
|
||||
{
|
||||
if (pclaimTrie->shouldNormalize()) {
|
||||
const std::string normalizedName1 = normalizeClaimName(name);
|
||||
const std::string normalizedName2 = normalizeClaimName(itSpent->first);
|
||||
if (normalizedName1 == normalizedName2 && itSpent->second == claimId)
|
||||
break;
|
||||
} else if (itSpent->first == name && itSpent->second == claimId) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -2705,12 +2730,12 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
|
|||
CTxUndo undoDummy;
|
||||
if (i > 0)
|
||||
{
|
||||
blockundo.vtxundo.push_back(CTxUndo());
|
||||
blockUndo.vtxundo.push_back(CTxUndo());
|
||||
}
|
||||
UpdateCoins(tx, state, view, i == 0 ? undoDummy : blockundo.vtxundo.back(), pindex->nHeight);
|
||||
UpdateCoins(tx, state, view, i == 0 ? undoDummy : blockUndo.vtxundo.back(), pindex->nHeight);
|
||||
if (i > 0 && !mClaimUndoHeights.empty())
|
||||
{
|
||||
std::vector<CTxInUndo>& txinUndos = blockundo.vtxundo.back().vprevout;
|
||||
std::vector<CTxInUndo>& txinUndos = blockUndo.vtxundo.back().vprevout;
|
||||
for (std::map<unsigned int, unsigned int>::iterator itHeight = mClaimUndoHeights.begin(); itHeight != mClaimUndoHeights.end(); ++itHeight)
|
||||
{
|
||||
txinUndos[itHeight->first].nClaimValidHeight = itHeight->second;
|
||||
|
@ -2732,13 +2757,23 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
|
|||
pos.nTxOffset += ::GetSerializeSize(tx, SER_DISK, CLIENT_VERSION);
|
||||
}
|
||||
|
||||
assert(trieCache.incrementBlock(blockundo.insertUndo, blockundo.expireUndo, blockundo.insertSupportUndo, blockundo.expireSupportUndo, blockundo.takeoverHeightUndo));
|
||||
if (pindex->nHeight == Params().GetConsensus().nNormalizedNameForkHeight) {
|
||||
LogPrintf("Incremented past the normalization hard fork height\n");
|
||||
pclaimTrie = pclaimTrie->enableNormalizationFork(true, pindex->nHeight, trieCache);
|
||||
CClaimTrieCache tmpTrieCache(pclaimTrie);
|
||||
tmpTrieCache.setBestBlock(trieCache.getBestBlock());
|
||||
trieCache = tmpTrieCache;
|
||||
trieCache.getMerkleHash(true);
|
||||
}
|
||||
|
||||
if (trieCache.getMerkleHash() != block.hashClaimTrie)
|
||||
assert(trieCache.incrementBlock(blockUndo.insertUndo, blockUndo.expireUndo, blockUndo.insertSupportUndo, blockUndo.expireSupportUndo, blockUndo.takeoverHeightUndo));
|
||||
|
||||
if (trieCache.getMerkleHash() != block.hashClaimTrie) {
|
||||
return state.DoS(100,
|
||||
error("ConnectBlock() : the merkle root of the claim trie does not match "
|
||||
"(actual=%s vs block=%s)", trieCache.getMerkleHash().GetHex(),
|
||||
block.hashClaimTrie.GetHex()), REJECT_INVALID, "bad-claim-merkle-hash");
|
||||
}
|
||||
|
||||
int64_t nTime3 = GetTimeMicros(); nTimeConnect += nTime3 - nTime2;
|
||||
LogPrint("bench", " - Connect %u transactions: %.2fms (%.3fms/tx, %.3fms/txin) [%.2fs]\n", (unsigned)block.vtx.size(), 0.001 * (nTime3 - nTime2), 0.001 * (nTime3 - nTime2) / block.vtx.size(), nInputs <= 1 ? 0 : 0.001 * (nTime3 - nTime2) / (nInputs-1), nTimeConnect * 0.000001);
|
||||
|
@ -2765,9 +2800,9 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
|
|||
{
|
||||
if (pindex->GetUndoPos().IsNull()) {
|
||||
CDiskBlockPos pos;
|
||||
if (!FindUndoPos(state, pindex->nFile, pos, ::GetSerializeSize(blockundo, SER_DISK, CLIENT_VERSION) + 40))
|
||||
if (!FindUndoPos(state, pindex->nFile, pos, ::GetSerializeSize(blockUndo, SER_DISK, CLIENT_VERSION) + 40))
|
||||
return error("ConnectBlock(): FindUndoPos failed");
|
||||
if (!UndoWriteToDisk(blockundo, pos, pindex->pprev->GetBlockHash(), chainparams.MessageStart()))
|
||||
if (!UndoWriteToDisk(blockUndo, pos, pindex->pprev->GetBlockHash(), chainparams.MessageStart()))
|
||||
return AbortNode(state, "Failed to write undo data");
|
||||
|
||||
// update nUndoPos in block index
|
||||
|
|
|
@ -341,10 +341,12 @@ CBlockTemplate* CreateNewBlock(const CChainParams& chainparams, const CScript& s
|
|||
spentClaimsType::iterator itSpent;
|
||||
for (itSpent = spentClaims.begin(); itSpent != spentClaims.end(); ++itSpent)
|
||||
{
|
||||
if (itSpent->first == name && itSpent->second == claimId)
|
||||
{
|
||||
if (pclaimTrie->shouldNormalize() &&
|
||||
(normalizeClaimName(name) == normalizeClaimName(itSpent->first)) &&
|
||||
itSpent->second == claimId)
|
||||
break;
|
||||
else if (itSpent->first == name && itSpent->second == claimId)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (itSpent != spentClaims.end())
|
||||
{
|
||||
|
@ -442,15 +444,33 @@ CBlockTemplate* CreateNewBlock(const CChainParams& chainparams, const CScript& s
|
|||
insertUndoType dummyInsertSupportUndo;
|
||||
supportQueueRowType dummyExpireSupportUndo;
|
||||
std::vector<std::pair<std::string, int> > dummyTakeoverHeightUndo;
|
||||
|
||||
if (nHeight == Params().GetConsensus().nNormalizedNameForkHeight) {
|
||||
trieCache.setBestBlock(pindexPrev->GetBlockHash());
|
||||
pclaimTrie = pclaimTrie->enableNormalizationFork(true, nHeight, trieCache);
|
||||
CClaimTrieCache tmpTrieCache(pclaimTrie);
|
||||
tmpTrieCache.setBestBlock(trieCache.getBestBlock());
|
||||
trieCache = tmpTrieCache;
|
||||
trieCache.getMerkleHash(true);
|
||||
}
|
||||
|
||||
trieCache.incrementBlock(dummyInsertUndo, dummyExpireUndo, dummyInsertSupportUndo, dummyExpireSupportUndo, dummyTakeoverHeightUndo);
|
||||
|
||||
pblock->hashClaimTrie = trieCache.getMerkleHash();
|
||||
|
||||
// disable the fork enabled above
|
||||
if (nHeight == Params().GetConsensus().nNormalizedNameForkHeight)
|
||||
pclaimTrie = pclaimTrie->enableNormalizationFork(false, nHeight, trieCache);
|
||||
|
||||
CValidationState state;
|
||||
if (!TestBlockValidity(state, chainparams, *pblock, pindexPrev, false, false)) {
|
||||
throw std::runtime_error(strprintf("%s: TestBlockValidity failed: %s", __func__, FormatStateMessage(state)));
|
||||
}
|
||||
}
|
||||
|
||||
// disable the fork enabled in TestBlockValidity
|
||||
if (nHeight == Params().GetConsensus().nNormalizedNameForkHeight)
|
||||
pclaimTrie = pclaimTrie->enableNormalizationFork(false, nHeight, trieCache);
|
||||
}
|
||||
return pblocktemplate.release();
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#include "nameclaim.h"
|
||||
#include "hash.h"
|
||||
#include "util.h"
|
||||
#include "claimtrie.h"
|
||||
|
||||
|
||||
std::vector<unsigned char> uint32_t_to_vch(uint32_t n)
|
||||
|
@ -18,8 +19,8 @@ std::vector<unsigned char> uint32_t_to_vch(uint32_t n)
|
|||
uint32_t vch_to_uint32_t(std::vector<unsigned char>& vchN)
|
||||
{
|
||||
uint32_t n;
|
||||
if (vchN.size() != 4)
|
||||
{
|
||||
static const size_t uint32Size = sizeof(uint32_t);
|
||||
if (vchN.size() != uint32Size) {
|
||||
LogPrintf("%s() : a vector<unsigned char> with size other than 4 has been given", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
@ -29,27 +30,26 @@ uint32_t vch_to_uint32_t(std::vector<unsigned char>& vchN)
|
|||
|
||||
CScript ClaimNameScript(std::string name, std::string value)
|
||||
{
|
||||
std::vector<unsigned char> vchName(name.begin(), name.end());
|
||||
std::vector<unsigned char> vchValue(value.begin(), value.end());
|
||||
return CScript() << OP_CLAIM_NAME << vchName << vchValue << OP_2DROP << OP_DROP << OP_TRUE;
|
||||
|
||||
std::vector<unsigned char> vchName(name.begin(), name.end());
|
||||
std::vector<unsigned char> vchValue(value.begin(), value.end());
|
||||
return CScript() << OP_CLAIM_NAME << vchName << vchValue << OP_2DROP << OP_DROP << OP_TRUE;
|
||||
}
|
||||
|
||||
CScript SupportClaimScript(std::string name, uint160 claimId)
|
||||
{
|
||||
std::vector<unsigned char> vchName(name.begin(), name.end());
|
||||
std::vector<unsigned char> vchClaimId(claimId.begin(),claimId.end());
|
||||
std::vector<unsigned char> vchClaimId(claimId.begin(), claimId.end());
|
||||
return CScript() << OP_SUPPORT_CLAIM << vchName << vchClaimId << OP_2DROP << OP_DROP << OP_TRUE;
|
||||
}
|
||||
|
||||
CScript UpdateClaimScript(std::string name, uint160 claimId, std::string value)
|
||||
{
|
||||
std::vector<unsigned char> vchName(name.begin(), name.end());
|
||||
std::vector<unsigned char> vchClaimId(claimId.begin(),claimId.end());
|
||||
std::vector<unsigned char> vchClaimId(claimId.begin(), claimId.end());
|
||||
std::vector<unsigned char> vchValue(value.begin(), value.end());
|
||||
return CScript() << OP_UPDATE_CLAIM << vchName << vchClaimId << vchValue << OP_2DROP << OP_2DROP << OP_TRUE;
|
||||
|
||||
}
|
||||
|
||||
|
||||
bool DecodeClaimScript(const CScript& scriptIn, int& op, std::vector<std::vector<unsigned char> >& vvchParams)
|
||||
{
|
||||
CScript::const_iterator pc = scriptIn.begin();
|
||||
|
@ -90,8 +90,8 @@ bool DecodeClaimScript(const CScript& scriptIn, int& op, std::vector<std::vector
|
|||
}
|
||||
if (op == OP_UPDATE_CLAIM || op == OP_SUPPORT_CLAIM)
|
||||
{
|
||||
if (vchParam2.size() != 160/8)
|
||||
{
|
||||
static const size_t claimIdHashSize = sizeof(uint160);
|
||||
if (vchParam2.size() != claimIdHashSize) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -122,15 +122,15 @@ struct ClaimTrieChainFixture{
|
|||
unsigned int num_txs_for_next_block;
|
||||
|
||||
// these will take on regtest parameters
|
||||
const int normalizationForkHeight;
|
||||
const int expirationForkHeight;
|
||||
const int originalExpiration;
|
||||
const int extendedExpiration;
|
||||
|
||||
|
||||
ClaimTrieChainFixture():
|
||||
expirationForkHeight(Params(CBaseChainParams::REGTEST).GetConsensus().nExtendedClaimExpirationForkHeight),
|
||||
originalExpiration(Params(CBaseChainParams::REGTEST).GetConsensus().nOriginalClaimExpirationTime),
|
||||
extendedExpiration(Params(CBaseChainParams::REGTEST).GetConsensus().nExtendedClaimExpirationTime)
|
||||
ClaimTrieChainFixture() : normalizationForkHeight(Params(CBaseChainParams::REGTEST).GetConsensus().nNormalizedNameForkHeight),
|
||||
expirationForkHeight(Params(CBaseChainParams::REGTEST).GetConsensus().nExtendedClaimExpirationForkHeight),
|
||||
originalExpiration(Params(CBaseChainParams::REGTEST).GetConsensus().nOriginalClaimExpirationTime),
|
||||
extendedExpiration(Params(CBaseChainParams::REGTEST).GetConsensus().nExtendedClaimExpirationTime)
|
||||
{
|
||||
fRequireStandard = false;
|
||||
ENTER_CRITICAL_SECTION(cs_main);
|
||||
|
@ -1077,10 +1077,144 @@ BOOST_AUTO_TEST_CASE(supports_fall_through)
|
|||
BOOST_CHECK(is_best_claim("A", tx2)); //tx2 support should be active now
|
||||
}
|
||||
|
||||
/*
|
||||
normalization
|
||||
check claim name normalization before the fork
|
||||
check claim name normalization after the fork
|
||||
*/
|
||||
BOOST_AUTO_TEST_CASE(claimtriebranching_normalization)
|
||||
{
|
||||
ClaimTrieChainFixture fixture;
|
||||
BOOST_CHECK(!pclaimTrie->shouldNormalize());
|
||||
|
||||
// Disable reg-test expiration during this test
|
||||
pclaimTrie->setExpirationTime(5000);
|
||||
|
||||
// check claim names are not normalized
|
||||
CMutableTransaction tx1 = fixture.MakeClaim(fixture.GetCoinbase(), "normalizeTest", "one", 3);
|
||||
fixture.IncrementBlocks(1);
|
||||
BOOST_CHECK(is_best_claim("normalizeTest", tx1));
|
||||
|
||||
CMutableTransaction tx2a = fixture.MakeClaim(fixture.GetCoinbase(), "Normalizetest", "one_a", 2);
|
||||
CMutableTransaction tx2 = fixture.MakeUpdate(tx2a, "Normalizetest", "one", ClaimIdHash(tx2a.GetHash(), 0), 2);
|
||||
fixture.IncrementBlocks(1);
|
||||
BOOST_CHECK(is_best_claim("Normalizetest", tx2));
|
||||
|
||||
// Activate the fork (which rebuilds the existing claimtrie and
|
||||
// cache), flattening all previously existing name clashes due to
|
||||
// the normalization
|
||||
fixture.IncrementBlocks(fixture.normalizationForkHeight - chainActive.Height());
|
||||
BOOST_CHECK(pclaimTrie->shouldNormalize());
|
||||
|
||||
// Disable reg-test expiration during this test
|
||||
pclaimTrie->setExpirationTime(5000);
|
||||
|
||||
// Post-fork, tx1 (the previous winning claim) assumes all name
|
||||
// variants of what it originally was ...
|
||||
BOOST_CHECK(is_best_claim("normalizeTest", tx1)); // effective amount is 3
|
||||
BOOST_CHECK(best_claim_effective_amount_equals("normalizeTest", 3));
|
||||
|
||||
CClaimValue val;
|
||||
pclaimTrie->getInfoForName("normalizeTest", val);
|
||||
|
||||
// Check equivalence of normalized claim names
|
||||
BOOST_CHECK(is_best_claim("NORMALIZETEST", tx1));
|
||||
BOOST_CHECK(is_best_claim("NormalizeTeST", tx1));
|
||||
BOOST_CHECK(is_best_claim("NormaLizeTeST", tx1));
|
||||
BOOST_CHECK(is_best_claim("Normalizetest", tx1)); // collapsed tx2
|
||||
fixture.IncrementBlocks(1);
|
||||
|
||||
CMutableTransaction tx3 = fixture.MakeClaim(fixture.GetCoinbase(), "NORMALIZETEST", "one", 1);
|
||||
fixture.IncrementBlocks(1);
|
||||
BOOST_CHECK(!is_best_claim("NORMALIZETEST", tx3));
|
||||
|
||||
CMutableTransaction s1 = fixture.MakeSupport(fixture.GetCoinbase(), tx1, "NoRmAlIzEtEsT", 2);
|
||||
fixture.IncrementBlocks(1);
|
||||
|
||||
// Ensure that supports work for normalized claim names
|
||||
BOOST_CHECK(is_best_claim("normalizeTest", tx1)); // effective amount is 5
|
||||
BOOST_CHECK(best_claim_effective_amount_equals("normalizeTEST", 5));
|
||||
|
||||
CMutableTransaction tx4 = fixture.MakeClaim(fixture.GetCoinbase(), "foo", "bar", 1);
|
||||
CMutableTransaction s2 = fixture.MakeSupport(fixture.GetCoinbase(), tx4, "Foo", 1);
|
||||
fixture.IncrementBlocks(1);
|
||||
BOOST_CHECK(is_best_claim("FOO", tx4));
|
||||
|
||||
CMutableTransaction u1 = fixture.MakeUpdate(tx4, "foo", "baz", ClaimIdHash(tx4.GetHash(), 0), 1);
|
||||
fixture.IncrementBlocks(1);
|
||||
BOOST_CHECK(is_best_claim("fOO", u1));
|
||||
|
||||
CMutableTransaction u2 = fixture.MakeUpdate(tx1, "nOrmalIzEtEst", "two", ClaimIdHash(tx1.GetHash(), 0), 3);
|
||||
fixture.IncrementBlocks(1);
|
||||
|
||||
BOOST_CHECK(is_best_claim("normalizetest", u2));
|
||||
|
||||
// Add another set of unicode claims that will collapse after the fork
|
||||
CMutableTransaction tx5 = fixture.MakeClaim(fixture.GetCoinbase(), "Ame\u0301lie", "amelie", 2);
|
||||
fixture.IncrementBlocks(1);
|
||||
CClaimValue nval1;
|
||||
pclaimTrie->getInfoForName("amélie", nval1);
|
||||
BOOST_CHECK(nval1.claimId == ClaimIdHash(tx5.GetHash(), 0));
|
||||
BOOST_CHECK(best_claim_effective_amount_equals("Ame\u0301lie", 2));
|
||||
|
||||
// Check equivalence of normalized claim names
|
||||
BOOST_CHECK(is_best_claim("Ame\u0301lie", tx5));
|
||||
BOOST_CHECK(is_best_claim("Amélie", tx5));
|
||||
BOOST_CHECK(is_best_claim("amélie", tx5));
|
||||
BOOST_CHECK(is_best_claim("améLIE", tx5));
|
||||
|
||||
CMutableTransaction tx7 = fixture.MakeClaim(fixture.GetCoinbase(), "あてはまる", "jn1", 1);
|
||||
fixture.IncrementBlocks(1);
|
||||
BOOST_CHECK(is_best_claim("あてはまる", tx7));
|
||||
|
||||
CMutableTransaction tx8 = fixture.MakeClaim(fixture.GetCoinbase(), "añejo", "es1", 1);
|
||||
fixture.IncrementBlocks(1);
|
||||
BOOST_CHECK(is_best_claim("añejo", tx8));
|
||||
BOOST_CHECK(is_best_claim("Añejo", tx8));
|
||||
BOOST_CHECK(is_best_claim("AñeJO", tx8));
|
||||
BOOST_CHECK(is_best_claim("AñEjO", tx8));
|
||||
|
||||
// Rewind to 1 block before the fork and be sure that the fork is
|
||||
// no longer active
|
||||
fixture.DecrementBlocks((chainActive.Height() - fixture.normalizationForkHeight) + 1);
|
||||
BOOST_CHECK(!pclaimTrie->shouldNormalize());
|
||||
|
||||
// Now check that our old (non-normalized) claims are 'alive' again
|
||||
BOOST_CHECK(is_best_claim("normalizeTest", tx1));
|
||||
BOOST_CHECK(!is_best_claim("NORMALIZETEST", tx1)); // no longer equivalent
|
||||
|
||||
BOOST_CHECK(is_best_claim("Normalizetest", tx2));
|
||||
|
||||
// Create new claim
|
||||
CMutableTransaction tx9 = fixture.MakeClaim(fixture.GetCoinbase(), "blah", "blah", 1);
|
||||
|
||||
// Roll forward to fork height again and check again that we're normalized
|
||||
fixture.IncrementBlocks(1);
|
||||
BOOST_CHECK(chainActive.Height() == fixture.normalizationForkHeight);
|
||||
BOOST_CHECK(is_best_claim("NORMALIZETEST", tx1));
|
||||
BOOST_CHECK(is_best_claim("NormalizeTeST", tx1));
|
||||
BOOST_CHECK(is_best_claim("NormaLizeTeST", tx1));
|
||||
BOOST_CHECK(is_best_claim("Normalizetest", tx1)); // collapsed tx2
|
||||
|
||||
// Rewind to 1 block before the fork and be sure that the fork is
|
||||
// no longer active
|
||||
fixture.DecrementBlocks((chainActive.Height() - fixture.normalizationForkHeight) + 1);
|
||||
BOOST_CHECK(!pclaimTrie->shouldNormalize());
|
||||
BOOST_CHECK(is_best_claim("Normalizetest", tx2));
|
||||
|
||||
// Roll forward to fork height again and check again that we're normalized
|
||||
fixture.IncrementBlocks(1);
|
||||
BOOST_CHECK(chainActive.Height() == fixture.normalizationForkHeight);
|
||||
BOOST_CHECK(is_best_claim("NORMALIZETEST", tx1));
|
||||
BOOST_CHECK(is_best_claim("NormalizeTeST", tx1));
|
||||
BOOST_CHECK(is_best_claim("NormaLizeTeST", tx1));
|
||||
BOOST_CHECK(is_best_claim("Normalizetest", tx1)); // collapsed tx2
|
||||
}
|
||||
|
||||
/*
|
||||
claim/support expiration for hard fork, but with checks for disk procedures
|
||||
*/
|
||||
BOOST_AUTO_TEST_CASE(hardfork_disk_test)
|
||||
BOOST_AUTO_TEST_CASE(claimtriebranching_hardfork_disktest)
|
||||
{
|
||||
ClaimTrieChainFixture fixture;
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
BOOST_AUTO_TEST_SUITE(scheduler_tests)
|
||||
|
||||
#if 0 /* Disabled for now because there is a race condition issue in this test - see #6540 */
|
||||
static void microTask(CScheduler& s, boost::mutex& mutex, int& counter, int delta, boost::chrono::system_clock::time_point rescheduleTime)
|
||||
{
|
||||
{
|
||||
|
@ -40,7 +41,6 @@ static void MicroSleep(uint64_t n)
|
|||
#endif
|
||||
}
|
||||
|
||||
#if 0 /* Disabled for now because there is a race condition issue in this test - see #6540 */
|
||||
BOOST_AUTO_TEST_CASE(manythreads)
|
||||
{
|
||||
seed_insecure_rand(false);
|
||||
|
|
|
@ -68,7 +68,7 @@ TestingSetup::TestingSetup(const std::string& chainName) : BasicTestingSetup(cha
|
|||
pblocktree = new CBlockTreeDB(1 << 20, true);
|
||||
pcoinsdbview = new CCoinsViewDB(1 << 23, true);
|
||||
pcoinsTip = new CCoinsViewCache(pcoinsdbview);
|
||||
pclaimTrie = new CClaimTrie(true, false, 1);
|
||||
pclaimTrie = new CClaimTrie(true, false, false, 1);
|
||||
InitBlockIndex(chainparams);
|
||||
#ifdef ENABLE_WALLET
|
||||
bool fFirstRun;
|
||||
|
|
Loading…
Reference in a new issue