Skip to content

Commit

Permalink
sync with KO static-experimental
Browse files Browse the repository at this point in the history
fixes 'ERROR: ConnectBlock: ac_staked chain failed slow komodo_checkPOW' among other things

squashed 00f8aa...820b99

add zk-SNARK proofs related comments

zmq: Fix due to invalid argument and multiple notifiers

fix value pools calculations (#63)

KomodoPlatform/komodo#604
depends: patch boost to ignore -Wnonnull new gcc 11 warnings (#64)

this patch fixes errors like:

```
include/boost/concept/detail/general.hpp:39:47: warning: 'this' pointer null [-Wnonnull]
   39 |     static void failed() { ((Model*)0)->~Model(); }
```

during build with gcc 11.x, more details can be found here:

- boostorg/concept_check#27
- boostorg/concept_check#28
build: proper clean of ./src/qt/qrc_*.cpp in clean-help

Add chain supply and transparent value to block index.

Co-authored-by: Jack Grigg <jack@z.cash>
Co-authored-by: Kris Nuttycombe <kris@nutty.land>
Co-authored-by: Daira Hopwood <daira@jacaranda.org>

bump version [0.8.1.3]

from 0.8.1.3 diskblockindex have new fields, related to chain
supply caused by this block and delta in the transparent pool produced
by the action of the transparent inputs to and outputs from
transactions in this block.

See the: TRANSPARENT_VALUE_VERSION constant.

fix transparent pool addition for unspendable outputs

chain.h: change std::nullopt to boost::none in comments

introduce burned coins value pool

burned coins refer to the value sent for OP_RETURN scripts:
```
"vout": [
...
    {
      "value": 2.00000000,
      "valueZat": 200000000,
      "n": 1,
      "scriptPubKey": {
        "asm": "OP_RETURN 6465636b6572",
        "hex": "6a066465636b6572",
        "type": "nulldata"
      }
    }
  ],
  "vjoinsplit": [
  ]
```
burned coins are also excluded from transparent pool.

bump version [0.8.1.4]

this update activates burned coins value pool, see: BURNED_VALUE_VERSION

revert fMiningRequiresPeers change on CMainParams

The change was made solely for debugging purposes and was
accidentally included in the PR. We are now reverting that change.

remove unused CompareBlocksByHeightMain comparator

bump COPYRIGHT_YEAR to 2024
  • Loading branch information
TheComputerGenie committed Jan 5, 2024
1 parent 8ab64b2 commit 4e1fc11
Show file tree
Hide file tree
Showing 11 changed files with 350 additions and 33 deletions.
4 changes: 2 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ AC_PREREQ([2.60])
define(_CLIENT_VERSION_MAJOR, 0)
define(_CLIENT_VERSION_MINOR, 8)
define(_CLIENT_VERSION_REVISION, 1)
define(_CLIENT_VERSION_BUILD, 1)
define(_CLIENT_VERSION_BUILD, 4)
define(_ZC_BUILD_VAL, m4_if(m4_eval(_CLIENT_VERSION_BUILD < 25), 1, m4_incr(_CLIENT_VERSION_BUILD), m4_eval(_CLIENT_VERSION_BUILD < 50), 1, m4_eval(_CLIENT_VERSION_BUILD - 24), m4_eval(_CLIENT_VERSION_BUILD == 50), 1, , m4_eval(_CLIENT_VERSION_BUILD - 50)))
define(_CLIENT_VERSION_SUFFIX, m4_if(m4_eval(_CLIENT_VERSION_BUILD < 25), 1, _CLIENT_VERSION_REVISION-beta$1, m4_eval(_CLIENT_VERSION_BUILD < 50), 1, _CLIENT_VERSION_REVISION-rc$1, m4_eval(_CLIENT_VERSION_BUILD == 50), 1, _CLIENT_VERSION_REVISION, _CLIENT_VERSION_REVISION-$1)))
define(_CLIENT_VERSION_IS_RELEASE, true)
define(_COPYRIGHT_YEAR, 2023)
define(_COPYRIGHT_YEAR, 2024)
define(_COPYRIGHT_HOLDERS, "The %s developers")
define(_COPYRIGHT_HOLDERS_SUBSTITUTION, "Ocean and Decker")

Expand Down
3 changes: 2 additions & 1 deletion depends/packages/boost.mk
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ $(package)_version=1_72_0
$(package)_download_path=https://github.com/KomodoPlatform/boost/releases/download/boost-1.72.0-kmd
$(package)_sha256_hash=59c9b274bc451cf91a9ba1dd2c7fdcaf5d60b1b3aa83f2c9fa143417cc660722
$(package)_file_name=$(package)_$($(package)_version).tar.bz2
$(package)_patches=commit-74fb0a2.patch commit-f9d0e59.patch
$(package)_patches=commit-74fb0a2.patch commit-f9d0e59.patch ignore_wnonnull_gcc_11.patch

define $(package)_set_vars
$(package)_config_opts_release=variant=release
Expand All @@ -30,6 +30,7 @@ endef
define $(package)_preprocess_cmds
patch -p2 -i $($(package)_patch_dir)/commit-74fb0a2.patch && \
patch -p2 -i $($(package)_patch_dir)/commit-f9d0e59.patch && \
patch -p2 -i $($(package)_patch_dir)/ignore_wnonnull_gcc_11.patch && \
echo "using $(boost_toolset_$(host_os)) : : $($(package)_cxx) : <cxxflags>\"$($(package)_cxxflags) $($(package)_cppflags)\" <linkflags>\"$($(package)_ldflags)\" <archiver>\"$(boost_archiver_$(host_os))\" <striper>\"$(host_STRIP)\" <ranlib>\"$(host_RANLIB)\" <rc>\"$(host_WINDRES)\" : ;" > user-config.jam
endef

Expand Down
68 changes: 68 additions & 0 deletions depends/patches/boost/ignore_wnonnull_gcc_11.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
diff --git a/include/boost/concept/detail/general.hpp b/include/boost/concept/detail/general.hpp
index eeb08750..8d7d6f69 100644
--- a/include/boost/concept/detail/general.hpp
+++ b/include/boost/concept/detail/general.hpp
@@ -28,7 +28,14 @@ namespace detail
template <class Model>
struct requirement
{
+# if defined(BOOST_GCC) && (BOOST_GCC >= 110000)
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Wnonnull"
+# endif
static void failed() { ((Model*)0)->~Model(); }
+# if defined(BOOST_GCC) && (BOOST_GCC >= 110000)
+# pragma GCC diagnostic pop
+# endif
};

struct failed {};
@@ -36,7 +43,14 @@ struct failed {};
template <class Model>
struct requirement<failed ************ Model::************>
{
+# if defined(BOOST_GCC) && (BOOST_GCC >= 110000)
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Wnonnull"
+# endif
static void failed() { ((Model*)0)->~Model(); }
+# if defined(BOOST_GCC) && (BOOST_GCC >= 110000)
+# pragma GCC diagnostic pop
+# endif
};

# ifdef BOOST_OLD_CONCEPT_SUPPORT
@@ -44,7 +58,14 @@ struct requirement<failed ************ Model::************>
template <class Model>
struct constraint
{
+# if defined(BOOST_GCC) && (BOOST_GCC >= 110000)
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Wnonnull"
+# endif
static void failed() { ((Model*)0)->constraints(); }
+# if defined(BOOST_GCC) && (BOOST_GCC >= 110000)
+# pragma GCC diagnostic pop
+# endif
};

template <class Model>
diff --git a/include/boost/concept/usage.hpp b/include/boost/concept/usage.hpp
index 373de63a..fe88b5f5 100644
--- a/include/boost/concept/usage.hpp
+++ b/include/boost/concept/usage.hpp
@@ -13,7 +13,14 @@ namespace boost { namespace concepts {
template <class Model>
struct usage_requirements
{
+# if defined(BOOST_GCC) && (BOOST_GCC >= 110000)
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Wnonnull"
+# endif
~usage_requirements() { ((Model*)0)->~Model(); }
+# if defined(BOOST_GCC) && (BOOST_GCC >= 110000)
+# pragma GCC diagnostic pop
+# endif
};

# if BOOST_WORKAROUND(__GNUC__, <= 3)
64 changes: 62 additions & 2 deletions src/chain.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@

extern CCriticalSection cs_main;

static const int SPROUT_VALUE_VERSION = 1001400;
static const int SAPLING_VALUE_VERSION = 1010100;
static const int SPROUT_VALUE_VERSION = 80102;
static const int SAPLING_VALUE_VERSION = 80102;
static const int TRANSPARENT_VALUE_VERSION = 80103;
static const int BURNED_VALUE_VERSION = 80104;

// These 5 are declared here to avoid circular dependencies
// code used this moved into .cpp
Expand Down Expand Up @@ -191,6 +193,44 @@ class CBlockIndex
//! (memory only) The anchor for the tree state up to the end of this block
uint256 hashFinalSproutRoot;

//! The change to the chain supply caused by this block. This is defined as
//! the value of the coinbase outputs in this block, minus fees not claimed
//! by the miner.
//!
//! Will be boost::none under the following conditions:
//! - if the block has never been connected to a chain tip
//! - for older blocks until a reindex has taken place
boost::optional<CAmount> nChainSupplyDelta;

//! (memory only) Total chain supply up to and including this block.
//!
//! Will be boost::none until a reindex has taken place, if nChainTx is
//! zero, or if the block has never been connected to a chain tip.
boost::optional<CAmount> nChainTotalSupply;

//! Change in value in the transparent pool produced by the action of the
//! transparent inputs to and outputs from transactions in this block.
//!
//! Will be boost::none for older blocks until a reindex has taken place.
boost::optional<CAmount> nTransparentValue;

//! (memory only) Total value of the transparent value pool up to and
//! including this block.
//!
//! Will be boost::none until a reindex has taken place.
//! Will be boost::none if nChainTx is zero.
boost::optional<CAmount> nChainTransparentValue;

// This refers to the number of coins burned in this block,
// essentially making them unspendable (due to the OP_RETURN scripts value).
//!
//! For older blocks, this will be boost::none until a reindexing has occurred.
boost::optional<CAmount> nBurnedAmountDelta;

//! (memory only) Total value of the burned coins up to and
//! including this block.
boost::optional<CAmount> nChainTotalBurned;

//! Change in value held by the Sprout circuit over this block.
//! Will be boost::none for older blocks on old nodes until a reindex has taken place.
boost::optional<CAmount> nSproutValue;
Expand Down Expand Up @@ -246,6 +286,13 @@ class CBlockIndex
hashSproutAnchor = uint256();
hashFinalSproutRoot = uint256();
nSequenceId = 0;

nChainSupplyDelta = boost::none;
nChainTotalSupply = boost::none;
nTransparentValue = boost::none;
nChainTransparentValue = boost::none;
nBurnedAmountDelta = boost::none;
nChainTotalBurned = boost::none;
nSproutValue = boost::none;
nChainSproutValue = boost::none;
nSaplingValue = 0;
Expand Down Expand Up @@ -440,6 +487,19 @@ class CDiskBlockIndex : public CBlockIndex
READWRITE(nNonce);
READWRITE(nSolution);

// Only read/write nTransparentValue if the client version used to create
// this index was storing them.
if ((s.GetType() & SER_DISK) && (nVersion >= TRANSPARENT_VALUE_VERSION)) {
READWRITE(nChainSupplyDelta);
READWRITE(nTransparentValue);
}

// Only read/write nBurnedAmountDelta if the client version used to create
// this index was storing them.
if ((s.GetType() & SER_DISK) && (nVersion >= BURNED_VALUE_VERSION)) {
READWRITE(nBurnedAmountDelta);
}

// Only read/write nSproutValue if the client version used to create
// this index was storing them.
if ((s.GetType() & SER_DISK) && (nVersion >= SPROUT_VALUE_VERSION)) {
Expand Down
7 changes: 6 additions & 1 deletion src/coins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,12 @@ const CScript &CCoinsViewCache::GetSpendFor(const CTxIn& input) const
* @returns Sum of value of all inputs (scriptSigs), (positive valueBalance or zero) and JoinSplit vpub_new
*/
CAmount CCoinsViewCache::GetValueIn(int32_t nHeight,int64_t &interestp,const CTransaction& tx) const
{
return GetTransparentValueIn(nHeight, interestp, tx) + tx.GetShieldedValueIn();
}

// TODO: remove this if it ends up unused
CAmount CCoinsViewCache::GetTransparentValueIn(int32_t nHeight,int64_t &interestp,const CTransaction& tx) const
{
CAmount value,nResult = 0;
interestp = 0;
Expand Down Expand Up @@ -617,7 +623,6 @@ CAmount CCoinsViewCache::GetValueIn(int32_t nHeight,int64_t &interestp,const CTr
}
#endif
}
nResult += tx.GetShieldedValueIn();

return nResult;
}
Expand Down
15 changes: 13 additions & 2 deletions src/coins.h
Original file line number Diff line number Diff line change
Expand Up @@ -562,11 +562,22 @@ class CCoinsViewCache : public CCoinsViewBacked
* so may not be able to calculate this.
* @param[in] nHeight the chain height
* @param[out] interestp the interest found
* @param[in] tx transaction for which we are checking input total
* @returns Sum of value of all inputs (scriptSigs), (positive valueBalance or zero) and JoinSplit vpub_new
* @param[in] tx transaction for which we are checking input total
* @return Sum of value of all inputs (scriptSigs), JoinSplit vpub_new, and
* positive values of valueBalanceSapling, and valueBalanceOrchard.
*/
CAmount GetValueIn(int32_t nHeight,int64_t &interestp,const CTransaction& tx) const;

/**
* Amount of coins coming in to a transaction in the transparent inputs.
*
* @param[in] nHeight the chain height
* @param[out] interestp the interest found
* @param[in] tx transaction for which we are checking input total
* @return Sum of value of all inputs (scriptSigs)
*/
CAmount GetTransparentValueIn(int32_t nHeight,int64_t &interestp,const CTransaction& tx) const;

//! Check whether all prevouts of the transaction are present in the UTXO set represented by this view
bool HaveInputs(const CTransaction& tx) const;

Expand Down
Loading

0 comments on commit 4e1fc11

Please sign in to comment.