diff --git a/installers/build-cli-win.py b/installers/build-cli-win.py deleted file mode 100644 index be186b594..000000000 --- a/installers/build-cli-win.py +++ /dev/null @@ -1,88 +0,0 @@ -# -# This is a script for easily building the wownero cli installer in an automated build. Note -# that it is also possible to build the installer by dropping the .nsi file on the NSIS GUI, -# but that this will not work, as the script requires some defines, parsed from the wownero -# version file, to be passed on the command line. -# - -import sys -sys.dont_write_bytecode = True - -import os -import os.path -import subprocess - -# -# Grab the dir of this .py -# -basedir = os.path.dirname(os.path.abspath(__file__)) - -# -# Try to find version.cpp.in. -# -version_file = os.path.join('..', 'src', 'version.cpp.in') -if not os.path.isfile(version_file): - print('Version file not found: %s' % version_file) - sys.exit(-1) - -# -# Try to parse version.cpp.in. -# -version_string = None -release_name = None -with open(version_file, 'r') as fp: - version_prefix = '#define DEF_MONERO_VERSION "' - release_prefix = '#define DEF_MONERO_RELEASE_NAME "' - for line in fp: - if line.startswith(version_prefix): - version_string = line.replace(version_prefix, '')[:-2] - elif line.startswith(release_prefix): - release_name = line.replace(release_prefix, '')[:-2] - -if not version_string: - print('Failed to parse version from: %s' % version_file) - sys.exit(-1) - -if not release_name: - print('Failed to parse release name from: %s' % version_file) - sys.exit(-1) - -# -# Check that we got an expected version format. -# -version_parts = version_string.split('.') -if len(version_parts) != 4: - print('Invalid version string: %s' % version_string) - sys.exit(-1) - -# -# Try to find makensis. -# -makensis = 'makensis.exe' -if not os.path.isfile(makensis): - for dir in os.environ['PATH'].split(';'): - test = os.path.join(dir, makensis) - if os.path.isfile(test): - makensis = test - break - -if not os.path.isfile(makensis): - print('Failed to find makensis.exe') - sys.exit(-1) - -# -# Build & run makensis command line. -# -cmd = '"%s"' % makensis -cmd += ' /V4' -cmd += ' /DVERSION_MAJOR=%s' % version_parts[0] -cmd += ' /DVERSION_MINOR=%s' % version_parts[1] -cmd += ' /DVERSION_BUILD=%s' % version_parts[2] -cmd += ' /DVERSION_REVISION=%s' % version_parts[3] -cmd += ' /DRELEASE_NAME="%s"' % release_name -cmd += ' "%s"' % os.path.join(basedir, 'cli-win', 'installer.nsi') - -print("Calling makensis: %s" % cmd) - -subprocess.call(cmd) - diff --git a/installers/cli-win/app.ico b/installers/cli-win/app.ico deleted file mode 100644 index 3004f190a..000000000 Binary files a/installers/cli-win/app.ico and /dev/null differ diff --git a/installers/cli-win/header.bmp b/installers/cli-win/header.bmp deleted file mode 100644 index c27a11941..000000000 Binary files a/installers/cli-win/header.bmp and /dev/null differ diff --git a/installers/cli-win/installer.nsi b/installers/cli-win/installer.nsi deleted file mode 100644 index 289270a68..000000000 --- a/installers/cli-win/installer.nsi +++ /dev/null @@ -1,262 +0,0 @@ -;----------------------------------------------------------------------------------------- -; File: Wownero CLI NSIS installer -; Author: 0x000090 -; Date: 1 Dec 2018 -; License: WTFPL -;----------------------------------------------------------------------------------------- -; -; DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE -; Version 2, December 2004 -; -; Copyright (C) 2018 Wownero Inc., a Monero Enterprise Alliance partner company -; -; DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE -; TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION -; -; 0. You just DO WHAT THE FUCK YOU WANT TO. -; -;----------------------------------------------------------------------------------------- -!include 'MUI2.nsh' -!include 'TextFunc.nsh' -!include 'WordFunc.nsh' -!include 'Sections.nsh' - -;----------------------------------------------------------------------------------------- -!ifndef VERSION_MAJOR - !warning 'VERSION_MAJOR not defined!' - Quit -!endif - -!ifndef VERSION_MINOR - !warning 'VERSION_MINOR not defined!' - Quit -!endif - -!ifndef VERSION_BUILD - !warning 'VERSION_BUILD not defined!' - Quit -!endif - -!ifndef VERSION_REVISION - !warning 'VERSION_REVISION not defined!' - Quit -!endif - -!ifndef RELEASE_NAME - !warning 'RELEASE_NAME not defined!' - Quit -!endif - -!define VERSION_SHORT '${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_BUILD}' -!define VERSION_LONG '${VERSION_SHORT}.${VERSION_REVISION}' - -;----------------------------------------------------------------------------------------- -!define PROJECT_NAME 'Wownero' -!define PRODUCT_NAME 'Wownero CLI' -!define COMPANY_NAME 'Wownero Inc.' -!define EXE_BASENAME 'wownero' -!define HELP_URL 'http://wownero.org/#community' -!define ABOUT_URL 'http://wownero.org/#about' -!define SOURCE_DIR '..\..\build\release\bin' -!define TARGET_DIR '..\..\build\installers' -!define TARGET_PATH '${TARGET_DIR}\Wownero-CLI-${VERSION_LONG}-win.exe' -!define INSTALL_SUBDIR 'cli' -!define INSTALL_SIZE 181000 -!define UNINSTALLER_NAME 'uninstall.exe' -!define REG_BASE 'Software\Microsoft\Windows\CurrentVersion\Uninstall' -!define REG_KEY '${REG_BASE}\{E114584F-4E1B-4B2D-8B1C-69A188025E98}' -!define /date CURRENT_YEAR '%Y' - -;----------------------------------------------------------------------------------------- -!system 'if not exist "${TARGET_DIR}" md "${TARGET_DIR}"' - -;----------------------------------------------------------------------------------------- -Name '${PRODUCT_NAME}' -OutFile '${TARGET_PATH}' -BrandingText '${PRODUCT_NAME} ${VERSION_LONG} "${RELEASE_NAME}"' -CRCCheck force -RequestExecutionLevel admin -InstallDir "$PROGRAMFILES64\${PROJECT_NAME}\${INSTALL_SUBDIR}" -ShowInstDetails show -ShowUninstDetails show - -;----------------------------------------------------------------------------------------- -VIAddVersionKey 'CompanyName' '${COMPANY_NAME}' -VIAddVersionKey 'ProductName' '${PRODUCT_NAME}' -VIAddVersionKey 'FileDescription' '${PRODUCT_NAME}' -VIAddVersionKey 'LegalCopyright' 'Copyright (c) ${CURRENT_YEAR}, ${COMPANY_NAME}' -VIAddVersionKey 'FileVersion' '${VERSION_SHORT}' -VIProductVersion '${VERSION_LONG}' - -;----------------------------------------------------------------------------------------- -!define MUI_ABORTWARNING -!define MUI_UNABORTWARNING - -!define MUI_FINISHPAGE_NOAUTOCLOSE -!define MUI_UNFINISHPAGE_NOAUTOCLOSE - -!define MUI_ICON "app.ico" -!define MUI_UNICON "app.ico" - -!define MUI_HEADERIMAGE -!define MUI_HEADERIMAGE_RIGHT -!define MUI_HEADERIMAGE_BITMAP "header.bmp" -!define MUI_HEADERIMAGE_UNBITMAP "header.bmp" -!define MUI_HEADERIMAGE_BITMAP_NOSTRETCH -!define MUI_HEADERIMAGE_UNBITMAP_NOSTRETCH - -!define MUI_WELCOMEFINISHPAGE_BITMAP "welcome.bmp" -!define MUI_UNWELCOMEFINISHPAGE_BITMAP "welcome.bmp" -!define MUI_WELCOMEFINISHPAGE_BITMAP_NOSTRETCH -!define MUI_UNWELCOMEFINISHPAGE_UNBITMAP_NOSTRETCH - -;----------------------------------------------------------------------------------------- -!insertmacro MUI_PAGE_WELCOME -!insertmacro MUI_PAGE_DIRECTORY -!insertmacro MUI_PAGE_INSTFILES -!insertmacro MUI_UNPAGE_WELCOME -!insertmacro MUI_UNPAGE_CONFIRM -!insertmacro MUI_UNPAGE_INSTFILES - -;----------------------------------------------------------------------------------------- -!insertmacro MUI_LANGUAGE "English" - -;----------------------------------------------------------------------------------------- -Function VerifyUserIsAdmin - UserInfo::GetAccountType - Pop $0 - ${If} $0 != "admin" - MessageBox MB_ICONSTOP "Admin permissions required, please use right-click > Run as Administrator." - SetErrorLevel 740 ; ERROR_ELEVATION_REQUIRED - Quit - ${EndIf} -FunctionEnd - -Function .onInit - Call VerifyUserIsAdmin -FunctionEnd - -Function un.onInit -FunctionEnd - -;----------------------------------------------------------------------------------------- -!macro RemoveFile file - Push $0 - ${TrimNewLines} '${file}' $0 - SetDetailsPrint both - ${If} ${FileExists} '$0' - DetailPrint 'Deleting file $0' - SetDetailsPrint textonly - Delete "$0" - ${Else} - DetailPrint 'File not found: $0' - ${Endif} - SetDetailsPrint lastused - Pop $0 -!macroend - -!macro RemoveDir dir - Push $0 - ${TrimNewLines} '${dir}' $0 - SetDetailsPrint both - ${If} ${FileExists} '$0' - DetailPrint 'Deleting directory $0' - SetDetailsPrint textonly - RmDir /r "$0" - ${Else} - DetailPrint 'Directory not found: $0' - ${Endif} - SetDetailsPrint lastused - Pop $0 -!macroend - -;----------------------------------------------------------------------------------------- -Function WriteFiles - DetailPrint 'Installing application files...' - SetDetailsPrint both - SetOutPath '$INSTDIR' - File 'app.ico' - - ; - ; Add here whatever else you want to be included: - ; - File '${SOURCE_DIR}\${EXE_BASENAME}d.exe' - File '${SOURCE_DIR}\${EXE_BASENAME}-wallet-cli.exe' - File '${SOURCE_DIR}\${EXE_BASENAME}-wallet-rpc.exe' - File '${SOURCE_DIR}\${EXE_BASENAME}-gen-trusted-multisig.exe' - - ; - ; NOTE: you can also add all files in a dir, like this: - ; - ;File /r '${SOURCE_DIR}\*.*' - - SetDetailsPrint lastused - DetailPrint 'Writing uninstaller...' - WriteUninstaller '$INSTDIR\${UNINSTALLER_NAME}' -FunctionEnd - -Function un.WriteFiles - DetailPrint 'Removing application files...' - !insertmacro RemoveDir '$INSTDIR' -FunctionEnd - -;----------------------------------------------------------------------------------------- -Function WriteShortcuts - DetailPrint 'Creating Desktop shortcuts...' - CreateShortCut '$DESKTOP\${PRODUCT_NAME} Wallet.lnk' '$INSTDIR\${EXE_BASENAME}-wallet-cli.exe' '' '$INSTDIR\app.ico' - CreateShortCut '$DESKTOP\${PRODUCT_NAME} Daemon.lnk' '$INSTDIR\${EXE_BASENAME}d.exe' '' '$INSTDIR\app.ico' - DetailPrint 'Creating Start Menu shortcuts...' - CreateDirectory '$SMPROGRAMS\${COMPANY_NAME}\${PRODUCT_NAME}' - CreateShortCut '$SMPROGRAMS\${COMPANY_NAME}\${PRODUCT_NAME}\${PRODUCT_NAME} Wallet.lnk' '$INSTDIR\${EXE_BASENAME}-wallet-cli.exe' '' '$INSTDIR\app.ico' - CreateShortCut '$SMPROGRAMS\${COMPANY_NAME}\${PRODUCT_NAME}\${PRODUCT_NAME} Daemon.lnk' '$INSTDIR\${EXE_BASENAME}d.exe' '' '$INSTDIR\app.ico' - CreateShortCut '$SMPROGRAMS\${COMPANY_NAME}\${PRODUCT_NAME}\Uninstall ${PRODUCT_NAME}.lnk' '$INSTDIR\${UNINSTALLER_NAME}' '' '$INSTDIR\app.ico' -FunctionEnd - -Function un.WriteShortcuts - DetailPrint 'Removing Desktop shortcuts...' - !insertmacro RemoveFile '$DESKTOP\${PRODUCT_NAME} Daemon.lnk' - !insertmacro RemoveFile '$DESKTOP\${PRODUCT_NAME} Wallet.lnk' - DetailPrint 'Removing Start Menu shortcuts...' - !insertmacro RemoveDir '$SMPROGRAMS\${COMPANY_NAME}\${PRODUCT_NAME}' -FunctionEnd - -;----------------------------------------------------------------------------------------- -Function WriteUninstaller - DetailPrint 'Registering ${PRODUCT_NAME} ${VERSION_SHORT}' - WriteRegDWORD HKLM '${REG_KEY}' 'VersionMajor' ${VERSION_MAJOR} - WriteRegDWORD HKLM '${REG_KEY}' 'VersionMinor' ${VERSION_MINOR} - WriteRegDWORD HKLM '${REG_KEY}' 'EstimatedSize' ${INSTALL_SIZE} - WriteRegDWORD HKLM '${REG_KEY}' 'NoModify' 1 - WriteRegDWORD HKLM '${REG_KEY}' 'NoRepair' 1 - WriteRegStr HKLM '${REG_KEY}' 'Contact' '${COMPANY_NAME}' - WriteRegStr HKLM '${REG_KEY}' 'Publisher' '${COMPANY_NAME}' - WriteRegStr HKLM '${REG_KEY}' 'HelpLink' '${HELP_URL}' - WriteRegStr HKLM '${REG_KEY}' 'URLInfoAbout' '${ABOUT_URL}' - WriteRegStr HKLM '${REG_KEY}' 'DisplayVersion' '${VERSION_SHORT}' - WriteRegStr HKLM '${REG_KEY}' 'Comments' '${PRODUCT_NAME}' - WriteRegStr HKLM '${REG_KEY}' 'DisplayName' '${PRODUCT_NAME} ${VERSION_SHORT}' - WriteRegStr HKLM '${REG_KEY}' 'InstallLocation' '"$INSTDIR"' - WriteRegStr HKLM '${REG_KEY}' 'DisplayIcon' '"$INSTDIR\app.ico"' - WriteRegStr HKLM '${REG_KEY}' 'UninstallString' '"$INSTDIR\${UNINSTALLER_NAME}"' - WriteRegStr HKLM '${REG_KEY}' 'QuietUninstallString' '"$INSTDIR\${UNINSTALLER_NAME}" /S' -FunctionEnd - -Function un.WriteUninstaller - DetailPrint 'Unregistering ${PRODUCT_NAME} ${VERSION_SHORT}...' - DeleteRegKey HKLM '${REG_KEY}' -FunctionEnd - -;----------------------------------------------------------------------------------------- -Section "${PRODUCT_NAME} ${VERSION_SHORT}" - Call WriteFiles - Call WriteShortcuts - Call WriteUninstaller -SectionEnd - -;----------------------------------------------------------------------------------------- -Section "Uninstall" - Call un.WriteFiles - Call un.WriteShortcuts - Call un.WriteUninstaller -SectionEnd - diff --git a/installers/cli-win/welcome.bmp b/installers/cli-win/welcome.bmp deleted file mode 100644 index f690cc96d..000000000 Binary files a/installers/cli-win/welcome.bmp and /dev/null differ diff --git a/installers/readme.txt b/installers/readme.txt deleted file mode 100644 index a22a088c6..000000000 --- a/installers/readme.txt +++ /dev/null @@ -1,31 +0,0 @@ -Installer notes - -So, at this point I just have one installer, for the cli, on windows. What do you need -to know .. - -1. It uses NSIS, and expects to find makensis.exe on your PATH. - -2. It expects built products to be found at: - - wownero/build/release/bin - -3. It currently includes the daemon, wallet, rpc, and gen-trusted-multisig. I note that - releases on the wownero github have had different files (static libs, pthreads dll) - than I end up with in my /bin dir when I build, so you may or may not need to change - which files you include. At any rate, it is easy to do, in the WriteFiles function - in installer.nsi. - -4. Provided everything is ok, it should be as simple as executing build-cli-win.py; built - installer, versioned according to src/version.cpp.in, will be depostied here: - - wownero/build/installers/Wownero-CLI--win.exe - -5. The installer includes an uninstaller, shortcuts on desktop & start menu, and it - registers itself with windows, so it shows up as expected in programs & features. - -6. I have tried to keep the installer script pretty generic, so it can be reused later, - for gui, or whatever. It installs to a /Wownero/cli subdirectory, so - that other applications can eventually be installed alongside. NOTE: if you copy the - installer.nsi file to use for another project, you will need to make a new GUID for - it, and put it in the REG_KEY define. - diff --git a/src/crypto/chacha.h b/src/crypto/chacha.h index a39823e5a..1cc1ed88a 100644 --- a/src/crypto/chacha.h +++ b/src/crypto/chacha.h @@ -73,18 +73,18 @@ namespace crypto { inline void generate_chacha_key(const void *data, size_t size, chacha_key& key, uint64_t kdf_rounds) { static_assert(sizeof(chacha_key) <= sizeof(hash), "Size of hash must be at least that of chacha_key"); epee::mlocked> pwd_hash; - crypto::cn_slow_hash(data, size, pwd_hash.data(), 0/*variant*/, 0/*prehashed*/, 0/*height*/); + crypto::cn_slow_hash(data, size, pwd_hash.data(), 0/*variant*/, 0/*prehashed*/); for (uint64_t n = 1; n < kdf_rounds; ++n) - crypto::cn_slow_hash(pwd_hash.data(), pwd_hash.size(), pwd_hash.data(), 0/*variant*/, 0/*prehashed*/, 0/*height*/); + crypto::cn_slow_hash(pwd_hash.data(), pwd_hash.size(), pwd_hash.data(), 0/*variant*/, 0/*prehashed*/); memcpy(&unwrap(unwrap(key)), pwd_hash.data(), sizeof(key)); } inline void generate_chacha_key_prehashed(const void *data, size_t size, chacha_key& key, uint64_t kdf_rounds) { static_assert(sizeof(chacha_key) <= sizeof(hash), "Size of hash must be at least that of chacha_key"); epee::mlocked> pwd_hash; - crypto::cn_slow_hash(data, size, pwd_hash.data(), 0/*variant*/, 1/*prehashed*/, 0/*height*/); + crypto::cn_slow_hash(data, size, pwd_hash.data(), 0/*variant*/, 1/*prehashed*/); for (uint64_t n = 1; n < kdf_rounds; ++n) - crypto::cn_slow_hash(pwd_hash.data(), pwd_hash.size(), pwd_hash.data(), 0/*variant*/, 0/*prehashed*/, 0/*height*/); + crypto::cn_slow_hash(pwd_hash.data(), pwd_hash.size(), pwd_hash.data(), 0/*variant*/, 0/*prehashed*/); memcpy(&unwrap(unwrap(key)), pwd_hash.data(), sizeof(key)); } diff --git a/src/crypto/hash-ops.h b/src/crypto/hash-ops.h index 859c810bd..0f7cd0c2a 100644 --- a/src/crypto/hash-ops.h +++ b/src/crypto/hash-ops.h @@ -79,7 +79,7 @@ enum { }; void cn_fast_hash(const void *data, size_t length, char *hash); -void cn_slow_hash(const void *data, size_t length, char *hash, int variant, int prehashed, uint64_t height); +void cn_slow_hash(const void *data, size_t length, char *hash, int variant, int prehashed); void hash_extra_blake(const void *data, size_t length, char *hash); void hash_extra_groestl(const void *data, size_t length, char *hash); diff --git a/src/crypto/hash.h b/src/crypto/hash.h index 17071923d..450953584 100644 --- a/src/crypto/hash.h +++ b/src/crypto/hash.h @@ -71,12 +71,12 @@ namespace crypto { return h; } - inline void cn_slow_hash(const void *data, std::size_t length, hash &hash, int variant = 0, uint64_t height = 0) { - cn_slow_hash(data, length, reinterpret_cast(&hash), variant, 0/*prehashed*/, height); + inline void cn_slow_hash(const void *data, std::size_t length, hash &hash, int variant = 0) { + cn_slow_hash(data, length, reinterpret_cast(&hash), variant, 0/*prehashed*/); } - inline void cn_slow_hash_prehashed(const void *data, std::size_t length, hash &hash, int variant = 0, uint64_t height = 0) { - cn_slow_hash(data, length, reinterpret_cast(&hash), variant, 1/*prehashed*/, height); + inline void cn_slow_hash_prehashed(const void *data, std::size_t length, hash &hash, int variant = 0) { + cn_slow_hash(data, length, reinterpret_cast(&hash), variant, 1/*prehashed*/); } inline void tree_hash(const hash *hashes, std::size_t count, hash &root_hash) { diff --git a/src/crypto/slow-hash.c b/src/crypto/slow-hash.c index 8da79dee0..ceb3a567b 100644 --- a/src/crypto/slow-hash.c +++ b/src/crypto/slow-hash.c @@ -39,7 +39,6 @@ #include "hash-ops.h" #include "oaes_lib.h" #include "variant2_int_sqrt.h" -#include "variant4_random_math.h" #define MEMORY (1 << 21) // 2MB scratchpad #define ITER (1 << 20) @@ -173,7 +172,7 @@ extern void aesb_pseudo_round(const uint8_t *in, uint8_t *out, const uint8_t *ex const uint64_t sqrt_input = SWAP64LE(((uint64_t*)(ptr))[0]) + division_result #define VARIANT2_INTEGER_MATH_SSE2(b, ptr) \ - do if ((variant == 2) || (variant == 3)) \ + do if (variant >= 2) \ { \ VARIANT2_INTEGER_MATH_DIVISION_STEP(b, ptr); \ VARIANT2_INTEGER_MATH_SQRT_STEP_SSE2(); \ @@ -183,7 +182,7 @@ extern void aesb_pseudo_round(const uint8_t *in, uint8_t *out, const uint8_t *ex #if defined DBL_MANT_DIG && (DBL_MANT_DIG >= 50) // double precision floating point type has enough bits of precision on current platform #define VARIANT2_PORTABLE_INTEGER_MATH(b, ptr) \ - do if ((variant == 2) || (variant == 3)) \ + do if (variant >= 2) \ { \ VARIANT2_INTEGER_MATH_DIVISION_STEP(b, ptr); \ VARIANT2_INTEGER_MATH_SQRT_STEP_FP64(); \ @@ -193,7 +192,7 @@ extern void aesb_pseudo_round(const uint8_t *in, uint8_t *out, const uint8_t *ex // double precision floating point type is not good enough on current platform // fall back to the reference code (integer only) #define VARIANT2_PORTABLE_INTEGER_MATH(b, ptr) \ - do if ((variant == 2) || (variant == 3)) \ + do if (variant >= 2) \ { \ VARIANT2_INTEGER_MATH_DIVISION_STEP(b, ptr); \ VARIANT2_INTEGER_MATH_SQRT_STEP_REF(); \ @@ -215,33 +214,6 @@ extern void aesb_pseudo_round(const uint8_t *in, uint8_t *out, const uint8_t *ex lo ^= SWAP64LE(*(U64(hp_state + (j ^ 0x20)) + 1)); \ } while (0) -#define VARIANT4_RANDOM_MATH_INIT() \ - v4_reg r[8]; \ - struct V4_Instruction code[TOTAL_LATENCY * ALU_COUNT + 1]; \ - do if (variant >= 4) \ - { \ - v4_reg* data = (v4_reg*)(state.hs.w + 12); \ - r[0] = data[0]; \ - r[1] = data[1]; \ - r[2] = data[2]; \ - r[3] = data[3]; \ - v4_random_math_init(code, height); \ - } while (0) - -#define VARIANT4_RANDOM_MATH(a, b, r, _b, _b1) \ - do if (variant >= 4) \ - { \ - if (sizeof(v4_reg) == sizeof(uint32_t)) \ - U64(b)[0] ^= (r[0] + r[1]) | ((uint64_t)(r[2] + r[3]) << 32); \ - else \ - U64(b)[0] ^= (r[0] + r[1]) ^ (r[2] + r[3]); \ - r[4] = ((v4_reg*)(a))[0]; \ - r[5] = ((v4_reg*)(a))[sizeof(uint64_t) / sizeof(v4_reg)]; \ - r[6] = ((v4_reg*)(_b))[0]; \ - r[7] = ((v4_reg*)(_b1))[0]; \ - v4_random_math(code, r); \ - } while (0) - #if !defined NO_AES && (defined(__x86_64__) || (defined(_MSC_VER) && defined(_WIN64))) // Optimised code below, uses x86-specific intrinsics, SSE2, AES-NI @@ -326,7 +298,6 @@ extern void aesb_pseudo_round(const uint8_t *in, uint8_t *out, const uint8_t *ex p = U64(&hp_state[j]); \ b[0] = p[0]; b[1] = p[1]; \ VARIANT2_INTEGER_MATH_SSE2(b, c); \ - VARIANT4_RANDOM_MATH(a, b, r, &_b, &_b1); \ __mul(); \ VARIANT2_2(); \ VARIANT2_SHUFFLE_ADD_SSE2(hp_state, j); \ @@ -723,7 +694,7 @@ void slow_hash_free_state(void) * @param length the length in bytes of the data * @param hash a pointer to a buffer in which the final 256 bit hash will be stored */ -void cn_slow_hash(const void *data, size_t length, char *hash, int variant, int prehashed, uint64_t height) +void cn_slow_hash(const void *data, size_t length, char *hash, int variant, int prehashed) { RDATA_ALIGN16 uint8_t expandedKey[240]; /* These buffers are aligned to use later with SSE functions */ @@ -759,7 +730,6 @@ void cn_slow_hash(const void *data, size_t length, char *hash, int variant, int VARIANT1_INIT64(); VARIANT2_INIT64(); - VARIANT4_RANDOM_MATH_INIT(); /* CryptoNight Step 2: Iteratively encrypt the results from Keccak to fill * the 2MB large random access buffer. @@ -931,7 +901,6 @@ union cn_slow_hash_state p = U64(&hp_state[j]); \ b[0] = p[0]; b[1] = p[1]; \ VARIANT2_PORTABLE_INTEGER_MATH(b, c); \ - VARIANT4_RANDOM_MATH(a, b, r, &_b, &_b1); \ __mul(); \ VARIANT2_2(); \ VARIANT2_SHUFFLE_ADD_NEON(hp_state, j); \ @@ -1094,7 +1063,7 @@ STATIC INLINE void aligned_free(void *ptr) } #endif /* FORCE_USE_HEAP */ -void cn_slow_hash(const void *data, size_t length, char *hash, int variant, int prehashed, uint64_t height) +void cn_slow_hash(const void *data, size_t length, char *hash, int variant, int prehashed) { RDATA_ALIGN16 uint8_t expandedKey[240]; @@ -1131,7 +1100,6 @@ void cn_slow_hash(const void *data, size_t length, char *hash, int variant, int VARIANT1_INIT64(); VARIANT2_INIT64(); - VARIANT4_RANDOM_MATH_INIT(); /* CryptoNight Step 2: Iteratively encrypt the results from Keccak to fill * the 2MB large random access buffer. @@ -1310,7 +1278,7 @@ STATIC INLINE void xor_blocks(uint8_t* a, const uint8_t* b) U64(a)[1] ^= U64(b)[1]; } -void cn_slow_hash(const void *data, size_t length, char *hash, int variant, int prehashed, uint64_t height) +void cn_slow_hash(const void *data, size_t length, char *hash, int variant, int prehashed) { uint8_t text[INIT_SIZE_BYTE]; uint8_t a[AES_BLOCK_SIZE]; @@ -1349,7 +1317,6 @@ void cn_slow_hash(const void *data, size_t length, char *hash, int variant, int VARIANT1_INIT64(); VARIANT2_INIT64(); - VARIANT4_RANDOM_MATH_INIT(); // use aligned data memcpy(expandedKey, aes_ctx->key->exp_data, aes_ctx->key->exp_data_len); @@ -1386,7 +1353,6 @@ void cn_slow_hash(const void *data, size_t length, char *hash, int variant, int copy_block(c, p); VARIANT2_PORTABLE_INTEGER_MATH(c, c1); - VARIANT4_RANDOM_MATH(a, c, r, b, b + AES_BLOCK_SIZE); mul(c1, c, d); VARIANT2_2_PORTABLE(); VARIANT2_PORTABLE_SHUFFLE_ADD(long_state, j); @@ -1510,7 +1476,7 @@ union cn_slow_hash_state { }; #pragma pack(pop) -void cn_slow_hash(const void *data, size_t length, char *hash, int variant, int prehashed, uint64_t height) { +void cn_slow_hash(const void *data, size_t length, char *hash, int variant, int prehashed) { #ifndef FORCE_USE_HEAP uint8_t long_state[MEMORY]; #else @@ -1539,7 +1505,6 @@ void cn_slow_hash(const void *data, size_t length, char *hash, int variant, int VARIANT1_PORTABLE_INIT(); VARIANT2_PORTABLE_INIT(); - VARIANT4_RANDOM_MATH_INIT(); oaes_key_import_data(aes_ctx, aes_key, AES_KEY_SIZE); for (i = 0; i < MEMORY / INIT_SIZE_BYTE; i++) { @@ -1572,7 +1537,6 @@ void cn_slow_hash(const void *data, size_t length, char *hash, int variant, int j = e2i(c1, MEMORY / AES_BLOCK_SIZE) * AES_BLOCK_SIZE; copy_block(c2, &long_state[j]); VARIANT2_PORTABLE_INTEGER_MATH(c2, c1); - VARIANT4_RANDOM_MATH(a, c2, r, b, b + AES_BLOCK_SIZE); mul(c1, c2, d); VARIANT2_2_PORTABLE(); VARIANT2_PORTABLE_SHUFFLE_ADD(long_state, j); diff --git a/src/crypto/variant4_random_math.h b/src/crypto/variant4_random_math.h deleted file mode 100644 index fc16ef4d8..000000000 --- a/src/crypto/variant4_random_math.h +++ /dev/null @@ -1,412 +0,0 @@ -#ifndef VARIANT4_RANDOM_MATH_H -#define VARIANT4_RANDOM_MATH_H - -// Register size can be configured to either 32 bit (uint32_t) or 64 bit (uint64_t) -typedef uint32_t v4_reg; - -enum V4_Settings -{ - // Generate code with minimal theoretical latency = 45 cycles, which is equivalent to 15 multiplications - TOTAL_LATENCY = 15 * 3, - - // Always generate at least 60 instructions - NUM_INSTRUCTIONS = 60, - - // Available ALUs for MUL - // Modern CPUs typically have only 1 ALU which can do multiplications - ALU_COUNT_MUL = 1, - - // Total available ALUs - // Modern CPUs have 4 ALUs, but we use only 3 because random math executes together with other main loop code - ALU_COUNT = 3, -}; - -enum V4_InstructionList -{ - MUL, // a*b - ADD, // a+b + C, -128 <= C <= 127 - SUB, // a-b - ROR, // rotate right "a" by "b & 31" bits - ROL, // rotate left "a" by "b & 31" bits - XOR, // a^b - RET, // finish execution - V4_INSTRUCTION_COUNT = RET, -}; - -// V4_InstructionDefinition is used to generate code from random data -// Every random sequence of bytes is a valid code -// -// There are 8 registers in total: -// - 4 variable registers -// - 4 constant registers initialized from loop variables -// -// This is why dst_index is 2 bits -enum V4_InstructionDefinition -{ - V4_OPCODE_BITS = 3, - V4_DST_INDEX_BITS = 2, - V4_SRC_INDEX_BITS = 3, -}; - -struct V4_Instruction -{ - uint8_t opcode; - uint8_t dst_index; - uint8_t src_index; - uint32_t C; -}; - -#ifndef FORCEINLINE -#ifdef __GNUC__ -#define FORCEINLINE __attribute__((always_inline)) inline -#elif _MSC_VER -#define FORCEINLINE __forceinline -#else -#define FORCEINLINE inline -#endif -#endif - -#ifndef UNREACHABLE_CODE -#ifdef __GNUC__ -#define UNREACHABLE_CODE __builtin_unreachable() -#elif _MSC_VER -#define UNREACHABLE_CODE __assume(false) -#else -#define UNREACHABLE_CODE -#endif -#endif - -// Random math interpreter's loop is fully unrolled and inlined to achieve 100% branch prediction on CPU: -// every switch-case will point to the same destination on every iteration of Cryptonight main loop -// -// This is about as fast as it can get without using low-level machine code generation -static FORCEINLINE void v4_random_math(const struct V4_Instruction* code, v4_reg* r) -{ - enum - { - REG_BITS = sizeof(v4_reg) * 8, - }; - -#define V4_EXEC(i) \ - { \ - const struct V4_Instruction* op = code + i; \ - const v4_reg src = r[op->src_index]; \ - v4_reg* dst = r + op->dst_index; \ - switch (op->opcode) \ - { \ - case MUL: \ - *dst *= src; \ - break; \ - case ADD: \ - *dst += src + op->C; \ - break; \ - case SUB: \ - *dst -= src; \ - break; \ - case ROR: \ - { \ - const uint32_t shift = src % REG_BITS; \ - *dst = (*dst >> shift) | (*dst << (REG_BITS - shift)); \ - } \ - break; \ - case ROL: \ - { \ - const uint32_t shift = src % REG_BITS; \ - *dst = (*dst << shift) | (*dst >> (REG_BITS - shift)); \ - } \ - break; \ - case XOR: \ - *dst ^= src; \ - break; \ - case RET: \ - return; \ - default: \ - UNREACHABLE_CODE; \ - break; \ - } \ - } - -#define V4_EXEC_10(j) \ - V4_EXEC(j + 0) \ - V4_EXEC(j + 1) \ - V4_EXEC(j + 2) \ - V4_EXEC(j + 3) \ - V4_EXEC(j + 4) \ - V4_EXEC(j + 5) \ - V4_EXEC(j + 6) \ - V4_EXEC(j + 7) \ - V4_EXEC(j + 8) \ - V4_EXEC(j + 9) - - // Generated program can have 60 + a few more (usually 2-3) instructions to achieve required latency - // I've checked all block heights < 10,000,000 and here is the distribution of program sizes: - // - // 60 28495 - // 61 106077 - // 62 2455855 - // 63 5114930 - // 64 1020868 - // 65 1109026 - // 66 151756 - // 67 8429 - // 68 4477 - // 69 87 - - // Unroll 70 instructions here - V4_EXEC_10(0); // instructions 0-9 - V4_EXEC_10(10); // instructions 10-19 - V4_EXEC_10(20); // instructions 20-29 - V4_EXEC_10(30); // instructions 30-39 - V4_EXEC_10(40); // instructions 40-49 - V4_EXEC_10(50); // instructions 50-59 - V4_EXEC_10(60); // instructions 60-69 - -#undef V4_EXEC_10 -#undef V4_EXEC -} - -// If we don't have enough data available, generate more -static FORCEINLINE void check_data(size_t* data_index, const size_t bytes_needed, char* data, const size_t data_size) -{ - if (*data_index + bytes_needed > data_size) - { - hash_extra_blake(data, data_size, data); - *data_index = 0; - } -} - -// Generates as many random math operations as possible with given latency and ALU restrictions -static inline int v4_random_math_init(struct V4_Instruction* code, const uint64_t height) -{ - // MUL is 3 cycles, 3-way addition and rotations are 2 cycles, SUB/XOR are 1 cycle - // These latencies match real-life instruction latencies for Intel CPUs starting from Sandy Bridge and up to Skylake/Coffee lake - // - // AMD Ryzen has the same latencies except 1-cycle ROR/ROL, so it'll be a bit faster than Intel Sandy Bridge and newer processors - // Surprisingly, Intel Nehalem also has 1-cycle ROR/ROL, so it'll also be faster than Intel Sandy Bridge and newer processors - // AMD Bulldozer has 4 cycles latency for MUL (slower than Intel) and 1 cycle for ROR/ROL (faster than Intel), so average performance will be the same - // Source: https://www.agner.org/optimize/instruction_tables.pdf - const int op_latency[V4_INSTRUCTION_COUNT] = { 3, 2, 1, 2, 2, 1 }; - - // Instruction latencies for theoretical ASIC implementation - const int asic_op_latency[V4_INSTRUCTION_COUNT] = { 3, 1, 1, 1, 1, 1 }; - - // Available ALUs for each instruction - const int op_ALUs[V4_INSTRUCTION_COUNT] = { ALU_COUNT_MUL, ALU_COUNT, ALU_COUNT, ALU_COUNT, ALU_COUNT, ALU_COUNT }; - - char data[32]; - memset(data, 0, sizeof(data)); - *((uint64_t*)data) = height; - - size_t data_index = sizeof(data); - - int code_size; - do { - int latency[8]; - int asic_latency[8]; - - // Tracks previous instruction and value of the source operand for registers R0-R3 throughout code execution - // byte 0: current value of the destination register - // byte 1: instruction opcode - // byte 2: current value of the source register - // - // Registers R4-R7 are constant and are threatened as having the same value because when we do - // the same operation twice with two constant source registers, it can be optimized into a single operation - int inst_data[8] = { 0, 1, 2, 3, -1, -1, -1, -1 }; - - bool alu_busy[TOTAL_LATENCY + 1][ALU_COUNT]; - bool is_rotation[V4_INSTRUCTION_COUNT]; - bool rotated[4]; - int rotate_count = 0; - - memset(latency, 0, sizeof(latency)); - memset(asic_latency, 0, sizeof(asic_latency)); - memset(alu_busy, 0, sizeof(alu_busy)); - memset(is_rotation, 0, sizeof(is_rotation)); - memset(rotated, 0, sizeof(rotated)); - is_rotation[ROR] = true; - is_rotation[ROL] = true; - - int num_retries = 0; - code_size = 0; - - // Generate random code to achieve minimal required latency for our abstract CPU - // Try to get this latency for all 4 registers - while (((latency[0] < TOTAL_LATENCY) || (latency[1] < TOTAL_LATENCY) || (latency[2] < TOTAL_LATENCY) || (latency[3] < TOTAL_LATENCY)) && (num_retries < 64)) - { - check_data(&data_index, 1, data, sizeof(data)); - - const uint8_t c = ((uint8_t*)data)[data_index++]; - - // MUL = opcodes 0-2 - // ADD = opcode 3 - // SUB = opcode 4 - // ROR/ROL = opcode 5, shift direction is selected randomly - // XOR = opcodes 6-7 - uint8_t opcode = c & ((1 << V4_OPCODE_BITS) - 1); - if (opcode == 5) - { - check_data(&data_index, 1, data, sizeof(data)); - opcode = (data[data_index++] >= 0) ? ROR : ROL; - } - else if (opcode >= 6) - { - opcode = XOR; - } - else - { - opcode = (opcode <= 2) ? MUL : (opcode - 2); - } - - uint8_t dst_index = (c >> V4_OPCODE_BITS) & ((1 << V4_DST_INDEX_BITS) - 1); - uint8_t src_index = (c >> (V4_OPCODE_BITS + V4_DST_INDEX_BITS)) & ((1 << V4_SRC_INDEX_BITS) - 1); - - const int a = dst_index; - int b = src_index; - - // Don't do ADD/SUB/XOR with the same register - if (((opcode == ADD) || (opcode == SUB) || (opcode == XOR)) && (a == b)) - { - // a is always < 4, so we don't need to check bounds here - b = a + 4; - src_index = b; - } - - // Don't do rotation with the same destination twice because it's equal to a single rotation - if (is_rotation[opcode] && rotated[a]) - { - continue; - } - - // Don't do the same instruction (except MUL) with the same source value twice because all other cases can be optimized: - // 2xADD(a, b, C) = ADD(a, b*2, C1+C2), same for SUB and rotations - // 2xXOR(a, b) = NOP - if ((opcode != MUL) && ((inst_data[a] & 0xFFFF00) == (opcode << 8) + ((inst_data[b] & 255) << 16))) - { - continue; - } - - // Find which ALU is available (and when) for this instruction - int next_latency = (latency[a] > latency[b]) ? latency[a] : latency[b]; - int alu_index = -1; - while (next_latency < TOTAL_LATENCY) - { - for (int i = op_ALUs[opcode] - 1; i >= 0; --i) - { - if (!alu_busy[next_latency][i]) - { - // ADD is implemented as two 1-cycle instructions on a real CPU, so do an additional availability check - if ((opcode == ADD) && alu_busy[next_latency + 1][i]) - { - continue; - } - - // Rotation can only start when previous rotation is finished, so do an additional availability check - if (is_rotation[opcode] && (next_latency < rotate_count * op_latency[opcode])) - { - continue; - } - - alu_index = i; - break; - } - } - if (alu_index >= 0) - { - break; - } - ++next_latency; - } - - // Don't generate instructions that leave some register unchanged for more than 7 cycles - if (next_latency > latency[a] + 7) - { - continue; - } - - next_latency += op_latency[opcode]; - - if (next_latency <= TOTAL_LATENCY) - { - if (is_rotation[opcode]) - { - ++rotate_count; - } - - // Mark ALU as busy only for the first cycle when it starts executing the instruction because ALUs are fully pipelined - alu_busy[next_latency - op_latency[opcode]][alu_index] = true; - latency[a] = next_latency; - - // ASIC is supposed to have enough ALUs to run as many independent instructions per cycle as possible, so latency calculation for ASIC is simple - asic_latency[a] = ((asic_latency[a] > asic_latency[b]) ? asic_latency[a] : asic_latency[b]) + asic_op_latency[opcode]; - - rotated[a] = is_rotation[opcode]; - - inst_data[a] = code_size + (opcode << 8) + ((inst_data[b] & 255) << 16); - - code[code_size].opcode = opcode; - code[code_size].dst_index = dst_index; - code[code_size].src_index = src_index; - code[code_size].C = 0; - - if (opcode == ADD) - { - // ADD instruction is implemented as two 1-cycle instructions on a real CPU, so mark ALU as busy for the next cycle too - alu_busy[next_latency - op_latency[opcode] + 1][alu_index] = true; - - // ADD instruction requires 4 more random bytes for 32-bit constant "C" in "a = a + b + C" - check_data(&data_index, sizeof(uint32_t), data, sizeof(data)); - code[code_size].C = *((uint32_t*)&data[data_index]); - data_index += sizeof(uint32_t); - } - - ++code_size; - if (code_size >= NUM_INSTRUCTIONS) - { - break; - } - } - else - { - ++num_retries; - } - } - - // ASIC has more execution resources and can extract as much parallelism from the code as possible - // We need to add a few more MUL and ROR instructions to achieve minimal required latency for ASIC - // Get this latency for at least 1 of the 4 registers - const int prev_code_size = code_size; - while ((asic_latency[0] < TOTAL_LATENCY) && (asic_latency[1] < TOTAL_LATENCY) && (asic_latency[2] < TOTAL_LATENCY) && (asic_latency[3] < TOTAL_LATENCY)) - { - int min_idx = 0; - int max_idx = 0; - for (int i = 1; i < 4; ++i) - { - if (asic_latency[i] < asic_latency[min_idx]) min_idx = i; - if (asic_latency[i] > asic_latency[max_idx]) max_idx = i; - } - - const uint8_t pattern[3] = { ROR, MUL, MUL }; - const uint8_t opcode = pattern[(code_size - prev_code_size) % 3]; - latency[min_idx] = latency[max_idx] + op_latency[opcode]; - asic_latency[min_idx] = asic_latency[max_idx] + asic_op_latency[opcode]; - - code[code_size].opcode = opcode; - code[code_size].dst_index = min_idx; - code[code_size].src_index = max_idx; - code[code_size].C = 0; - ++code_size; - } - - // There is ~99.8% chance that code_size >= NUM_INSTRUCTIONS here, so second iteration is required rarely - } while (code_size < NUM_INSTRUCTIONS); - - // Add final instruction to stop the interpreter - code[code_size].opcode = RET; - code[code_size].dst_index = 0; - code[code_size].src_index = 0; - code[code_size].C = 0; - - return code_size; -} - -#endif diff --git a/src/cryptonote_basic/cryptonote_format_utils.cpp b/src/cryptonote_basic/cryptonote_format_utils.cpp index 44bf08d60..46c5e4085 100644 --- a/src/cryptonote_basic/cryptonote_format_utils.cpp +++ b/src/cryptonote_basic/cryptonote_format_utils.cpp @@ -1149,8 +1149,8 @@ namespace cryptonote bool get_block_longhash(const block& b, crypto::hash& res, uint64_t height) { blobdata bd = get_block_hashing_blob(b); - const int cn_variant = b.major_version >= 11 ? 4 : b.major_version >= 9 && b.major_version <= 10 ? 2 : 1; - crypto::cn_slow_hash(bd.data(), bd.size(), res, cn_variant, height); + const int cn_variant = b.major_version >= 9 ? 2 : 1; + crypto::cn_slow_hash(bd.data(), bd.size(), res, cn_variant); return true; } //--------------------------------------------------------------- diff --git a/src/cryptonote_basic/difficulty.cpp b/src/cryptonote_basic/difficulty.cpp index 88952a87b..f92b550fa 100644 --- a/src/cryptonote_basic/difficulty.cpp +++ b/src/cryptonote_basic/difficulty.cpp @@ -279,8 +279,8 @@ namespace cryptonote { size_t length = timestamps.size(); assert(length == cumulative_difficulties.size()); - if (length < DIFFICULTY_FORK_HEIGHT + 72) { - return DIFFICULTY_RESET; + if (length <= 1) { + return 1; } static_assert(DIFFICULTY_WINDOW_V3 >= 2, "Window is too small"); assert(length <= DIFFICULTY_WINDOW_V3); diff --git a/src/cryptonote_config.h b/src/cryptonote_config.h index 1a87922bc..ddc3d442a 100644 --- a/src/cryptonote_config.h +++ b/src/cryptonote_config.h @@ -90,8 +90,7 @@ #define DIFFICULTY_BLOCKS_COUNT_V3 DIFFICULTY_WINDOW_V3 + DIFFICULTY_LAG_V2 #define DIFFICULTY_BLOCKS_COUNT_V2 DIFFICULTY_WINDOW_V2 + 1 // added +1 to make N=N #define DIFFICULTY_BLOCKS_COUNT DIFFICULTY_WINDOW + DIFFICULTY_LAG -#define DIFFICULTY_FORK_HEIGHT 80969 // ~14 February 2019 -#define DIFFICULTY_RESET 10000000 // 10 million + #define CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_SECONDS_V1 DIFFICULTY_TARGET_V1 * CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_BLOCKS #define CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_SECONDS_V2 DIFFICULTY_TARGET_V2 * CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_BLOCKS diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp index 88b8d9103..5b81129bb 100644 --- a/src/cryptonote_core/blockchain.cpp +++ b/src/cryptonote_core/blockchain.cpp @@ -91,8 +91,6 @@ static const struct { { 8, 6969, 0, 1524214739 }, { 9, 53666, 0, 1538689773 }, { 10, 63469, 0, 1541700352 }, - { 11, 80969, 0, 1549238400 }, - { 12, 81269, 0, 1549318761 }, }; static const struct { diff --git a/src/cryptonote_core/cryptonote_core.cpp b/src/cryptonote_core/cryptonote_core.cpp index e2a49aba5..ee6a25b08 100644 --- a/src/cryptonote_core/cryptonote_core.cpp +++ b/src/cryptonote_core/cryptonote_core.cpp @@ -1574,9 +1574,6 @@ namespace cryptonote MGINFO_YELLOW(ENDL << "**********************************************************************" << ENDL << main_message << ENDL << ENDL - << "Caution: Wownero is highly experimental software compiled by a ragtag team of stoners with as much" << ENDL - << "skill as Verge developers. Storing your life savings in WOW is probably not a good idea." << ENDL - << ENDL << "You can set the level of process detailization through \"set_log \" command," << ENDL << "where is between 0 (no details) and 4 (very verbose), or custom category based levels (eg, *:WARNING)." << ENDL << ENDL diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index 207f68f6e..ca39675dd 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -2044,14 +2044,6 @@ bool simple_wallet::set_always_confirm_transfers(const std::vector return true; } -bool simple_wallet::set_auto_confirm_churn(const std::vector &args/* = std::vector()*/) -{ - parse_bool_and_use(args[1], [&](bool r) { - m_wallet->auto_confirm_churn(r); - }); - return true; -} - bool simple_wallet::set_print_ring_members(const std::vector &args/* = std::vector()*/) { const auto pwd_container = get_and_verify_password(); @@ -2545,7 +2537,6 @@ bool simple_wallet::help(const std::vector &args/* = std::vector to the development team")); + tr("Donate to the development team (donate.getmonero.org).")); m_cmd_binder.set_handler("sign_transfer", boost::bind(&simple_wallet::sign_transfer, this, _1), tr(USAGE_SIGN_TRANSFER), @@ -3045,7 +3036,6 @@ bool simple_wallet::set_variable(const std::vector &args) } success_msg_writer() << "seed = " << seed_language; success_msg_writer() << "always-confirm-transfers = " << m_wallet->always_confirm_transfers(); - success_msg_writer() << "auto-confirm-churn = " << m_wallet->auto_confirm_churn(); success_msg_writer() << "print-ring-members = " << m_wallet->print_ring_members(); success_msg_writer() << "store-tx-info = " << m_wallet->store_tx_info(); success_msg_writer() << "default-ring-size = " << (m_wallet->default_mixin() ? m_wallet->default_mixin() + 1 : 0); @@ -3104,7 +3094,6 @@ bool simple_wallet::set_variable(const std::vector &args) } } CHECK_SIMPLE_VARIABLE("always-confirm-transfers", set_always_confirm_transfers, tr("0 or 1")); - CHECK_SIMPLE_VARIABLE("auto-confirm-churn", set_auto_confirm_churn, tr("0 or 1")); CHECK_SIMPLE_VARIABLE("print-ring-members", set_print_ring_members, tr("0 or 1")); CHECK_SIMPLE_VARIABLE("store-tx-info", set_store_tx_info, tr("0 or 1")); CHECK_SIMPLE_VARIABLE("default-ring-size", set_default_ring_size, tr("integer >= ") << MIN_RING_SIZE); @@ -6439,7 +6428,7 @@ bool simple_wallet::donate(const std::vector &args_) if (!payment_id_str.empty()) local_args.push_back(payment_id_str); if (m_wallet->nettype() == cryptonote::MAINNET) - message_writer() << (boost::format(tr("Donating %s %s to help get some stripers through college.")) % amount_str % cryptonote::get_unit(cryptonote::get_default_decimal_point())).str(); + message_writer() << (boost::format(tr("Donating %s %s to The Monero Project (donate.getmonero.org or %s).")) % amount_str % cryptonote::get_unit(cryptonote::get_default_decimal_point()) % MONERO_DONATION_ADDR).str(); else message_writer() << (boost::format(tr("Donating %s %s to %s.")) % amount_str % cryptonote::get_unit(cryptonote::get_default_decimal_point()) % address_str).str(); transfer(local_args); @@ -8833,6 +8822,13 @@ bool simple_wallet::churn(const std::vector &args_) return true; } + // Check balance + if (m_wallet->unlocked_balance(m_current_subaddress_account) < 2) + { + fail_msg_writer() << tr("You need to have an unlocked balance of more than 2 WOW, operation cancelled."); + return true; + } + // Warning std::string warning = input_line(tr("Warning: Churning requires your wallet to be open for a few hours. If wallet is left unattended, make sure your computer is in a secure location. Continue?"), true); if (std::cin.eof() || !command_line::is_yes(warning)) @@ -8849,11 +8845,7 @@ bool simple_wallet::churn(const std::vector &args_) float total_time = static_cast(churn_number*pause_time)/60; // calculate how long churning will take in hours // Calculate fee - float churn_fee = churn_number * 0.032654; // usual 2/2 tx fee - if (m_wallet->use_fork_rules(HF_VERSION_PER_BYTE_FEE)) - { - float churn_fee = churn_number * 0.015; - } + float churn_fee = m_wallet->use_fork_rules(HF_VERSION_PER_BYTE_FEE) ? static_cast(churn_number * 0.015) : static_cast(churn_number * 0.032654); // usual 2/2 tx fee // Prompt confirmation printf ("----------------\nNumber of churns: %d\nTotal duration: %.2f hours\nEstimated cost: %.2f WOW\n----------------\n", churn_number, total_time, churn_fee); diff --git a/src/simplewallet/simplewallet.h b/src/simplewallet/simplewallet.h index 8d7cc745f..15f8d4aa5 100644 --- a/src/simplewallet/simplewallet.h +++ b/src/simplewallet/simplewallet.h @@ -52,7 +52,7 @@ #undef MONERO_DEFAULT_LOG_CATEGORY #define MONERO_DEFAULT_LOG_CATEGORY "wallet.simplewallet" // Hardcode Monero's donation address (see #1447) -constexpr const char MONERO_DONATION_ADDR[] = "Wo3MWeKwtA918DU4c69hVSNgejdWFCRCuWjShRY66mJkU2Hv58eygJWDJS1MNa2Ge5M1WjUkGHuLqHkweDxwZZU42d16v94mP"; +constexpr const char MONERO_DONATION_ADDR[] = "44AFFq5kSiGBoZ4NMDwYtN18obc8AemS33DBLWs3H7otXft3XjrpDtQGv7SqSsaBYBb98uNbr2VBBEt7f2wfn3RVGQBEP3A"; /*! * \namespace cryptonote @@ -121,7 +121,6 @@ namespace cryptonote */ bool seed_set_language(const std::vector &args = std::vector()); bool set_always_confirm_transfers(const std::vector &args = std::vector()); - bool set_auto_confirm_churn(const std::vector &args = std::vector()); bool set_print_ring_members(const std::vector &args = std::vector()); bool set_store_tx_info(const std::vector &args = std::vector()); bool set_default_ring_size(const std::vector &args = std::vector()); diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 81838145c..57108ffef 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -890,7 +890,7 @@ wallet2::wallet2(network_type nettype, uint64_t kdf_rounds, bool unattended): m_nettype(nettype), m_multisig_rounds_passed(0), m_always_confirm_transfers(true), - m_auto_confirm_churn(true), + m_auto_confirm_churn(false), m_print_ring_members(false), m_store_tx_info(true), m_default_mixin(0), @@ -3423,7 +3423,7 @@ bool wallet2::load_keys(const std::string& keys_file_name, const epee::wipeable_ m_multisig_rounds_passed = 0; m_multisig_derivations.clear(); m_always_confirm_transfers = false; - m_auto_confirm_churn = true; + m_auto_confirm_churn = false; m_print_ring_members = false; m_default_mixin = 0; m_default_priority = 0; diff --git a/tests/hash/CMakeLists.txt b/tests/hash/CMakeLists.txt index a0c78bfdc..0624d5d02 100644 --- a/tests/hash/CMakeLists.txt +++ b/tests/hash/CMakeLists.txt @@ -43,7 +43,7 @@ set_property(TARGET hash-tests PROPERTY FOLDER "tests") -foreach (hash IN ITEMS fast slow slow-1 slow-2 slow-4 tree extra-blake extra-groestl extra-jh extra-skein) +foreach (hash IN ITEMS fast slow slow-1 slow-2 tree extra-blake extra-groestl extra-jh extra-skein) add_test( NAME "hash-${hash}" COMMAND hash-tests "${hash}" "${CMAKE_CURRENT_SOURCE_DIR}/tests-${hash}.txt") diff --git a/tests/hash/main.cpp b/tests/hash/main.cpp index adf1bd9c4..5a141d41c 100644 --- a/tests/hash/main.cpp +++ b/tests/hash/main.cpp @@ -44,13 +44,6 @@ using namespace std; using namespace crypto; typedef crypto::hash chash; -struct V4_Data -{ - const void* data; - size_t length; - uint64_t height; -}; - PUSH_WARNINGS DISABLE_VS_WARNINGS(4297) extern "C" { @@ -61,17 +54,13 @@ extern "C" { tree_hash((const char (*)[crypto::HASH_SIZE]) data, length >> 5, hash); } static void cn_slow_hash_0(const void *data, size_t length, char *hash) { - return cn_slow_hash(data, length, hash, 0/*variant*/, 0/*prehashed*/, 0/*height*/); + return cn_slow_hash(data, length, hash, 0/*variant*/, 0/*prehashed*/); } static void cn_slow_hash_1(const void *data, size_t length, char *hash) { - return cn_slow_hash(data, length, hash, 1/*variant*/, 0/*prehashed*/, 0/*height*/); + return cn_slow_hash(data, length, hash, 1/*variant*/, 0/*prehashed*/); } static void cn_slow_hash_2(const void *data, size_t length, char *hash) { - return cn_slow_hash(data, length, hash, 2/*variant*/, 0/*prehashed*/, 0/*height*/); - } - static void cn_slow_hash_4(const void *data, size_t, char *hash) { - const V4_Data* p = reinterpret_cast(data); - return cn_slow_hash(p->data, p->length, hash, 4/*variant*/, 0/*prehashed*/, p->height); + return cn_slow_hash(data, length, hash, 2/*variant*/, 0/*prehashed*/); } } POP_WARNINGS @@ -83,7 +72,7 @@ struct hash_func { } hashes[] = {{"fast", cn_fast_hash}, {"slow", cn_slow_hash_0}, {"tree", hash_tree}, {"extra-blake", hash_extra_blake}, {"extra-groestl", hash_extra_groestl}, {"extra-jh", hash_extra_jh}, {"extra-skein", hash_extra_skein}, - {"slow-1", cn_slow_hash_1}, {"slow-2", cn_slow_hash_2}, {"slow-4", cn_slow_hash_4}}; + {"slow-1", cn_slow_hash_1}, {"slow-2", cn_slow_hash_2}}; int test_variant2_int_sqrt(); int test_variant2_int_sqrt_ref(); @@ -151,15 +140,7 @@ int main(int argc, char *argv[]) { input.exceptions(ios_base::badbit | ios_base::failbit | ios_base::eofbit); input.clear(input.rdstate()); get(input, data); - if (f == cn_slow_hash_4) { - V4_Data d; - d.data = data.data(); - d.length = data.size(); - get(input, d.height); - f(&d, 0, (char *) &actual); - } else { - f(data.data(), data.size(), (char *) &actual); - } + f(data.data(), data.size(), (char *) &actual); if (expected != actual) { size_t i; cerr << "Hash mismatch on test " << test << endl << "Input: "; diff --git a/tests/hash/tests-slow-4.txt b/tests/hash/tests-slow-4.txt deleted file mode 100644 index 78e72b744..000000000 --- a/tests/hash/tests-slow-4.txt +++ /dev/null @@ -1,10 +0,0 @@ -9d47bf4c41b7e8e727e681715acb47fa1677cdba9ca7bcb05ad8cc8abd5daa66 5468697320697320612074657374205468697320697320612074657374205468697320697320612074657374 1806260 -0d4a495cb844a3ca8ba4edb8e6bcf829ef1c06d9cdea2b62ca46c2a21b8b0a79 4c6f72656d20697073756d20646f6c6f722073697420616d65742c20636f6e73656374657475722061646970697363696e67 1806261 -a1d6d848b5c5915fccd2f64cf216c6b1a02cf7c77bc80d8d4e51b419e88ff0dd 656c69742c2073656420646f20656975736d6f642074656d706f7220696e6369646964756e74207574206c61626f7265 1806262 -af3a8544a0221a148c2ac90484b19861e3afca33fe17021efb8ad6496b567915 657420646f6c6f7265206d61676e6120616c697175612e20557420656e696d206164206d696e696d2076656e69616d2c 1806263 -313399e0963ae8a99dab8af66d343e097dae0c0feb08dbc43ccdafef5515f413 71756973206e6f737472756420657865726369746174696f6e20756c6c616d636f206c61626f726973206e697369 1806264 -6021c6ef90bff9ae94a7506d623d3a7a86c1756d655f50dd558f716d64622a34 757420616c697175697020657820656120636f6d6d6f646f20636f6e7365717561742e20447569732061757465 1806265 -2b13000535f3db5f9b9b84a65c4351f386cd2cdedebb8c3ad2eab086e6a3fee5 697275726520646f6c6f7220696e20726570726568656e646572697420696e20766f6c7570746174652076656c6974 1806266 -fc0e1dad8e895749dc90eb690bc1ba059a1cd772afaaf65a106bf9e5e6b80503 657373652063696c6c756d20646f6c6f726520657520667567696174206e756c6c612070617269617475722e 1806267 -b60b0afe144deff7d903ed2d5545e77ebe66a3c51fee7016eeb8fee9eb630c0f 4578636570746575722073696e74206f6363616563617420637570696461746174206e6f6e2070726f6964656e742c 1806268 -64774b27e7d5fec862fc4c0c13ac6bf09123b6f05bb0e4b75c97f379a2b3a679 73756e7420696e2063756c706120717569206f666669636961206465736572756e74206d6f6c6c697420616e696d20696420657374206c61626f72756d2e 1806269