Skip to content

Commit

Permalink
Merge pull request #5427 from PastaPastaPasta/v19.2-rc.1-backports
Browse files Browse the repository at this point in the history
backport: V19.2 rc.1 backports
  • Loading branch information
PastaPastaPasta committed Jun 13, 2023
2 parents 2fbd73e + 75fe05e commit 44cd30f
Show file tree
Hide file tree
Showing 62 changed files with 1,049 additions and 288 deletions.
12 changes: 9 additions & 3 deletions configure.ac
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
AC_PREREQ([2.69])
define(_CLIENT_VERSION_MAJOR, 19)
define(_CLIENT_VERSION_MINOR, 1)
define(_CLIENT_VERSION_MINOR, 2)
define(_CLIENT_VERSION_BUILD, 0)
define(_CLIENT_VERSION_RC, 0)
define(_CLIENT_VERSION_IS_RELEASE, true)
define(_CLIENT_VERSION_RC, 1)
define(_CLIENT_VERSION_IS_RELEASE, false)
define(_COPYRIGHT_YEAR, 2023)
define(_COPYRIGHT_HOLDERS,[The %s developers])
define(_COPYRIGHT_HOLDERS_SUBSTITUTION,[[Dash Core]])
Expand Down Expand Up @@ -713,6 +713,12 @@ case $host in
export PKG_CONFIG_PATH
fi

gmp_prefix=$($BREW --prefix gmp 2>/dev/null)
if test x$gmp_prefix != x; then
CPPFLAGS="$CPPFLAGS -I$gmp_prefix/include"
LDFLAGS="$LDFLAGS -L$gmp_prefix/lib"
fi

case $host in
*aarch64*)
dnl The preferred Homebrew prefix for Apple Silicon is /opt/homebrew.
Expand Down
2 changes: 1 addition & 1 deletion depends/packages/qt.mk
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
PACKAGE=qt
$(package)_version=5.12.11
$(package)_download_path=https://download.qt.io/official_releases/qt/5.12/$($(package)_version)/submodules
$(package)_download_path=https://download.qt.io/archive/qt/5.12/$($(package)_version)/submodules
$(package)_suffix=everywhere-src-$($(package)_version).tar.xz
$(package)_file_name=qtbase-$($(package)_suffix)
$(package)_sha256_hash=1c1b4e33137ca77881074c140d54c3c9747e845a31338cfe8680f171f0bc3a39
Expand Down
289 changes: 289 additions & 0 deletions doc/release-notes/dash/release-notes-19.0.0.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/bip39.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,11 @@ bool CMnemonic::Check(SecureString mnemonic)
return fResult;
}

// passphrase must be at most 256 characters or code may crash
// passphrase must be at most 256 characters otherwise it would be truncated
void CMnemonic::ToSeed(SecureString mnemonic, SecureString passphrase, SecureVector& seedRet)
{
SecureString ssSalt = SecureString("mnemonic") + passphrase;
SecureVector vchSalt(ssSalt.begin(), ssSalt.end());
SecureVector vchSalt(ssSalt.begin(), ssSalt.begin() + strnlen(ssSalt.data(), 256));
seedRet.resize(64);
PKCS5_PBKDF2_HMAC_SHA512(mnemonic.c_str(), mnemonic.size(), vchSalt.data(), vchSalt.size(), 2048, 64, seedRet.data());
}
2 changes: 1 addition & 1 deletion src/bip39.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class CMnemonic
static SecureString Generate(int strength); // strength in bits
static SecureString FromData(const SecureVector& data, int len);
static bool Check(SecureString mnemonic);
// passphrase must be at most 256 characters or code may crash
// passphrase must be at most 256 characters otherwise it would be truncated
static void ToSeed(SecureString mnemonic, SecureString passphrase, SecureVector& seedRet);
};

Expand Down
61 changes: 34 additions & 27 deletions src/bls/bls.h
Original file line number Diff line number Diff line change
Expand Up @@ -418,10 +418,7 @@ class CBLSLazyWrapper
CBLSLazyWrapper() :
vecBytes(BLSObject::SerSize, 0),
bufLegacyScheme(bls::bls_legacy_scheme.load())
{
// the all-zero buf is considered a valid buf, but the resulting object will return false for IsValid
bufValid = true;
}
{}

