Skip to content

Commit c98e305

Browse files
authored
[PSL-1174] pasteld: update googletest library to the latest 1.14 - updated googletest library from v1.11 to v1.14 (08/02/2023) (#253)
[PSL-1177] pasteld: update zstd library to the latest v1.5.6 - updated zstd library from v.1.5.5 to v1.5.6 (03/30/2024) [PSL-1173] pasteld: existing ticket validation in the forked chain pasteld v2.3.0-beta2 - mainnet chain forked at height 657,925 and the same ticket was registered in both chains at different heights: 658,421 and 658,564 - the node active chain was the forked one - main chain at one point became longer (more work) than the forked one, but it couldn't switch to that better chain because of ticket validation failure (action registration ticket could not be validated - because it was finding existing ticket registered in the forked chain, that ticket was written to the Ticket DB) - ticket processor functions to find/list/process/get tickets by primary/secondary/mv keys were changed to make them fork-aware. Optional parameter pindexPrev that points to the previous block being validated was passed to all the functions. If this parameter is passed and the function finds the ticket in DB - it checks if this ticket transaction is in the block which is direct ancestor of the pindexPrev block. If not - it will not return this ticket. This way when validating forked chain ticket processor won't see tickets registered in the active chain after the fork point. - corrected IsValid functions for all ticket types to work with new ticket processor functions including functions that work with signatures, collections, collection items, dependent tickets, etc... - switch to the better chain can be automatic if the reorg length is not longer that 99 blocks, for longer reorgs you have to specify parameter in the command-line or pastel.conf: -rewindchain=_block_hash_. - fixed IsIntendedChainRewind to allow specify -rewindchain block as fork block or its direct ancestor (up to 1000 blocks)
1 parent 4eed66f commit c98e305

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+933
-513
lines changed

build-aux/vs2022/settings/googletest.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<ItemDefinitionGroup>
1010
<ClCompile>
1111
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
12-
<PreprocessorDefinitions>_CONSOLE;GOOGLETEST;%(PreprocessorDefinitions)</PreprocessorDefinitions>
12+
<PreprocessorDefinitions>_CONSOLE;GOOGLETEST;GTEST_LINKED_AS_SHARED_LIBRARY;%(PreprocessorDefinitions)</PreprocessorDefinitions>
1313
</ClCompile>
1414
<Link>
1515
<Profile>true</Profile>

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ AC_PREREQ([2.60])
33
define(_CLIENT_VERSION_MAJOR, 2)
44
define(_CLIENT_VERSION_MINOR, 3)
55
define(_CLIENT_VERSION_REVISION, 0)
6-
define(_CLIENT_VERSION_BUILD, 0)
6+
define(_CLIENT_VERSION_BUILD, 1)
77
define(_ZC_BUILD_VAL,
88
m4_if(m4_eval(_CLIENT_VERSION_BUILD < 25), 1, m4_incr(_CLIENT_VERSION_BUILD),
99
m4_eval(_CLIENT_VERSION_BUILD < 50), 1,

depends/packages/googletest.mk

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package=googletest
2-
$(package)_version=1.11.0
2+
$(package)_version=1.14.0
33
$(package)_download_path=https://github.com/google/$(package)/archive/refs/tags
44
$(package)_file_name=$(package)-$($(package)_version).tar.gz
5-
$(package)_download_file=release-$($(package)_version).tar.gz
6-
$(package)_sha256_hash=b4870bf121ff7795ba20d20bcdd8627b8e088f2d1dab299a031c1034eddc93d5
5+
$(package)_download_file=v$($(package)_version).tar.gz
6+
$(package)_sha256_hash=8ad598c73ad796e0d8280b082cebd82a630d73e73cd3c70057938a6501bba5d7
77

88
define $(package)_set_vars
99
$(package)_cxxflags+= -std=c++17

depends/packages/zstd.mk

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package=zstd
2-
$(package)_version=1.5.5
2+
$(package)_version=1.5.6
33
$(package)_download_path=https://github.com/facebook/zstd/releases/download/v$($(package)_version)/
44
$(package)_file_name=$(package)-$($(package)_version).tar.gz
5-
$(package)_sha256_hash=9c4396cc829cfae319a6e2615202e82aad41372073482fce286fac78646d3ee4
5+
$(package)_sha256_hash=8c29e06cf42aacc1eafc4077ae2ec6c6fcb96a626157e0593d5e82a34fd403c1
66

77
define $(package)_preprocess_cmds
88
mkdir -p bld
@@ -16,6 +16,7 @@ $(package)_cmake_opts+= -DCMAKE_CXX_STANDARD_REQUIRED=ON
1616
$(package)_cmake_opts+= -DCMAKE_POSITION_INDEPENDENT_CODE=ON
1717
$(package)_cmake_opts+= -DZSTD_BUILD_SHARED=OFF
1818
$(package)_cmake_opts+= -DZSTD_BUILD_PROGRAMS=OFF
19+
$(package)_cmake_opts+= -DZSTD_MULTITHREAD_SUPPORT=ON
1920
$(package)_cmake_opts+= -DSYSINSTALL_BINDINGS=ON
2021
$(package)_cmake_opts+= -DCMAKE_INSTALL_PREFIX=$($(package)_staging_prefix_dir)
2122
endef

src/accept_to_mempool.cpp

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -283,14 +283,16 @@ bool AreInputsStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs,
283283
* \param state - validation state
284284
* \param chainparams - chain parameters
285285
* \param nHeight - height of the block being evaluated
286+
* \param pindexPrev - pointer to the previous block index
286287
* \param isInitBlockDownload - functor to check IBD mode
287-
* \return
288+
* \return true if the transaction is valid, false otherwise
288289
*/
289290
bool ContextualCheckTransaction(
290291
const CTransaction& tx,
291292
CValidationState &state,
292293
const CChainParams& chainparams,
293294
const int nHeight,
295+
const CBlockIndex *pindexPrev,
294296
funcIsInitialBlockDownload_t isInitBlockDownload)
295297
{
296298
const auto& consensusParams = chainparams.GetConsensus();
@@ -512,7 +514,7 @@ bool ContextualCheckTransaction(
512514
}
513515

514516
// Check Pastel Ticket transactions
515-
const auto tv = CPastelTicketProcessor::ValidateIfTicketTransaction(state, nHeight, tx);
517+
const auto tv = CPastelTicketProcessor::ValidateIfTicketTransaction(state, nHeight, tx, pindexPrev);
516518
if (tv.state == TICKET_VALIDATION_STATE::NOT_TICKET || tv.state == TICKET_VALIDATION_STATE::VALID)
517519
return true;
518520
if (tv.state == TICKET_VALIDATION_STATE::MISSING_INPUTS)
@@ -526,11 +528,20 @@ bool ContextualCheckTransaction(
526528
REJECT_INVALID, "bad-tx-invalid-ticket", false, strRejectReasonDetails);
527529
}
528530

531+
/**
532+
* Contextual validation of the block and its transactions.
533+
*
534+
* \param block - block to check
535+
* \param state - validation state
536+
* \param chainparams - chain parameters
537+
* \param pindexPrev - pointer to the previous block index
538+
* \return true if the block is valid, false otherwise
539+
*/
529540
bool ContextualCheckBlock(
530541
const CBlock& block,
531542
CValidationState& state,
532543
const CChainParams& chainparams,
533-
CBlockIndex * const pindexPrev)
544+
const CBlockIndex *pindexPrev)
534545
{
535546
const int nHeight = !pindexPrev ? 0 : pindexPrev->nHeight + 1;
536547
const auto& consensusParams = chainparams.GetConsensus();
@@ -540,7 +551,7 @@ bool ContextualCheckBlock(
540551
for (const auto& tx : block.vtx)
541552
{
542553
// Check transaction contextually against consensus rules at block height
543-
if (!ContextualCheckTransaction(tx, state, chainparams, nHeight))
554+
if (!ContextualCheckTransaction(tx, state, chainparams, nHeight, pindexPrev, fnIsInitialBlockDownload))
544555
return false; // Failure reason has been set in validation state object
545556

546557
int nLockTimeFlags = 0;
@@ -839,7 +850,7 @@ bool AcceptToMemoryPool(
839850
return error("%s: CheckTransaction failed. %s", sFuncLog, state.GetRejectReason());
840851

841852
// Check transaction contextually against the set of consensus rules which apply in the next block to be mined.
842-
if (!ContextualCheckTransaction(tx, state, chainparams, nextBlockHeight))
853+
if (!ContextualCheckTransaction(tx, state, chainparams, nextBlockHeight, nullptr, fnIsInitialBlockDownload))
843854
{
844855
if (state.IsRejectCode(REJECT_MISSING_INPUTS))
845856
{

src/accept_to_mempool.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <consensus/params.h>
1313
#include <primitives/transaction.h>
1414
#include <txmempool.h>
15+
#include <chain.h>
1516

1617
/** Check whether we are doing an initial block download (synchronizing from disk or network) */
1718
extern funcIsInitialBlockDownload_t fnIsInitialBlockDownload;
@@ -24,7 +25,8 @@ bool ContextualCheckTransaction(
2425
CValidationState &state,
2526
const CChainParams& chainparams,
2627
const int nHeight,
27-
funcIsInitialBlockDownload_t isInitBlockDownload = fnIsInitialBlockDownload);
28+
const CBlockIndex *pindexPrev,
29+
funcIsInitialBlockDownload_t isInitBlockDownload);
2830

2931
/** Context-independent validity checks */
3032
bool CheckTransaction(const CTransaction& tx, CValidationState& state, libzcash::ProofVerifier& verifier);

src/chain.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,24 @@ CBlockIndex* FindLastCommonAncestorBlockIndex(CBlockIndex* pa, CBlockIndex* pb)
452452
return pa;
453453
}
454454

455+
const CBlockIndex* FindLastCommonAncestorBlockIndex(const CBlockIndex* pa, const CBlockIndex* pb)
456+
{
457+
if (pa->nHeight > pb->nHeight)
458+
pa = pa->GetAncestor(pb->nHeight);
459+
else if (pb->nHeight > pa->nHeight)
460+
pb = pb->GetAncestor(pa->nHeight);
461+
462+
while (pa != pb && pa && pb)
463+
{
464+
pa = pa->pprev;
465+
pb = pb->pprev;
466+
}
467+
468+
// Eventually all chain branches meet at the genesis block.
469+
assert(pa == pb);
470+
return pa;
471+
}
472+
455473
int64_t CBlockIndex::GetMedianTimePast() const noexcept
456474
{
457475
int64_t pmedian[nMedianTimeSpan];

src/chain.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,3 +453,4 @@ class CChain {
453453

454454
// Find the last common ancestor two blocks have.
455455
CBlockIndex* FindLastCommonAncestorBlockIndex(CBlockIndex* pa, CBlockIndex* pb);
456+
const CBlockIndex* FindLastCommonAncestorBlockIndex(const CBlockIndex* pa, const CBlockIndex* pb);

src/clientversion.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#define CLIENT_VERSION_MAJOR 2
1818
#define CLIENT_VERSION_MINOR 3
1919
#define CLIENT_VERSION_REVISION 0
20-
#define CLIENT_VERSION_BUILD 0
20+
#define CLIENT_VERSION_BUILD 1
2121

2222
//! Set to true for release, false for prerelease or test build
2323
#define CLIENT_VERSION_IS_RELEASE true

src/coins.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#pragma once
22
// Copyright (c) 2009-2010 Satoshi Nakamoto
33
// Copyright (c) 2009-2014 The Bitcoin Core developers
4-
// Copyright (c) 2018-2023 The Pastel Core developers
4+
// Copyright (c) 2018-2024 The Pastel Core developers
55
// Distributed under the MIT software license, see the accompanying
66
// file COPYING or https://www.opensource.org/licenses/mit-license.php.
77
#include <assert.h>
@@ -74,7 +74,7 @@ class CCoins
7474
bool fCoinBase;
7575

7676
//! unspent transaction outputs; spent outputs are .IsNull(); spent outputs at the end of the array are dropped
77-
std::vector<CTxOut> vout;
77+
v_txouts vout;
7878

7979
//! at which height this transaction was included in the active block chain
8080
int nHeight;
@@ -98,7 +98,7 @@ class CCoins
9898

9999
void Clear() {
100100
fCoinBase = false;
101-
std::vector<CTxOut>().swap(vout);
101+
v_txouts().swap(vout);
102102
nHeight = 0;
103103
nVersion = 0;
104104
}
@@ -111,7 +111,7 @@ class CCoins
111111
while (vout.size() > 0 && vout.back().IsNull())
112112
vout.pop_back();
113113
if (vout.empty())
114-
std::vector<CTxOut>().swap(vout);
114+
v_txouts().swap(vout);
115115
}
116116

117117
void ClearUnspendable() {

0 commit comments

Comments
 (0)