diff --git a/.cargo/config.offline b/.cargo/config.toml.offline similarity index 100% rename from .cargo/config.offline rename to .cargo/config.toml.offline diff --git a/.gitignore b/.gitignore index e9daf3dfd78..06a58e03af3 100644 --- a/.gitignore +++ b/.gitignore @@ -83,6 +83,7 @@ Makefile # Rust .cargo/.configured-for-* .cargo/config +.cargo/config.toml src/rust/gen/ target/ diff --git a/Cargo.toml b/Cargo.toml index 029d141f42a..36df468b413 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,7 @@ repository = "https://github.com/zcash/zcash" readme = "README.md" license = "MIT OR Apache-2.0" edition = "2018" -rust-version = "1.69" +rust-version = "1.78" [package.metadata.vet] store = { path = "./qa/supply-chain" } diff --git a/configure.ac b/configure.ac index 43eabea896a..901fa9c8a3d 100644 --- a/configure.ac +++ b/configure.ac @@ -354,6 +354,7 @@ DESIRED_WARNING_CXXFLAGS="\ # same as fields # • `-Wno-string-conversion`: currently abused to `assert` on strings # • `-Wno-tautological-type-limit-compare`: I think isn’t portable because of numeric type sizing +# • `-Wno-unsafe-buffer-usage`: Added in Clang 16, needs consideration DISABLED_WARNING_CXXFLAGS="\ -Wno-c++20-compat -Wno-cast-align -Wno-cast-qual -Wno-comma -Wno-conditional-uninitialized \ -Wno-covered-switch-default -Wno-ctad-maybe-unsupported \ @@ -370,11 +371,13 @@ DISABLED_WARNING_CXXFLAGS="\ -Wno-redundant-parens -Wno-reorder-ctor -Wno-reserved-id-macro -Wno-reserved-identifier \ -Wno-return-type -Wno-shadow -Wno-shadow-field -Wno-shadow-field-in-constructor \ -Wno-shift-sign-overflow -Wno-shorten-64-to-32 -Wno-sign-compare -Wno-sign-conversion \ - -Wno-string-conversion -Wno-suggest-destructor-override -Wno-suggest-override -Wno-switch-enum \ + -Wno-string-conversion -Wno-suggest-destructor-override -Wno-suggest-override \ + -Wno-switch-default -Wno-switch-enum \ -Wno-tautological-type-limit-compare -Wno-tautological-unsigned-enum-zero-compare \ -Wno-tautological-unsigned-zero-compare -Wno-thread-safety-attributes \ -Wno-thread-safety-negative -Wno-undef -Wno-undefined-func-template -Wno-uninitialized \ -Wno-unreachable-code -Wno-unreachable-code-break -Wno-unreachable-code-return \ + -Wno-unsafe-buffer-usage \ -Wno-unused-but-set-variable -Wno-unused-exception-parameter -Wno-unused-function \ -Wno-unused-macros -Wno-unused-member-function -Wno-unused-parameter -Wno-unused-private-field \ -Wno-unused-template -Wno-unused-variable -Wno-used-but-marked-unused -Wno-weak-vtables \ @@ -401,7 +404,7 @@ REENABLED_WARNING_CXXFLAGS="\ -Wmicrosoft-comment-paste -Wmicrosoft-cpp-macro -Wmicrosoft-end-of-file -Wmicrosoft-enum-value \ -Wmicrosoft-fixed-enum -Wmicrosoft-flexible-array -Wmicrosoft-redeclare-static \ -Wnested-anon-types -Wnullability-extension -Wobjc-signed-char-bool-implicit-int-conversion \ - -Woverlength-strings -Wpre-c++2b-compat -Wretained-language-linkage \ + -Woverlength-strings -Wpre-c++20-compat -Wretained-language-linkage \ -Wshadow-field-in-constructor-modified -Wshadow-ivar -Wsometimes-uninitialized \ -Wstatic-self-init -Wundefined-internal-type -Wunneeded-member-function \ -Wunreachable-code-fallthrough -Wunreachable-code-generic-assoc -Wunreachable-code-loop-increment" diff --git a/contrib/devtools/update-clang-hashes.sh b/contrib/devtools/update-clang-hashes.sh index cf682392f46..c46dbee0ac7 100755 --- a/contrib/devtools/update-clang-hashes.sh +++ b/contrib/devtools/update-clang-hashes.sh @@ -7,7 +7,7 @@ SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) CLANG_PACKAGE="$SCRIPT_DIR/../../depends/packages/native_clang.mk" LIBCXX_PACKAGE="$SCRIPT_DIR/../../depends/packages/libcxx.mk" -CLANG_VERSION=$( grep -v _major_version $CLANG_PACKAGE | grep -oP "_version=\K.*" ) +CLANG_VERSION=$( grep -v _major_version $CLANG_PACKAGE | grep -oP "_default_version=\K.*" ) LIBCXX_MSYS2_VERSION=$( grep -oP "_msys2_version=\K.*" $LIBCXX_PACKAGE ) update_clang_hash() { diff --git a/depends/packages/libcxx.mk b/depends/packages/libcxx.mk index 7c5d6b4b2c6..37eb2af1613 100644 --- a/depends/packages/libcxx.mk +++ b/depends/packages/libcxx.mk @@ -1,6 +1,6 @@ package=libcxx $(package)_version=$(if $(native_clang_version_$(host_arch)_$(host_os)),$(native_clang_version_$(host_arch)_$(host_os)),$(if $(native_clang_version_$(host_os)),$(native_clang_version_$(host_os)),$(native_clang_default_version))) -$(package)_msys2_version=15.0.7-3 +$(package)_msys2_version=18.1.4-1 ifneq ($(canonical_host),$(build)) ifneq ($(host_os),mingw32) @@ -9,10 +9,10 @@ ifneq ($(host_os),mingw32) $(package)_download_path=$(native_clang_download_path) $(package)_download_file_aarch64_linux=clang+llvm-$($(package)_version)-aarch64-linux-gnu.tar.xz $(package)_file_name_aarch64_linux=clang-llvm-$($(package)_version)-aarch64-linux-gnu.tar.xz -$(package)_sha256_hash_aarch64_linux=8ca4d68cf103da8331ca3f35fe23d940c1b78fb7f0d4763c1c059e352f5d1bec -$(package)_download_file_linux=clang+llvm-$($(package)_version)-x86_64-linux-gnu-ubuntu-18.04.tar.xz -$(package)_file_name_linux=clang-llvm-$($(package)_version)-x86_64-linux-gnu-ubuntu-18.04.tar.xz -$(package)_sha256_hash_linux=38bc7f5563642e73e69ac5626724e206d6d539fbef653541b34cae0ba9c3f036 +$(package)_sha256_hash_aarch64_linux=8c2f4d1606d24dc197a590acce39453abe7a302b9b92e762108f9b5a9701b1df +$(package)_download_file_linux=clang+llvm-$($(package)_version)-x86_64-linux-gnu-ubuntu-22.04.tar.xz +$(package)_file_name_linux=clang-llvm-$($(package)_version)-x86_64-linux-gnu-ubuntu-22.04.tar.xz +$(package)_sha256_hash_linux=1607375b4aa2aec490b6db51846a04b265675a87e925bcf5825966401ff9b0b1 # Starting from LLVM 14.0.0, some Clang binary tarballs store libc++ in a # target-specific subdirectory. @@ -30,7 +30,7 @@ else $(package)_download_path=https://repo.msys2.org/mingw/x86_64 $(package)_download_file=mingw-w64-x86_64-libc++-$($(package)_msys2_version)-any.pkg.tar.zst $(package)_file_name=mingw-w64-x86_64-libcxx-$($(package)_msys2_version)-any.pkg.tar.zst -$(package)_sha256_hash=8c14da21fa9622cc7450b22467452c6c933a03cee526cf8744faea3d4674035b +$(package)_sha256_hash=45f8dcac0ed5ff68d202c9321375dbefb0a7e7aa1d1e1ed7299842759f9bc88b define $(package)_stage_cmds mkdir -p $($(package)_staging_prefix_dir)/lib && \ diff --git a/depends/packages/libevent.mk b/depends/packages/libevent.mk index e2d1d9d34cd..47025e92805 100644 --- a/depends/packages/libevent.mk +++ b/depends/packages/libevent.mk @@ -15,7 +15,7 @@ endef # version as we do in configure. Due to quirks in libevents build system, this # is also required to enable support for ipv6. See #19375. define $(package)_set_vars - $(package)_config_opts=--disable-shared --disable-openssl --disable-libevent-regress + $(package)_config_opts=--disable-shared --disable-openssl --disable-libevent-regress --disable-samples $(package)_config_opts += --disable-dependency-tracking --enable-option-checking $(package)_config_opts_release=--disable-debug-mode $(package)_config_opts_linux=--with-pic diff --git a/depends/packages/libsodium.mk b/depends/packages/libsodium.mk index 563473877c7..2cd150a9d16 100644 --- a/depends/packages/libsodium.mk +++ b/depends/packages/libsodium.mk @@ -4,12 +4,13 @@ $(package)_download_path=https://download.libsodium.org/libsodium/releases/ $(package)_file_name=$(package)-$($(package)_version).tar.gz $(package)_sha256_hash=018d79fe0a045cca07331d37bd0cb57b2e838c51bc48fd837a1472e50068bbea $(package)_dependencies= -$(package)_patches=1.0.15-pubkey-validation.diff 1.0.15-signature-validation.diff +$(package)_patches=1.0.15-pubkey-validation.diff 1.0.15-signature-validation.diff 1321-aarch64-fix-compiler-attributes.patch $(package)_config_opts= define $(package)_preprocess_cmds patch -p1 < $($(package)_patch_dir)/1.0.15-pubkey-validation.diff && \ patch -p1 < $($(package)_patch_dir)/1.0.15-signature-validation.diff && \ + patch -p1 < $($(package)_patch_dir)/1321-aarch64-fix-compiler-attributes.patch && \ cd $($(package)_build_subdir); DO_NOT_UPDATE_CONFIG_SCRIPTS=1 ./autogen.sh endef diff --git a/depends/packages/native_clang.mk b/depends/packages/native_clang.mk index 4cd197ebe1e..7e75822ef4c 100644 --- a/depends/packages/native_clang.mk +++ b/depends/packages/native_clang.mk @@ -5,11 +5,15 @@ package=native_clang # - Manually fix the versions for packages that don't exist (the LLVM project # doesn't uniformly cut binaries across releases). # The Clang compiler should use the same LLVM version as the Rust compiler. -$(package)_default_major_version=15 -$(package)_default_version=15.0.6 +$(package)_default_major_version=18 +$(package)_default_version=18.1.4 +# 2024-05-03: No Intel macOS packages are available for Clang 16, 17, or 18. +$(package)_major_version_darwin=15 $(package)_version_darwin=15.0.4 # 2023-02-16: No FreeBSD packages are available for Clang 15. # 2023-04-07: Still the case. +# 2024-05-03: No FreeBSD packages are available for Clang 17 or 18. +# Clang 16 has FreeBSD 13 packages, but none for FreeBSD 12. $(package)_major_version_freebsd=14 $(package)_version_freebsd=14.0.6 @@ -23,7 +27,7 @@ $(package)_major_version=$(if $($(package)_major_version_$(host_arch)_$(host_os) $(package)_download_path_linux=https://github.com/llvm/llvm-project/releases/download/llvmorg-$($(package)_version) $(package)_download_file_linux=clang+llvm-$($(package)_version)-x86_64-linux-gnu-ubuntu-18.04.tar.xz $(package)_file_name_linux=clang-llvm-$($(package)_version)-x86_64-linux-gnu-ubuntu-18.04.tar.xz -$(package)_sha256_hash_linux=38bc7f5563642e73e69ac5626724e206d6d539fbef653541b34cae0ba9c3f036 +$(package)_sha256_hash_linux=1607375b4aa2aec490b6db51846a04b265675a87e925bcf5825966401ff9b0b1 $(package)_download_path_darwin=https://github.com/llvm/llvm-project/releases/download/llvmorg-$($(package)_version) $(package)_download_file_darwin=clang+llvm-$($(package)_version)-x86_64-apple-darwin.tar.xz $(package)_file_name_darwin=clang-llvm-$($(package)_version)-x86_64-apple-darwin.tar.xz @@ -35,10 +39,10 @@ $(package)_sha256_hash_freebsd=b0a7b86dacb12afb8dd2ca99ea1b894d9cce84aab7711cb19 $(package)_download_path_aarch64_linux=https://github.com/llvm/llvm-project/releases/download/llvmorg-$($(package)_version) $(package)_download_file_aarch64_linux=clang+llvm-$($(package)_version)-aarch64-linux-gnu.tar.xz $(package)_file_name_aarch64_linux=clang-llvm-$($(package)_version)-aarch64-linux-gnu.tar.xz -$(package)_sha256_hash_aarch64_linux=8ca4d68cf103da8331ca3f35fe23d940c1b78fb7f0d4763c1c059e352f5d1bec +$(package)_sha256_hash_aarch64_linux=8c2f4d1606d24dc197a590acce39453abe7a302b9b92e762108f9b5a9701b1df -ifneq (,$(wildcard /etc/arch-release)) -$(package)_dependencies=native_libtinfo +ifeq ($(build_os),linux) +$(package)_dependencies=native_libtinfo5 endif # Ensure we have clang native to the builder, not the target host diff --git a/depends/packages/native_libtinfo.mk b/depends/packages/native_libtinfo5.mk similarity index 54% rename from depends/packages/native_libtinfo.mk rename to depends/packages/native_libtinfo5.mk index d3c200660dd..33366e35e7a 100644 --- a/depends/packages/native_libtinfo.mk +++ b/depends/packages/native_libtinfo5.mk @@ -1,17 +1,19 @@ -package=native_tinfo -$(package)_version=5.6.0 -$(package)_download_path_linux=http://ftp.debian.org/debian/pool/main/n/ncurses/ -$(package)_download_file_linux=libtinfo5_6.0+20161126-1+deb9u2_amd64.deb -$(package)_file_name_linux=libtinfo5_6.0+20161126-1+deb9u2_amd64.deb -$(package)_sha256_hash_linux=1d249a3193568b5ef785ad8993b9ba6d6fdca0eb359204c2355532b82d25e9f5 +package=native_libtinfo5 +$(package)_version=6.2 + +# We only enable this if build_os is linux. +$(package)_download_path=http://ftp.debian.org/debian/pool/main/n/ncurses/ +$(package)_download_file=libtinfo5_$($(package)_version)+20201114-2+deb11u2_amd64.deb +$(package)_file_name=libtinfo5-$($(package)_version).deb +$(package)_sha256_hash=69e131ce3f790a892ca1b0ae3bfad8659daa2051495397eee1b627d9783a6797 define $(package)_extract_cmds mkdir -p $($(package)_extract_dir) && \ echo "$($(package)_sha256_hash) $($(package)_source)" > $($(package)_extract_dir)/.$($(package)_file_name).hash && \ $(build_SHA256SUM) -c $($(package)_extract_dir)/.$($(package)_file_name).hash && \ mkdir -p libtinfo5 && \ - ar x --output libtinfo5 $($(package)_source_dir)/$($(package)_file_name) && \ cd libtinfo5 && \ + ar x $($(package)_source_dir)/$($(package)_file_name) && \ tar xf data.tar.xz endef diff --git a/depends/packages/native_rust.mk b/depends/packages/native_rust.mk index 99bc5da0f79..f65255663af 100644 --- a/depends/packages/native_rust.mk +++ b/depends/packages/native_rust.mk @@ -3,16 +3,16 @@ package=native_rust # ./contrib/devtools/update-rust-hashes.sh # The Rust compiler should use the same LLVM version as the Clang compiler; you # can check this with `rustc --version -v`. -$(package)_version=1.69.0 +$(package)_version=1.78.0 $(package)_download_path=https://static.rust-lang.org/dist $(package)_file_name_linux=rust-$($(package)_version)-x86_64-unknown-linux-gnu.tar.gz -$(package)_sha256_hash_linux=2ca4a306047c0b8b4029c382910fcbc895badc29680e0332c9df990fd1c70d4f +$(package)_sha256_hash_linux=1307747915e8bd925f4d5396ab2ae3d8d9c7fad564afbc358c081683d0f22e87 $(package)_file_name_darwin=rust-$($(package)_version)-x86_64-apple-darwin.tar.gz -$(package)_sha256_hash_darwin=9818dab2c3726d63dfbfde12c9273e62e484ef6d6f6e05a6431a3e089c335454 +$(package)_sha256_hash_darwin=6c91ed3bd90253961fcb4a2991b8b22e042e2aaa9aba9f389f1e17008171d898 $(package)_file_name_freebsd=rust-$($(package)_version)-x86_64-unknown-freebsd.tar.gz -$(package)_sha256_hash_freebsd=2985d98910b4a1dd336bfc7a1ac3b18082ed917cff097b4db6f0d6602016c289 +$(package)_sha256_hash_freebsd=b9cc84c60deb8da08a6c876426f8721758f4c7e7c553b4554385752ad37c63df $(package)_file_name_aarch64_linux=rust-$($(package)_version)-aarch64-unknown-linux-gnu.tar.gz -$(package)_sha256_hash_aarch64_linux=88af5aa7a40c8f1b40416a1f27de8ffbe09c155d933f69d3e109c0ccee92353b +$(package)_sha256_hash_aarch64_linux=131eda738cd977fff2c912e5838e8e9b9c260ecddc1247c0fe5473bf09c594af # Mapping from GCC canonical hosts to Rust targets # If a mapping is not present, we assume they are identical, unless $host_os is @@ -21,10 +21,10 @@ $(package)_rust_target_x86_64-pc-linux-gnu=x86_64-unknown-linux-gnu $(package)_rust_target_x86_64-w64-mingw32=x86_64-pc-windows-gnu # Mapping from Rust targets to SHA-256 hashes -$(package)_rust_std_sha256_hash_aarch64-unknown-linux-gnu=8f42b40c0a0658ee75ce758652c9821fac7db3fbd8d20f7fb2483ec2c57ee0ac -$(package)_rust_std_sha256_hash_x86_64-apple-darwin=e44d71250dc5a238da0dc4784dad59d562862653adecd31ea52e0920b85c6a7c -$(package)_rust_std_sha256_hash_x86_64-pc-windows-gnu=09ded4a4c27c16aff9c9911640b1bdf6e1172237ce540ed4dc3e166e9438f0d7 -$(package)_rust_std_sha256_hash_x86_64-unknown-freebsd=eed4b3f3358a8887b0f6a62e021469878a8990af9b94c2fe87d3c1b0220913bb +$(package)_rust_std_sha256_hash_aarch64-unknown-linux-gnu=9ef30225a7c466758a1b3ba011cbd702f5038c875816cb1733d633002642e2f3 +$(package)_rust_std_sha256_hash_x86_64-apple-darwin=f91024e3b9a4fdb9bba5dfe8b028604bcd1ad621f0b8e8140a31bd677a0232c2 +$(package)_rust_std_sha256_hash_x86_64-pc-windows-gnu=5dfe7246685dad55fbdd93deffcdfcf11dea095383228a327769a209bfc145f4 +$(package)_rust_std_sha256_hash_x86_64-unknown-freebsd=82fd506f720c0e469fb72f5b532b42c109562a030c3ef2f4fd73dfb08c050929 define rust_target $(if $($(1)_rust_target_$(2)),$($(1)_rust_target_$(2)),$(if $(findstring darwin,$(3)),x86_64-apple-darwin,$(if $(findstring freebsd,$(3)),x86_64-unknown-freebsd,$(2)))) diff --git a/depends/packages/packages.mk b/depends/packages/packages.mk index 5e609db7669..e37c93fedab 100644 --- a/depends/packages/packages.mk +++ b/depends/packages/packages.mk @@ -2,8 +2,8 @@ zcash_packages := libsodium rustcxx utfcpp tl_expected packages := boost libevent zeromq $(zcash_packages) googletest native_packages := native_clang native_ccache native_cmake native_rust native_cxxbridge native_zstd -ifneq (,$(wildcard /etc/arch-release)) -native_packages += native_libtinfo +ifeq ($(build_os),linux) +native_packages += native_libtinfo5 endif wallet_packages=bdb diff --git a/depends/patches/libsodium/1321-aarch64-fix-compiler-attributes.patch b/depends/patches/libsodium/1321-aarch64-fix-compiler-attributes.patch new file mode 100644 index 00000000000..5a4b966dd09 --- /dev/null +++ b/depends/patches/libsodium/1321-aarch64-fix-compiler-attributes.patch @@ -0,0 +1,133 @@ +From 8f453f41f8834e0fe47610f2a3e03e696ddb3450 Mon Sep 17 00:00:00 2001 +From: Frank Denis +Date: Fri, 20 Oct 2023 13:47:57 +0200 +Subject: [PATCH] aarch64: set compiler attributes *after* including + + +Fixes #1321 +--- + configure.ac | 11 ++++++----- + .../crypto_aead/aegis128l/aegis128l_armcrypto.c | 12 ++++++------ + .../crypto_aead/aegis256/aegis256_armcrypto.c | 12 ++++++------ + .../aes256gcm/armcrypto/aead_aes256gcm_armcrypto.c | 12 ++++++------ + 4 files changed, 24 insertions(+), 23 deletions(-) + +diff --git a/configure.ac b/configure.ac +index 287e109cd7..e792f67139 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -397,11 +397,6 @@ AS_IF([test "x$EMSCRIPTEN" = "x"], [ + have_armcrypto=no + AC_MSG_CHECKING(for ARM crypto instructions set) + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ +- #ifdef __clang__ +- # pragma clang attribute push(__attribute__((target("neon,crypto,aes"))), apply_to = function) +- #elif defined(__GNUC__) +- # pragma GCC target("+simd+crypto") +- #endif + #ifndef __ARM_FEATURE_CRYPTO + # define __ARM_FEATURE_CRYPTO 1 + #endif +@@ -410,6 +405,12 @@ AS_IF([test "x$EMSCRIPTEN" = "x"], [ + #endif + + #include ++ ++ #ifdef __clang__ ++ # pragma clang attribute push(__attribute__((target("neon,crypto,aes"))), apply_to = function) ++ #elif defined(__GNUC__) ++ # pragma GCC target("+simd+crypto") ++ #endif + ]], [[ + int64x2_t x = { 0, 0 }; + vaeseq_u8(vmovq_n_u8(0), vmovq_n_u8(0)); +diff --git a/src/libsodium/crypto_aead/aegis128l/aegis128l_armcrypto.c b/src/libsodium/crypto_aead/aegis128l/aegis128l_armcrypto.c +index 825de8a1c8..a01f60cbe6 100644 +--- a/src/libsodium/crypto_aead/aegis128l/aegis128l_armcrypto.c ++++ b/src/libsodium/crypto_aead/aegis128l/aegis128l_armcrypto.c +@@ -17,12 +17,6 @@ + + #include "aegis128l_armcrypto.h" + +-#ifdef __clang__ +-#pragma clang attribute push(__attribute__((target("neon,crypto,aes"))), apply_to = function) +-#elif defined(__GNUC__) +-#pragma GCC target("+simd+crypto") +-#endif +- + #ifndef __ARM_FEATURE_CRYPTO + #define __ARM_FEATURE_CRYPTO 1 + #endif +@@ -32,6 +26,12 @@ + + #include + ++#ifdef __clang__ ++#pragma clang attribute push(__attribute__((target("neon,crypto,aes"))), apply_to = function) ++#elif defined(__GNUC__) ++#pragma GCC target("+simd+crypto") ++#endif ++ + #define AES_BLOCK_LENGTH 16 + + typedef uint8x16_t aes_block_t; +diff --git a/src/libsodium/crypto_aead/aegis256/aegis256_armcrypto.c b/src/libsodium/crypto_aead/aegis256/aegis256_armcrypto.c +index e1ebd577a2..058e2072b9 100644 +--- a/src/libsodium/crypto_aead/aegis256/aegis256_armcrypto.c ++++ b/src/libsodium/crypto_aead/aegis256/aegis256_armcrypto.c +@@ -17,12 +17,6 @@ + + #include "aegis256_armcrypto.h" + +-#ifdef __clang__ +-#pragma clang attribute push(__attribute__((target("neon,crypto,aes"))), apply_to = function) +-#elif defined(__GNUC__) +-#pragma GCC target("+simd+crypto") +-#endif +- + #ifndef __ARM_FEATURE_CRYPTO + #define __ARM_FEATURE_CRYPTO 1 + #endif +@@ -32,6 +26,12 @@ + + #include + ++#ifdef __clang__ ++#pragma clang attribute push(__attribute__((target("neon,crypto,aes"))), apply_to = function) ++#elif defined(__GNUC__) ++#pragma GCC target("+simd+crypto") ++#endif ++ + #define AES_BLOCK_LENGTH 16 + + typedef uint8x16_t aes_block_t; +diff --git a/src/libsodium/crypto_aead/aes256gcm/armcrypto/aead_aes256gcm_armcrypto.c b/src/libsodium/crypto_aead/aes256gcm/armcrypto/aead_aes256gcm_armcrypto.c +index ed2af303c3..8f9bba6d74 100644 +--- a/src/libsodium/crypto_aead/aes256gcm/armcrypto/aead_aes256gcm_armcrypto.c ++++ b/src/libsodium/crypto_aead/aes256gcm/armcrypto/aead_aes256gcm_armcrypto.c +@@ -19,12 +19,6 @@ + #define __vectorcall + #endif + +-#ifdef __clang__ +-#pragma clang attribute push(__attribute__((target("neon,crypto,aes"))), apply_to = function) +-#elif defined(__GNUC__) +-#pragma GCC target("+simd+crypto") +-#endif +- + #ifndef __ARM_FEATURE_CRYPTO + #define __ARM_FEATURE_CRYPTO 1 + #endif +@@ -34,6 +28,12 @@ + + #include + ++#ifdef __clang__ ++#pragma clang attribute push(__attribute__((target("neon,crypto,aes"))), apply_to = function) ++#elif defined(__GNUC__) ++#pragma GCC target("+simd+crypto") ++#endif ++ + #define ABYTES crypto_aead_aes256gcm_ABYTES + #define NPUBBYTES crypto_aead_aes256gcm_NPUBBYTES + #define KEYBYTES crypto_aead_aes256gcm_KEYBYTES diff --git a/qa/zcash/postponed-updates.txt b/qa/zcash/postponed-updates.txt index b6401bf1a24..822185f633a 100644 --- a/qa/zcash/postponed-updates.txt +++ b/qa/zcash/postponed-updates.txt @@ -10,61 +10,9 @@ boost 1.85.0 2024-06-15 native_b2 1.84.0 2024-06-15 native_b2 1.85.0 2024-06-15 -# Clang and Rust are currently pinned to LLVM 15 -libcxx 15.0.7 2024-06-15 -libcxx 16.0.0 2024-06-15 -libcxx 16.0.1 2024-06-15 -libcxx 16.0.2 2024-06-15 -libcxx 16.0.2 2024-06-15 -libcxx 16.0.3 2024-06-15 -libcxx 16.0.4 2024-06-15 -libcxx 16.0.5 2024-06-15 -libcxx 16.0.6 2024-06-15 -libcxx 17.0.0 2024-06-15 -libcxx 17.0.1 2024-06-15 -libcxx 17.0.2 2024-06-15 -libcxx 17.0.3 2024-06-15 -libcxx 17.0.4 2024-06-15 -libcxx 17.0.5 2024-06-15 -libcxx 17.0.6 2024-06-15 -libcxx 18.1.0 2024-06-15 -libcxx 18.1.1 2024-06-15 -libcxx 18.1.2 2024-06-15 -libcxx 18.1.3 2024-06-15 -libcxx 18.1.4 2024-06-15 -native_clang 15.0.7 2024-06-15 -native_clang 16.0.0 2024-06-15 -native_clang 16.0.1 2024-06-15 -native_clang 16.0.2 2024-06-15 -native_clang 16.0.3 2024-06-15 -native_clang 16.0.4 2024-06-15 -native_clang 16.0.5 2024-06-15 -native_clang 16.0.6 2024-06-15 -native_clang 17.0.0 2024-06-15 -native_clang 17.0.1 2024-06-15 -native_clang 17.0.2 2024-06-15 -native_clang 17.0.3 2024-06-15 -native_clang 17.0.4 2024-06-15 -native_clang 17.0.5 2024-06-15 -native_clang 17.0.6 2024-06-15 -native_clang 18.1.0 2024-06-15 -native_clang 18.1.1 2024-06-15 -native_clang 18.1.2 2024-06-15 -native_clang 18.1.3 2024-06-15 -native_clang 18.1.4 2024-06-15 -native_rust 1.70.0 2024-06-15 -native_rust 1.71.0 2024-06-15 -native_rust 1.71.1 2024-06-15 -native_rust 1.72.0 2024-06-15 -native_rust 1.72.1 2024-06-15 -native_rust 1.73.0 2024-06-15 -native_rust 1.74.0 2024-06-15 -native_rust 1.74.1 2024-06-15 -native_rust 1.75.0 2024-06-15 -native_rust 1.76.0 2024-06-15 -native_rust 1.77.0 2024-06-15 -native_rust 1.77.1 2024-06-15 -native_rust 1.77.2 2024-06-15 +# Clang and Rust are currently pinned to LLVM 18 +libcxx 18.1.5 2024-06-15 +native_clang 18.1.5 2024-06-15 native_cxxbridge 1.0.114 2024-06-15 native_cxxbridge 1.0.115 2024-06-15 diff --git a/rust-toolchain.toml b/rust-toolchain.toml index d04f2eb53b3..623f9a27157 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "1.69.0" +channel = "1.78.0" components = ["clippy", "rustfmt"] diff --git a/src/Makefile.am b/src/Makefile.am index b4c3f3f8ddc..09d3d07e23e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -127,10 +127,11 @@ cargo_verbose_ = $(cargo_verbose_@AM_DEFAULT_V@) cargo_verbose_1 = --verbose if ENABLE_ONLINE_RUST -# Ensure that .cargo/config does not exist +# Ensure that .cargo/config.toml (or the older .cargo/config) does not exist. CARGO_CONFIGURED = $(top_srcdir)/.cargo/.configured-for-online $(CARGO_CONFIGURED): - $(AM_V_at)rm -f $(top_srcdir)/.cargo/.configured-for-offline $(top_srcdir)/.cargo/config + $(AM_V_at)rm -f $(top_srcdir)/.cargo/.configured-for-offline $(top_srcdir)/.cargo/config.toml + $(AM_V_at)rm -f $(top_srcdir)/.cargo/config $(AM_V_at)touch $@ else @@ -138,10 +139,11 @@ else RUST_BUILD_OPTS += --locked --offline CARGO_CONFIGURED = $(top_srcdir)/.cargo/.configured-for-offline -$(CARGO_CONFIGURED): $(top_srcdir)/.cargo/config.offline +$(CARGO_CONFIGURED): $(top_srcdir)/.cargo/config.toml.offline $(AM_V_at)rm -f $(top_srcdir)/.cargo/.configured-for-online - $(AM_V_at)cp $< $(top_srcdir)/.cargo/config - $(AM_V_at)echo "directory = \"$(RUST_VENDORED_SOURCES)\"" >>$(top_srcdir)/.cargo/config + $(AM_V_at)rm -f $(top_srcdir)/.cargo/config + $(AM_V_at)cp $< $(top_srcdir)/.cargo/config.toml + $(AM_V_at)echo "directory = \"$(RUST_VENDORED_SOURCES)\"" >>$(top_srcdir)/.cargo/config.toml $(AM_V_at)touch $@ endif if ENABLE_SHANI @@ -773,7 +775,7 @@ DISTCLEANFILES = obj/build.h EXTRA_DIST = $(CTAES_DIST) rust clean-local: - rm -f $(top_srcdir)/.cargo/config $(top_srcdir)/.cargo/.configured-for-* + rm -f $(top_srcdir)/.cargo/config.toml $(top_srcdir)/.cargo/config $(top_srcdir)/.cargo/.configured-for-* -$(MAKE) -C secp256k1 clean -$(MAKE) -C univalue clean rm -f leveldb/*/*.gcno leveldb/helpers/memenv/*.gcno diff --git a/src/hash.h b/src/hash.h index 106a97620c1..7f081caab4c 100644 --- a/src/hash.h +++ b/src/hash.h @@ -30,9 +30,9 @@ class CHash256 { static const size_t OUTPUT_SIZE = CSHA256::OUTPUT_SIZE; void Finalize(unsigned char hash[OUTPUT_SIZE]) { - unsigned char buf[sha.OUTPUT_SIZE]; + unsigned char buf[CSHA256::OUTPUT_SIZE]; sha.Finalize(buf); - sha.Reset().Write(buf, sha.OUTPUT_SIZE).Finalize(hash); + sha.Reset().Write(buf, CSHA256::OUTPUT_SIZE).Finalize(hash); } CHash256& Write(const unsigned char *data, size_t len) { @@ -54,9 +54,9 @@ class CHash160 { static const size_t OUTPUT_SIZE = CRIPEMD160::OUTPUT_SIZE; void Finalize(unsigned char hash[OUTPUT_SIZE]) { - unsigned char buf[sha.OUTPUT_SIZE]; + unsigned char buf[CSHA256::OUTPUT_SIZE]; sha.Finalize(buf); - CRIPEMD160().Write(buf, sha.OUTPUT_SIZE).Finalize(hash); + CRIPEMD160().Write(buf, CSHA256::OUTPUT_SIZE).Finalize(hash); } CHash160& Write(const unsigned char *data, size_t len) { diff --git a/src/rust/bin/inspect/address.rs b/src/rust/bin/inspect/address.rs index b6f84ec3067..b89acedd678 100644 --- a/src/rust/bin/inspect/address.rs +++ b/src/rust/bin/inspect/address.rs @@ -3,6 +3,7 @@ use zcash_address::{ ConversionError, Network, ToAddress, ZcashAddress, }; +#[allow(dead_code)] enum AddressKind { Sprout([u8; 64]), Sapling([u8; 43]), diff --git a/src/rust/bin/inspect/block.rs b/src/rust/bin/inspect/block.rs index 15e8ef22d35..f6a79b73c77 100644 --- a/src/rust/bin/inspect/block.rs +++ b/src/rust/bin/inspect/block.rs @@ -159,7 +159,7 @@ impl Block { } fn extract_height(&self) -> Option { - self.txs.get(0).and_then(extract_height_from_coinbase) + self.txs.first().and_then(extract_height_from_coinbase) } /// Builds the Merkle tree for this block and returns its root. diff --git a/src/rust/bin/inspect/transaction.rs b/src/rust/bin/inspect/transaction.rs index 4e9308c00b8..a70b442b32e 100644 --- a/src/rust/bin/inspect/transaction.rs +++ b/src/rust/bin/inspect/transaction.rs @@ -44,7 +44,7 @@ pub fn extract_height_from_coinbase(tx: &Transaction) -> Option { const OP_16: u8 = 0x60; tx.transparent_bundle() - .and_then(|bundle| bundle.vin.get(0)) + .and_then(|bundle| bundle.vin.first()) .and_then(|input| match input.script_sig.0.first().copied() { // {0, -1} will never occur as the first byte of a coinbase scriptSig. Some(OP_0 | OP_1NEGATE) => None, diff --git a/src/rust/src/metrics_ffi.rs b/src/rust/src/metrics_ffi.rs index 35306ef9d69..64fc7e85654 100644 --- a/src/rust/src/metrics_ffi.rs +++ b/src/rust/src/metrics_ffi.rs @@ -137,7 +137,7 @@ pub extern "C" fn metrics_callsite( let labels: Vec<_> = labels .into_iter() - .zip(values.into_iter()) + .zip(values) .map(|(name, value)| Label::new(name, value)) .collect(); @@ -178,7 +178,7 @@ pub extern "C" fn metrics_key( let labels: Vec<_> = labels .into_iter() - .zip(values.into_iter()) + .zip(values) .map(|(name, value)| Label::new(name, value)) .collect(); diff --git a/src/rust/src/sprout.rs b/src/rust/src/sprout.rs index aaaa406862a..d04bdb67a7e 100644 --- a/src/rust/src/sprout.rs +++ b/src/rust/src/sprout.rs @@ -1,5 +1,6 @@ use std::fs::File; use std::io::BufReader; +use std::ptr::addr_of; use bellman::groth16::Parameters; use zcash_proofs::sprout; @@ -90,9 +91,12 @@ fn prove( use std::io::Read; // Load parameters from disk - let sprout_path = unsafe { &SPROUT_GROTH16_PARAMS_PATH }.as_ref().expect( - "Parameters not loaded: SPROUT_GROTH16_PARAMS_PATH should have been initialized", - ); + let sprout_path = unsafe { addr_of!(SPROUT_GROTH16_PARAMS_PATH).as_ref() } + .expect("Only mutated during init, so this pointer can never be null") + .as_ref() + .expect( + "Parameters not loaded: SPROUT_GROTH16_PARAMS_PATH should have been initialized", + ); const HOW_TO_FIX: &str = " Please download this file from https://download.z.cash/downloads/sprout-groth16.params and put it at "; diff --git a/src/rust/src/tests/signatures.rs b/src/rust/src/tests/signatures.rs index 31d01ab90c5..1ff7a402b9c 100644 --- a/src/rust/src/tests/signatures.rs +++ b/src/rust/src/tests/signatures.rs @@ -491,7 +491,7 @@ fn redjubjub_signatures() { assert_eq!(vk.verify(&tv.m, &sig), Ok(())); assert_eq!(rvk.verify(&tv.m, &rsig), Ok(())); - assert!(matches!(vk.verify(&tv.m, &rsig), Err(_))); - assert!(matches!(rvk.verify(&tv.m, &sig), Err(_))); + assert!(vk.verify(&tv.m, &rsig).is_err()); + assert!(rvk.verify(&tv.m, &sig).is_err()); } } diff --git a/src/rust/src/wallet.rs b/src/rust/src/wallet.rs index 5253ab9c32d..6d309f88dcb 100644 --- a/src/rust/src/wallet.rs +++ b/src/rust/src/wallet.rs @@ -537,7 +537,7 @@ impl Wallet { ); self.potential_spends .entry(*nf) - .or_insert_with(BTreeSet::new) + .or_default() .insert(inpoint); } diff --git a/src/wallet/gtest/test_wallet.cpp b/src/wallet/gtest/test_wallet.cpp index 9fc8b420e26..c273d1a8905 100644 --- a/src/wallet/gtest/test_wallet.cpp +++ b/src/wallet/gtest/test_wallet.cpp @@ -1095,7 +1095,13 @@ TEST(WalletTests, NavigateFromSaplingNullifierToNote) { ASSERT_TRUE(nf); uint256 nullifier = nf.value(); - MerkleFrontiers frontiers = { .sapling = testNote.tree }; + SproutMerkleTree sproutFrontier; + OrchardMerkleFrontier orchardFrontier; + MerkleFrontiers frontiers = { + .sprout = sproutFrontier, + .sapling = testNote.tree, + .orchard = orchardFrontier, + }; // Verify dummy note is unspent EXPECT_FALSE(wallet.IsSaplingSpent(nullifier, std::nullopt)); @@ -1482,7 +1488,11 @@ TEST(WalletTests, CachedWitnessesChainTip) { block2.vtx.push_back(wtx); CBlockIndex index2(block2); index2.nHeight = 2; - MerkleFrontiers frontiers2 = { .sprout = frontiers.sprout, .sapling = frontiers.sapling }; + MerkleFrontiers frontiers2 = { + .sprout = frontiers.sprout, + .sapling = frontiers.sapling, + .orchard = frontiers.orchard, + }; wallet.IncrementNoteWitnesses(Params().GetConsensus(), &index2, &block2, frontiers2, true); auto anchors2 = GetWitnessesAndAnchors(wallet, sproutNotes, saplingNotes, 1, sproutWitnesses, saplingWitnesses); @@ -1622,7 +1632,11 @@ TEST(WalletTests, CachedWitnessesCleanIndex) { std::vector sproutAnchors; std::vector saplingAnchors; MerkleFrontiers frontiers; - MerkleFrontiers riFrontiers = { .sprout = frontiers.sprout, .sapling = frontiers.sapling }; + MerkleFrontiers riFrontiers = { + .sprout = frontiers.sprout, + .sapling = frontiers.sapling, + .orchard = frontiers.orchard, + }; std::vector> sproutWitnesses; std::vector> saplingWitnesses; @@ -2068,7 +2082,13 @@ TEST(WalletTests, UpdatedSaplingNoteData) { builder.AddSaplingOutput(extfvk.fvk.ovk, pa2, 25000, {}); auto tx = builder.Build().GetTxOrThrow(); - MerkleFrontiers frontiers = { .sapling = testNote.tree }; + SproutMerkleTree sproutFrontier; + OrchardMerkleFrontier orchardFrontier; + MerkleFrontiers frontiers = { + .sprout = sproutFrontier, + .sapling = testNote.tree, + .orchard = orchardFrontier, + }; // Wallet contains extfvk1 but not extfvk2 CWalletTx wtx {&wallet, tx}; diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 1bcb749b427..ee9aedc2e42 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -3477,6 +3477,8 @@ WalletDecryptedNotes CWallet::TryDecryptShieldedOutputs(const CTransaction& tx) auto sproutNoteData = FindMySproutNotes(tx); // Sapling is trial decrypted in Rust. + mapSaplingNoteData_t saplingNoteData; + SaplingIncomingViewingKeyMap saplingViewingKeysToAdd; // Orchard // TODO: Trial decryption of Orchard notes alongside Sprout and Sapling will @@ -3485,6 +3487,7 @@ WalletDecryptedNotes CWallet::TryDecryptShieldedOutputs(const CTransaction& tx) return WalletDecryptedNotes { .sproutNoteData = sproutNoteData, + .saplingNoteDataAndAddressesToAdd = std::make_pair(saplingNoteData, saplingViewingKeysToAdd), }; } diff --git a/zcutil/clean.sh b/zcutil/clean.sh index 6e1f9a3e422..5180428bb89 100755 --- a/zcutil/clean.sh +++ b/zcutil/clean.sh @@ -9,6 +9,7 @@ rm -f doc/man/Makefile rm -f doc/man/Makefile.in rm -f .cargo/config +rm -f .cargo/config.toml rm -f .cargo/.configured-for-online rm -f .cargo/.configured-for-offline