explicit CBLSLazyWrapper(const CBLSLazyWrapper& r)
{
Expand All @@ -437,6 +434,7 @@ class CBLSLazyWrapper
if (r.bufValid) {
vecBytes = r.vecBytes;
} else {
vecBytes.resize(BLSObject::SerSize);
std::fill(vecBytes.begin(), vecBytes.end(), 0);
}
objInitialized = r.objInitialized;
Expand All @@ -459,12 +457,9 @@ class CBLSLazyWrapper
{
std::unique_lock<std::mutex> l(mutex);
if (!objInitialized && !bufValid) {
// the all-zero buf is considered a valid buf
vecBytes.resize(BLSObject::SerSize);
std::fill(vecBytes.begin(), vecBytes.end(), 0);
bufLegacyScheme = specificLegacyScheme;
bufValid = true;
}
if (!bufValid || (bufLegacyScheme != specificLegacyScheme)) {
} else if (!bufValid || (bufLegacyScheme != specificLegacyScheme)) {
vecBytes = obj.ToByteVector(specificLegacyScheme);
bufValid = true;
bufLegacyScheme = specificLegacyScheme;
Expand All @@ -476,7 +471,7 @@ class CBLSLazyWrapper
template<typename Stream>
inline void Serialize(Stream& s) const
{
Serialize(s, bls::bls_legacy_scheme.load());
Serialize(s, bufLegacyScheme);
}

template<typename Stream>
Expand All @@ -493,13 +488,14 @@ class CBLSLazyWrapper
template<typename Stream>
inline void Unserialize(Stream& s) const
{
Unserialize(s, bls::bls_legacy_scheme.load());
Unserialize(s, bufLegacyScheme);
}

void Set(const BLSObject& _obj)
void Set(const BLSObject& _obj, const bool specificLegacyScheme)
{
std::unique_lock<std::mutex> l(mutex);
bufValid = false;
bufLegacyScheme = specificLegacyScheme;
objInitialized = true;
obj = _obj;
hash.SetNull();
Expand All @@ -514,21 +510,14 @@ class CBLSLazyWrapper
if (!objInitialized) {
obj.SetByteVector(vecBytes, bufLegacyScheme);
if (!obj.IsValid()) {
// If setting of BLS object using one scheme failed, then we need to attempt again with the opposite scheme.
// This is due to the fact that LazyBLSWrapper receives a serialised buffer but attempts to create actual BLS object when needed.
// That could happen when the fork has been activated and the enforced scheme has switched.
obj.SetByteVector(vecBytes, !bufLegacyScheme);
if (obj.IsValid()) {
bufLegacyScheme = !bufLegacyScheme;
}
bufValid = false;
return invalidObj;
}
if (!obj.CheckMalleable(vecBytes, bufLegacyScheme)) {
bufValid = false;
objInitialized = false;
obj = invalidObj;
} else {
objInitialized = true;
return invalidObj;
}
objInitialized = true;
}
return obj;
}
Expand All @@ -549,13 +538,16 @@ class CBLSLazyWrapper
return !(*this == r);
}

uint256 GetHash(const bool specificLegacyScheme = bls::bls_legacy_scheme.load()) const
uint256 GetHash() const
{
std::unique_lock<std::mutex> l(mutex);
if (!bufValid || bufLegacyScheme != specificLegacyScheme) {
vecBytes = obj.ToByteVector(specificLegacyScheme);
if (!objInitialized && !bufValid) {
vecBytes.resize(BLSObject::SerSize);
std::fill(vecBytes.begin(), vecBytes.end(), 0);
hash.SetNull();
} else if (!bufValid) {
vecBytes = obj.ToByteVector(bufLegacyScheme);
bufValid = true;
bufLegacyScheme = specificLegacyScheme;
hash.SetNull();
}
if (hash.IsNull()) {
Expand All @@ -565,6 +557,21 @@ class CBLSLazyWrapper
}
return hash;
}

bool IsLegacy() const
{
return bufLegacyScheme;
}

void SetLegacy(bool specificLegacyScheme)
{
bufLegacyScheme = specificLegacyScheme;
}

std::string ToString() const
{
return Get().ToString(bufLegacyScheme);
}
};
using CBLSLazySignature = CBLSLazyWrapper<CBLSSignature>;
using CBLSLazyPublicKey = CBLSLazyWrapper<CBLSPublicKey>;
Expand Down
14 changes: 7 additions & 7 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -485,10 +485,10 @@ class CTestNetParams : public CChainParams {
consensus.vDeployments[Consensus::DEPLOYMENT_V19].nFalloffCoeff = 5; // this corresponds to 10 periods

// The best chain should have at least this much work.
consensus.nMinimumChainWork = uint256S("0x00000000000000000000000000000000000000000000000002d68cb6c090031f"); // 864000
consensus.nMinimumChainWork = uint256S("0x00000000000000000000000000000000000000000000000002d68c6dc9ca04f3"); // 840000

// By default assume that the signatures in ancestors of this block are valid.
consensus.defaultAssumeValid = uint256S("0x0000005c35514190ef3c38d322f69412553dc7e1107ed5f92adc2935b90acc51"); // 864000
consensus.defaultAssumeValid = uint256S("0x000000cd7c3084499912ae893125c13e8c3c656abb6e511dcec6619c3d65a510"); // 840000

pchMessageStart[0] = 0xce;
pchMessageStart[1] = 0xe2;
Expand Down Expand Up @@ -568,16 +568,16 @@ class CTestNetParams : public CChainParams {
{470000, uint256S("0x0000009303aeadf8cf3812f5c869691dbd4cb118ad20e9bf553be434bafe6a52")},
{794950, uint256S("0x000001860e4c7248a9c5cc3bc7106041750560dc5cd9b3a2641b49494bcff5f2")},
{808000, uint256S("0x00000104cb60a2b5e00a8a4259582756e5bf0dca201c0993c63f0e54971ea91a")},
{864000, uint256S("0x0000005c35514190ef3c38d322f69412553dc7e1107ed5f92adc2935b90acc51")},
{840000, uint256S("0x000000cd7c3084499912ae893125c13e8c3c656abb6e511dcec6619c3d65a510")},
}
};

// getchaintxstats 17280 0000005c35514190ef3c38d322f69412553dc7e1107ed5f92adc2935b90acc51
// getchaintxstats 17280 000000cd7c3084499912ae893125c13e8c3c656abb6e511dcec6619c3d65a510
chainTxData = ChainTxData{
1680868209, // * UNIX timestamp of last known number of transactions (Block 771537)
5847013, // * total number of transactions between genesis and that timestamp
1676885923, // * UNIX timestamp of last known number of transactions (Block 840000)
5776047, // * total number of transactions between genesis and that timestamp
// (the tx=... number in the ChainStateFlushed debug.log lines)
0.01994632331955769, // * estimated number of transactions per second after that timestamp
0.01120953982471268, // * estimated number of transactions per second after that timestamp
};
}
};
Expand Down
25 changes: 14 additions & 11 deletions src/coinjoin/coinjoin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,30 +41,31 @@ bool CCoinJoinEntry::AddScriptSig(const CTxIn& txin)
return false;
}

