Skip to content

Commit

Permalink
Merge branch 'bitcoin' into auxpow
Browse files Browse the repository at this point in the history
  • Loading branch information
domob1812 committed Dec 25, 2023
2 parents 8118bf6 + 4b1196a commit f19b650
Show file tree
Hide file tree
Showing 28 changed files with 214 additions and 107 deletions.
5 changes: 1 addition & 4 deletions ci/test/00_setup_env_mac.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,4 @@ export XCODE_BUILD_ID=15A240d
export RUN_UNIT_TESTS=false
export RUN_FUNCTIONAL_TESTS=false
export GOAL="deploy"

# False-positive warning is fixed with clang 17, remove this when that version
# can be used.
export BITCOIN_CONFIG="--with-gui --enable-reduce-exports LDFLAGS=-Wno-error=unused-command-line-argument"
export BITCOIN_CONFIG="--with-gui --enable-reduce-exports"
2 changes: 1 addition & 1 deletion contrib/devtools/symbol-check.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
# See https://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html for more info.

MAX_VERSIONS = {
'GCC': (4,8,0),
'GCC': (4,3,0),
'GLIBC': {
lief.ELF.ARCH.x86_64: (2,27),
lief.ELF.ARCH.ARM: (2,27),
Expand Down
2 changes: 1 addition & 1 deletion contrib/guix/libexec/prelude.bash
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ fi
time-machine() {
# shellcheck disable=SC2086
guix time-machine --url=https://git.savannah.gnu.org/git/guix.git \
--commit=77386bdbfe6b0c649c05ab37f08051d1ab3e5074 \
--commit=d5ca4d4fd713a9f7e17e074a1e37dda99bbb09fc \
--cores="$JOBS" \
--keep-failed \
--fallback \
Expand Down
2 changes: 1 addition & 1 deletion contrib/guix/manifest.scm
Original file line number Diff line number Diff line change
Expand Up @@ -525,5 +525,5 @@ inspecting signatures in Mach-O binaries.")
((string-contains target "-linux-")
(list (make-bitcoin-cross-toolchain target)))
((string-contains target "darwin")
(list clang-toolchain-15 binutils cmake-minimal python-signapple zip))
(list clang-toolchain-17 binutils cmake-minimal python-signapple zip))
(else '())))))
2 changes: 1 addition & 1 deletion depends/packages/native_libtapi.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ $(package)_sha256_hash=d4d46c64622f13d6938cecf989046d9561011bb59e8ee835f8f39825d
$(package)_patches=disable_zlib.patch

ifeq ($(strip $(FORCE_USE_SYSTEM_CLANG)),)
$(package)_dependencies=native_clang
$(package)_dependencies=native_llvm
endif

define $(package)_preprocess_cmds
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
package=native_clang
$(package)_version=15.0.6
package=native_llvm
$(package)_version=17.0.6
$(package)_major_version=$(firstword $(subst ., ,$($(package)_version)))
$(package)_download_path=https://github.com/llvm/llvm-project/releases/download/llvmorg-$($(package)_version)
ifneq (,$(findstring aarch64,$(BUILD)))
$(package)_file_name=clang+llvm-$($(package)_version)-aarch64-linux-gnu.tar.xz
$(package)_sha256_hash=8ca4d68cf103da8331ca3f35fe23d940c1b78fb7f0d4763c1c059e352f5d1bec
$(package)_sha256_hash=6dd62762285326f223f40b8e4f2864b5c372de3f7de0731cb7cd55ca5287b75a
else
$(package)_file_name=clang+llvm-$($(package)_version)-x86_64-linux-gnu-ubuntu-18.04.tar.xz
$(package)_sha256_hash=38bc7f5563642e73e69ac5626724e206d6d539fbef653541b34cae0ba9c3f036
$(package)_file_name=clang+llvm-$($(package)_version)-x86_64-linux-gnu-ubuntu-22.04.tar.xz
$(package)_sha256_hash=884ee67d647d77e58740c1e645649e29ae9e8a6fe87c1376be0f3a30f3cc9ab3
endif

define $(package)_stage_cmds
mkdir -p $($(package)_staging_prefix_dir)/lib/clang/$($(package)_version)/include && \
mkdir -p $($(package)_staging_prefix_dir)/lib/clang/$($(package)_major_version)/include && \
mkdir -p $($(package)_staging_prefix_dir)/bin && \
mkdir -p $($(package)_staging_prefix_dir)/include/llvm-c && \
cp bin/clang $($(package)_staging_prefix_dir)/bin/ && \
Expand All @@ -20,5 +21,5 @@ define $(package)_stage_cmds
cp include/llvm-c/ExternC.h $($(package)_staging_prefix_dir)/include/llvm-c && \
cp include/llvm-c/lto.h $($(package)_staging_prefix_dir)/include/llvm-c && \
cp lib/libLTO.so $($(package)_staging_prefix_dir)/lib/ && \
cp -r lib/clang/$($(package)_version)/include/* $($(package)_staging_prefix_dir)/lib/clang/$($(package)_version)/include/
cp -r lib/clang/$($(package)_major_version)/include/* $($(package)_staging_prefix_dir)/lib/clang/$($(package)_major_version)/include/
endef
2 changes: 1 addition & 1 deletion depends/packages/packages.mk
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ ifneq ($(build_os),darwin)
darwin_native_packages += native_cctools native_libtapi

ifeq ($(strip $(FORCE_USE_SYSTEM_CLANG)),)
darwin_native_packages+= native_clang
darwin_native_packages+= native_llvm
endif

endif
4 changes: 2 additions & 2 deletions depends/packages/qt.mk
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ $(package)_patches += fast_fixed_dtoa_no_optimize.patch
$(package)_patches += guix_cross_lib_path.patch
$(package)_patches += fix-macos-linker.patch
$(package)_patches += memory_resource.patch
$(package)_patches += utc_from_string_no_optimize.patch
$(package)_patches += windows_lto.patch
$(package)_patches += fix-minimum-macos.patch

$(package)_qttranslations_file_name=qttranslations-$($(package)_suffix)
$(package)_qttranslations_sha256_hash=a31785948c640b7c66d9fe2db4993728ca07f64e41c560b3625ad191b276ff20
Expand Down Expand Up @@ -240,7 +240,6 @@ endef
define $(package)_preprocess_cmds
cp $($(package)_patch_dir)/qt.pro qt.pro && \
cp $($(package)_patch_dir)/qttools_src.pro qttools/src/src.pro && \
patch -p1 -i $($(package)_patch_dir)/fix-minimum-macos.patch && \
patch -p1 -i $($(package)_patch_dir)/fix-macos-linker.patch && \
patch -p1 -i $($(package)_patch_dir)/dont_hardcode_pwd.patch && \
patch -p1 -i $($(package)_patch_dir)/fix_qt_pkgconfig.patch && \
Expand All @@ -251,6 +250,7 @@ define $(package)_preprocess_cmds
patch -p1 -i $($(package)_patch_dir)/memory_resource.patch && \
patch -p1 -i $($(package)_patch_dir)/rcc_hardcode_timestamp.patch && \
patch -p1 -i $($(package)_patch_dir)/duplicate_lcqpafonts.patch && \
patch -p1 -i $($(package)_patch_dir)/utc_from_string_no_optimize.patch && \
patch -p1 -i $($(package)_patch_dir)/fast_fixed_dtoa_no_optimize.patch && \
patch -p1 -i $($(package)_patch_dir)/guix_cross_lib_path.patch && \
patch -p1 -i $($(package)_patch_dir)/windows_lto.patch && \
Expand Down
18 changes: 0 additions & 18 deletions depends/patches/qt/fix-minimum-macos.patch

This file was deleted.

84 changes: 84 additions & 0 deletions depends/patches/qt/utc_from_string_no_optimize.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
Modify optimisation flags for various functions.
This fixes non-determinism issues in the asm produced for
these function when cross-compiling on x86_64 and aarch64 for
the arm64-apple-darwin HOST.

--- a/qtbase/src/corelib/itemmodels/qitemselectionmodel.cpp
+++ b/qtbase/src/corelib/itemmodels/qitemselectionmodel.cpp
@@ -1078,9 +1078,9 @@ void QItemSelectionModelPrivate::_q_layoutChanged(const QList<QPersistentModelIn

if (hint != QAbstractItemModel::VerticalSortHint) {
// sort the "new" selection, as preparation for merging
- std::stable_sort(savedPersistentIndexes.begin(), savedPersistentIndexes.end(),
+ std::sort(savedPersistentIndexes.begin(), savedPersistentIndexes.end(),
qt_PersistentModelIndexLessThan);
- std::stable_sort(savedPersistentCurrentIndexes.begin(), savedPersistentCurrentIndexes.end(),
+ std::sort(savedPersistentCurrentIndexes.begin(), savedPersistentCurrentIndexes.end(),
qt_PersistentModelIndexLessThan);

// update the selection by merging the individual indexes
@@ -1092,8 +1092,8 @@ void QItemSelectionModelPrivate::_q_layoutChanged(const QList<QPersistentModelIn
savedPersistentCurrentIndexes.clear();
} else {
// sort the "new" selection, as preparation for merging
- std::stable_sort(savedPersistentRowLengths.begin(), savedPersistentRowLengths.end());
- std::stable_sort(savedPersistentCurrentRowLengths.begin(), savedPersistentCurrentRowLengths.end());
+ std::sort(savedPersistentRowLengths.begin(), savedPersistentRowLengths.end());
+ std::sort(savedPersistentCurrentRowLengths.begin(), savedPersistentCurrentRowLengths.end());

// update the selection by merging the individual indexes
ranges = mergeRowLengths(savedPersistentRowLengths);

--- a/qtbase/src/corelib/itemmodels/qitemselectionmodel_p.h
+++ b/qtbase/src/corelib/itemmodels/qitemselectionmodel_p.h
@@ -76,7 +76,7 @@ public:
void _q_rowsAboutToBeInserted(const QModelIndex &parent, int start, int end);
void _q_columnsAboutToBeInserted(const QModelIndex &parent, int start, int end);
void _q_layoutAboutToBeChanged(const QList<QPersistentModelIndex> &parents = QList<QPersistentModelIndex>(), QAbstractItemModel::LayoutChangeHint hint = QAbstractItemModel::NoLayoutChangeHint);
- void _q_layoutChanged(const QList<QPersistentModelIndex> &parents = QList<QPersistentModelIndex>(), QAbstractItemModel::LayoutChangeHint hint = QAbstractItemModel::NoLayoutChangeHint);
+ __attribute__ ((optnone)) void _q_layoutChanged(const QList<QPersistentModelIndex> &parents = QList<QPersistentModelIndex>(), QAbstractItemModel::LayoutChangeHint hint = QAbstractItemModel::NoLayoutChangeHint);

inline void remove(QList<QItemSelectionRange> &r)
{

--- a/qtbase/src/corelib/time/qdatetimeparser_p.h
+++ b/qtbase/src/corelib/time/qdatetimeparser_p.h
@@ -215,7 +215,7 @@ private:
: value(ok == Invalid ? -1 : val), used(read), zeroes(zs), state(ok)
{}
};
- ParsedSection parseSection(const QDateTime &currentValue, int sectionIndex,
+ __attribute__ ((optnone)) ParsedSection parseSection(const QDateTime &currentValue, int sectionIndex,
int offset, QString *text) const;
int findMonth(const QString &str1, int monthstart, int sectionIndex,
int year, QString *monthName = nullptr, int *used = nullptr) const;

--- a/qtbase/src/corelib/time/qtimezoneprivate_p.h
+++ b/qtbase/src/corelib/time/qtimezoneprivate_p.h
@@ -191,7 +191,7 @@ public:
virtual ~QUtcTimeZonePrivate();

// Fall-back for UTC[+-]\d+(:\d+){,2} IDs.
- static qint64 offsetFromUtcString(const QByteArray &id);
+ static __attribute__ ((optnone)) qint64 offsetFromUtcString(const QByteArray &id);

QUtcTimeZonePrivate *clone() const override;

--- a/qtbase/src/widgets/widgets/qcalendarwidget.cpp
+++ b/qtbase/src/widgets/widgets/qcalendarwidget.cpp
@@ -329,13 +329,13 @@ class QCalendarYearValidator : public QCalendarDateSectionValidator

public:
QCalendarYearValidator();
- virtual Section handleKey(int key) override;
+ __attribute__ ((optnone)) virtual Section handleKey(int key) override;
virtual QDate applyToDate(QDate date, QCalendar cal) const override;
virtual void setDate(QDate date, QCalendar cal) override;
virtual QString text() const override;
virtual QString text(QDate date, QCalendar cal, int repeat) const override;
private:
- int pow10(int n);
+ __attribute__ ((optnone)) int pow10(int n);
int m_pos;
int m_year;
int m_oldYear;
2 changes: 2 additions & 0 deletions src/.clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,7 @@ SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
BreakBeforeConceptDeclarations: Always
RequiresExpressionIndentation: OuterScope
Standard: c++20
UseTab: Never
3 changes: 2 additions & 1 deletion src/interfaces/chain.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <blockfilter.h>
#include <common/settings.h>
#include <primitives/transaction.h> // For CTransactionRef
#include <util/result.h>

#include <functional>
#include <memory>
Expand Down Expand Up @@ -260,7 +261,7 @@ class Chain
virtual void getPackageLimits(unsigned int& limit_ancestor_count, unsigned int& limit_descendant_count) = 0;

//! Check if transaction will pass the mempool's chain limits.
virtual bool checkChainLimits(const CTransactionRef& tx) = 0;
virtual util::Result<void> checkChainLimits(const CTransactionRef& tx) = 0;

//! Estimate smart fee.
virtual CFeeRate estimateSmartFee(int num_blocks, bool conservative, FeeCalculation* calc = nullptr) = 0;
Expand Down
8 changes: 4 additions & 4 deletions src/node/interfaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#include <uint256.h>
#include <univalue.h>
#include <util/check.h>
#include <util/result.h>
#include <util/signalinterrupt.h>
#include <util/translation.h>
#include <validation.h>
Expand Down Expand Up @@ -702,14 +703,13 @@ class ChainImpl : public Chain
limit_ancestor_count = limits.ancestor_count;
limit_descendant_count = limits.descendant_count;
}
bool checkChainLimits(const CTransactionRef& tx) override
util::Result<void> checkChainLimits(const CTransactionRef& tx) override
{
if (!m_node.mempool) return true;
if (!m_node.mempool) return {};
LockPoints lp;
CTxMemPoolEntry entry(tx, 0, 0, 0, 0, false, 0, lp);
LOCK(m_node.mempool->cs);
std::string err_string;
return m_node.mempool->CheckPackageLimits({tx}, entry.GetTxSize(), err_string);
return m_node.mempool->CheckPackageLimits({tx}, entry.GetTxSize());
}
CFeeRate estimateSmartFee(int num_blocks, bool conservative, FeeCalculation* calc) override
{
Expand Down
2 changes: 2 additions & 0 deletions src/policy/feerate.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ class CFeeRate
friend bool operator!=(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK != b.nSatoshisPerK; }
CFeeRate& operator+=(const CFeeRate& a) { nSatoshisPerK += a.nSatoshisPerK; return *this; }
std::string ToString(const FeeEstimateMode& fee_estimate_mode = FeeEstimateMode::BTC_KVB) const;
friend CFeeRate operator*(const CFeeRate& f, int a) { return CFeeRate(a * f.nSatoshisPerK); }
friend CFeeRate operator*(int a, const CFeeRate& f) { return CFeeRate(a * f.nSatoshisPerK); }

SERIALIZE_METHODS(CFeeRate, obj) { READWRITE(obj.nSatoshisPerK); }
};
Expand Down
8 changes: 4 additions & 4 deletions src/script/descriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1777,15 +1777,15 @@ std::unique_ptr<DescriptorImpl> ParseScript(uint32_t& key_exp_index, Span<const
const auto script_ctx{ctx == ParseScriptContext::P2WSH ? miniscript::MiniscriptContext::P2WSH : miniscript::MiniscriptContext::TAPSCRIPT};
KeyParser parser(/*out = */&out, /* in = */nullptr, /* ctx = */script_ctx, key_exp_index);
auto node = miniscript::FromString(std::string(expr.begin(), expr.end()), parser);
if (parser.m_key_parsing_error != "") {
error = std::move(parser.m_key_parsing_error);
return nullptr;
}
if (node) {
if (ctx != ParseScriptContext::P2WSH && ctx != ParseScriptContext::P2TR) {
error = "Miniscript expressions can only be used in wsh or tr.";
return nullptr;
}
if (parser.m_key_parsing_error != "") {
error = std::move(parser.m_key_parsing_error);
return nullptr;
}
if (!node->IsSane() || node->IsNotSatisfiable()) {
// Try to find the first insane sub for better error reporting.
auto insane_node = node.get();
Expand Down
29 changes: 16 additions & 13 deletions src/serialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -271,10 +271,9 @@ template<typename Stream> inline void Serialize(Stream& s, int32_t a ) { ser_wri
template<typename Stream> inline void Serialize(Stream& s, uint32_t a) { ser_writedata32(s, a); }
template<typename Stream> inline void Serialize(Stream& s, int64_t a ) { ser_writedata64(s, a); }
template<typename Stream> inline void Serialize(Stream& s, uint64_t a) { ser_writedata64(s, a); }
template<typename Stream, int N> inline void Serialize(Stream& s, const char (&a)[N]) { s.write(MakeByteSpan(a)); }
template<typename Stream, int N> inline void Serialize(Stream& s, const unsigned char (&a)[N]) { s.write(MakeByteSpan(a)); }
template <typename Stream, typename B, std::size_t N> void Serialize(Stream& s, const std::array<B, N>& a) { (void)/* force byte-type */UCharCast(a.data()); s.write(MakeByteSpan(a)); }
template <typename Stream, typename B> void Serialize(Stream& s, Span<B> span) { (void)/* force byte-type */UCharCast(span.data()); s.write(AsBytes(span)); }
template <typename Stream, BasicByte B, int N> void Serialize(Stream& s, const B (&a)[N]) { s.write(MakeByteSpan(a)); }
template <typename Stream, BasicByte B, std::size_t N> void Serialize(Stream& s, const std::array<B, N>& a) { s.write(MakeByteSpan(a)); }
template <typename Stream, BasicByte B> void Serialize(Stream& s, Span<B> span) { s.write(AsBytes(span)); }

#ifndef CHAR_EQUALS_INT8
template <typename Stream> void Unserialize(Stream&, char) = delete; // char serialization forbidden. Use uint8_t or int8_t
Expand All @@ -288,10 +287,9 @@ template<typename Stream> inline void Unserialize(Stream& s, int32_t& a ) { a =
template<typename Stream> inline void Unserialize(Stream& s, uint32_t& a) { a = ser_readdata32(s); }
template<typename Stream> inline void Unserialize(Stream& s, int64_t& a ) { a = ser_readdata64(s); }
template<typename Stream> inline void Unserialize(Stream& s, uint64_t& a) { a = ser_readdata64(s); }
template<typename Stream, int N> inline void Unserialize(Stream& s, char (&a)[N]) { s.read(MakeWritableByteSpan(a)); }
template<typename Stream, int N> inline void Unserialize(Stream& s, unsigned char (&a)[N]) { s.read(MakeWritableByteSpan(a)); }
template <typename Stream, typename B, std::size_t N> void Unserialize(Stream& s, std::array<B, N>& a) { (void)/* force byte-type */UCharCast(a.data()); s.read(MakeWritableByteSpan(a)); }
template <typename Stream, typename B> void Unserialize(Stream& s, Span<B> span) { (void)/* force byte-type */UCharCast(span.data()); s.read(AsWritableBytes(span)); }
template <typename Stream, BasicByte B, int N> void Unserialize(Stream& s, B (&a)[N]) { s.read(MakeWritableByteSpan(a)); }
template <typename Stream, BasicByte B, std::size_t N> void Unserialize(Stream& s, std::array<B, N>& a) { s.read(MakeWritableByteSpan(a)); }
template <typename Stream, BasicByte B> void Unserialize(Stream& s, Span<B> span) { s.read(AsWritableBytes(span)); }

template <typename Stream> inline void Serialize(Stream& s, bool a) { uint8_t f = a; ser_writedata8(s, f); }
template <typename Stream> inline void Unserialize(Stream& s, bool& a) { uint8_t f = ser_readdata8(s); a = f; }
Expand Down Expand Up @@ -755,18 +753,23 @@ template<typename Stream, typename T> void Serialize(Stream& os, const std::uniq
template<typename Stream, typename T> void Unserialize(Stream& os, std::unique_ptr<const T>& p);



/**
* If none of the specialized versions above matched, default to calling member function.
*/
template<typename Stream, typename T>
inline void Serialize(Stream& os, const T& a)
template <class T, class Stream>
concept Serializable = requires(T a, Stream s) { a.Serialize(s); };
template <typename Stream, typename T>
requires Serializable<T, Stream>
void Serialize(Stream& os, const T& a)
{
a.Serialize(os);
}

template<typename Stream, typename T>
inline void Unserialize(Stream& is, T&& a)
template <class T, class Stream>
concept Unserializable = requires(T a, Stream s) { a.Unserialize(s); };
template <typename Stream, typename T>
requires Unserializable<T, Stream>
void Unserialize(Stream& is, T&& a)
{
a.Unserialize(is);
}
Expand Down
6 changes: 5 additions & 1 deletion src/span.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <algorithm>
#include <cassert>
#include <cstddef>
#include <span>
#include <type_traits>

#ifdef DEBUG
Expand Down Expand Up @@ -283,13 +284,16 @@ Span<std::byte> MakeWritableByteSpan(V&& v) noexcept
return AsWritableBytes(Span{std::forward<V>(v)});
}

// Helper functions to safely cast to unsigned char pointers.
// Helper functions to safely cast basic byte pointers to unsigned char pointers.
inline unsigned char* UCharCast(char* c) { return reinterpret_cast<unsigned char*>(c); }
inline unsigned char* UCharCast(unsigned char* c) { return c; }
inline unsigned char* UCharCast(std::byte* c) { return reinterpret_cast<unsigned char*>(c); }
inline const unsigned char* UCharCast(const char* c) { return reinterpret_cast<const unsigned char*>(c); }
inline const unsigned char* UCharCast(const unsigned char* c) { return c; }
inline const unsigned char* UCharCast(const std::byte* c) { return reinterpret_cast<const unsigned char*>(c); }
// Helper concept for the basic byte types.
template <typename B>
concept BasicByte = requires { UCharCast(std::span<B>{}.data()); };

// Helper function to safely convert a Span to a Span<[const] unsigned char>.
template <typename T> constexpr auto UCharSpanCast(Span<T> s) -> Span<typename std::remove_pointer<decltype(UCharCast(s.data()))>::type> { return {UCharCast(s.data()), s.size()}; }
Expand Down
Loading

0 comments on commit f19b650

Please sign in to comment.