uint256 CCoinJoinQueue::GetSignatureHash() const
uint256 CCoinJoinQueue::GetSignatureHash(bool legacy) const
{
return SerializeHash(*this);
int version = legacy ? COINJOIN_PROTX_HASH_PROTO_VERSION - 1 : PROTOCOL_VERSION;
return SerializeHash(*this, SER_GETHASH, version);
}

bool CCoinJoinQueue::Sign()
{
if (!fMasternodeMode) return false;


uint256 hash = GetSignatureHash();
bool legacy_bls_scheme = !llmq::utils::IsV19Active(::ChainActive().Tip());
uint256 hash = GetSignatureHash(legacy_bls_scheme);
CBLSSignature sig = WITH_LOCK(activeMasternodeInfoCs, return activeMasternodeInfo.blsKeyOperator->Sign(hash));
if (!sig.IsValid()) {
return false;
}
bool legacy_bls_scheme = !llmq::utils::IsV19Active(::ChainActive().Tip());
vchSig = sig.ToByteVector(legacy_bls_scheme);

return true;
}

bool CCoinJoinQueue::CheckSignature(const CBLSPublicKey& blsPubKey) const
{
if (!CBLSSignature(vchSig).VerifyInsecure(blsPubKey, GetSignatureHash())) {
bool legacy_bls_scheme = !llmq::utils::IsV19Active(::ChainActive().Tip());
if (!CBLSSignature(vchSig).VerifyInsecure(blsPubKey, GetSignatureHash(legacy_bls_scheme))) {
LogPrint(BCLog::COINJOIN, "CCoinJoinQueue::CheckSignature -- VerifyInsecure() failed\n");
return false;
}
Expand All @@ -89,29 +90,31 @@ bool CCoinJoinQueue::IsTimeOutOfBounds(int64_t current_time) const
nTime - current_time > COINJOIN_QUEUE_TIMEOUT;
}

uint256 CCoinJoinBroadcastTx::GetSignatureHash() const
uint256 CCoinJoinBroadcastTx::GetSignatureHash(bool legacy) const
{
return SerializeHash(*this);
int version = legacy ? COINJOIN_PROTX_HASH_PROTO_VERSION - 1 : PROTOCOL_VERSION;
return SerializeHash(*this, SER_GETHASH, version);
}

bool CCoinJoinBroadcastTx::Sign()
{
if (!fMasternodeMode) return false;

uint256 hash = GetSignatureHash();
bool legacy_bls_scheme = !llmq::utils::IsV19Active(::ChainActive().Tip());
uint256 hash = GetSignatureHash(legacy_bls_scheme);
CBLSSignature sig = WITH_LOCK(activeMasternodeInfoCs, return activeMasternodeInfo.blsKeyOperator->Sign(hash));
if (!sig.IsValid()) {
return false;
}
bool legacy_bls_scheme = !llmq::utils::IsV19Active(::ChainActive().Tip());
vchSig = sig.ToByteVector(legacy_bls_scheme);

return true;
}

bool CCoinJoinBroadcastTx::CheckSignature(const CBLSPublicKey& blsPubKey) const
{
if (!CBLSSignature(vchSig).VerifyInsecure(blsPubKey, GetSignatureHash())) {
bool legacy_bls_scheme = !llmq::utils::IsV19Active(::ChainActive().Tip());
if (!CBLSSignature(vchSig).VerifyInsecure(blsPubKey, GetSignatureHash(legacy_bls_scheme))) {
LogPrint(BCLog::COINJOIN, "CCoinJoinBroadcastTx::CheckSignature -- VerifyInsecure() failed\n");
return false;
}
Expand Down
8 changes: 4 additions & 4 deletions src/coinjoin/coinjoin.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ class CCoinJoinQueue
{
READWRITE(obj.nDenom);

if (s.GetVersion() < COINJOIN_PROTX_HASH_PROTO_VERSION || (s.GetType() & SER_GETHASH)) {
if (s.GetVersion() < COINJOIN_PROTX_HASH_PROTO_VERSION) {
READWRITE(obj.masternodeOutpoint);
} else {
READWRITE(obj.m_protxHash);
Expand All @@ -230,7 +230,7 @@ class CCoinJoinQueue
}
}

[[nodiscard]] uint256 GetSignatureHash() const;
[[nodiscard]] uint256 GetSignatureHash(bool legacy) const;
/** Sign this mixing transaction
* return true if all conditions are met:
* 1) we have an active Masternode,
Expand Down Expand Up @@ -292,7 +292,7 @@ class CCoinJoinBroadcastTx
{
READWRITE(obj.tx);

if (s.GetVersion() < COINJOIN_PROTX_HASH_PROTO_VERSION || (s.GetType() & SER_GETHASH)) {
if (s.GetVersion() < COINJOIN_PROTX_HASH_PROTO_VERSION) {
READWRITE(obj.masternodeOutpoint);
} else {
READWRITE(obj.m_protxHash);
Expand All @@ -317,7 +317,7 @@ class CCoinJoinBroadcastTx
return *this != CCoinJoinBroadcastTx();
}

[[nodiscard]] uint256 GetSignatureHash() const;
[[nodiscard]] uint256 GetSignatureHash(bool legacy) const;

bool Sign();
[[nodiscard]] bool CheckSignature(const CBLSPublicKey& blsPubKey) const;
Expand Down
3 changes: 1 addition & 2 deletions src/evo/cbtx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,7 @@ bool CalcCbTxMerkleRootMNList(const CBlock& block, const CBlockIndex* pindexPrev
int64_t nTime2 = GetTimeMicros(); nTimeDMN += nTime2 - nTime1;
LogPrint(BCLog::BENCHMARK, " - BuildNewListFromBlock: %.2fms [%.2fs]\n", 0.001 * (nTime2 - nTime1), nTimeDMN * 0.000001);

bool v19active = llmq::utils::IsV19Active(pindexPrev);
CSimplifiedMNList sml(tmpMNList, v19active);
CSimplifiedMNList sml(tmpMNList);

int64_t nTime3 = GetTimeMicros(); nTimeSMNL += nTime3 - nTime2;
LogPrint(BCLog::BENCHMARK, " - CSimplifiedMNList: %.2fms [%.2fs]\n", 0.001 * (nTime3 - nTime2), nTimeSMNL * 0.000001);
Expand Down

0 comments on commit 44cd30f

Please sign in to comment.