Commit Graph

112 Commits

Author SHA1 Message Date
Alex Morcos 1d866c85d8 [cleanup] Remove coin age priority completely.
Remove GetPriority and ComputePriority.  Remove internal machinery for tracking priority in CTxMemPoolEntry.

(cherry picked from commit bitcoin/bitcoin@359e8a03d1)

Zcash:
* We don't have `src/bench/mempool_eviction.cpp`.
* We don't have `-walletrejectlongchains`.
* Now we can remove `MAX_PRIORITY`.
* Fix a comment in `coins.h` while we're changing code next to it.
* Update the `Mempool/PriorityStatsDoNotCrash` regression test.

Signed-off-by: Daira Emma Hopwood <daira@jacaranda.org>
2023-04-17 18:49:45 +01:00
Kris Nuttycombe cc2fd60617 Make all CCoinsView methods pure-virtual. 2023-02-15 13:58:46 -07:00
str4d d6e2fada84
Merge pull request #6362 from nuttycom/issue2921-fix-copyright-headers
Replace fix-copyright-headers.py with a script that creates a scripted-diff git commit.
2023-01-23 22:13:05 +00:00
Kris Nuttycombe 3cec519ce4 scripted-diff: Update Zcash copyrights to 2023
-BEGIN VERIFY SCRIPT-
for party in "The Zcash developers" "The Bitcoin Core developers" "Bitcoin Developers"; do
  sed -i"" -e "s#Copyright (c) \([0-9]\{4\}\)\(-[0-9]\{4\}\)\? $party#Copyright (c) \1-2023 $party#" COPYING
  sed -i"" -e "s#\(.*\)\([0-9]\{4\}\)\(-[0-9]\{4\}\)\, $party#\1\2-2023, $party#" contrib/debian/copyright
done

sed -i"" -e "s/define(_COPYRIGHT_YEAR, [0-9]\{4\})/define(_COPYRIGHT_YEAR, 2023)/" configure.ac
sed -i"" -e "s/#define COPYRIGHT_YEAR [0-9]\{4\}/#define COPYRIGHT_YEAR 2023/" src/clientversion.h

git grep "^// Copyright (c) .* The Zcash developers" \
  | awk -F ':' '{print $1}' \
  | xargs -I {} sed -i"" -e "s#// Copyright (c) \([0-9]\{4\}\)\(-[0-9]\{4\}\)\? The Zcash developers#// Copyright (c) \1-2023 The Zcash developers#" {}
-END VERIFY SCRIPT-
2023-01-23 11:31:54 -07:00
Kris Nuttycombe 2fd52ada51 Apply suggestions from code review
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2023-01-22 09:10:03 -07:00
Alfredo Garcia 486817498f 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>
2023-01-22 09:10:03 -07:00
Daira Hopwood d502714326 Refactor HaveShieldedRequirements to use tl::expected (example with a void T)
and rename it to CheckShieldedRequirements.

Signed-off-by: Daira Hopwood <jacaranda.org>
2022-12-08 20:53:54 +00:00
Kris Nuttycombe 28040f9ce4 scripted-diff: Add 2016-2022 copyright headers for files added/modified in 2016
-BEGIN VERIFY SCRIPT-
grep -l "Copyright" $(grep -L "The Zcash developers" $(git diff --name-only --diff-filter=ACM bitcoin-v0.11.2..94f427a211bb337200c29a1e19be0f5ad2f171b0 -- src/ test/ zcutil/ qa/)) | xargs -I {} sed -i"" -e "s#\(\(.*\)Copyright (c) .* The Bitcoin Core developers\)#\1\n\2Copyright (c) 2016-2022 The Zcash developers#" {}
-END VERIFY SCRIPT-
2022-05-11 17:23:09 -06:00
Kris Nuttycombe 14f06f9f06 Return MAX_PRIORITY when transactions contain an Orchard bundle. 2022-04-07 08:47:47 -06:00
Jack Grigg ae3d2a3525 Add missing `view.PopAnchor(_, ORCHARD)` in `DisconnectBlock`
By forgetting to pop the tree, we were leaving the view in an
inconsistent state, where it believed the best Orchard anchor was for a
tree that didn't correspond to the rest of the view. This would then
propagate in subsequent block connections, and the chain history
commitments to Orchard tree roots eventually result in inconsistent
`blockcommitments` values in subsequent blocks.
2022-03-03 13:26:48 +00:00
Kris Nuttycombe f49f4c73d8 Rename OrchardMerkleTree -> OrchardMerkleFrontier
Remove IncrementalSinsemillaTree; this will be replaced by
a more full-featured OrchardWallet type which embeds the
incremental merkle tree used in wallet operations.
2021-11-23 07:27:34 -07:00
Kris Nuttycombe 0d40ea8494 Add Orchard nullifiers to nullifiers cache. 2021-06-28 17:43:23 -06:00
Kris Nuttycombe fd34ecc64d Return std::optional for GetAnchor 2021-06-23 16:06:30 -06:00
Kris Nuttycombe 437b8c488a Orchard changes to coins & consensus. 2021-06-23 16:06:30 -06:00
Pieter Wuille 47ed587336 Use C++11 thread-safe static initializers 2021-02-17 08:07:00 -07:00
Pieter Wuille ec4196d8cf Use SipHash-2-4 for CCoinsCache index
This is ~1.7x slower than the Lookup3-of-Xor-with-salt construct we were
using before, but it is a primitive designed for exactly this.

Zcash: Propagate CCoinsKeyHasher -> SaltedTxidHasher changes to where
we've used CCoinsKeyHasher outside of its original scope.
2021-02-11 11:10:42 -07:00
Jorge Timón 92a867febc scripted-diff: Fully remove BOOST_FOREACH
-BEGIN VERIFY SCRIPT-
sed -i 's/BOOST_FOREACH *(\(.*\),/for (\1 :/' ./src/*.h ./src/*.cpp ./src/*/*.h ./src/*/*.cpp ./src/*/*/*.h ./src/*/*/*.cpp ;
-END VERIFY SCRIPT-
2020-11-23 23:07:15 +00:00
Jack Grigg 6fa2d1b73e Add logging to CCoinsViewCache::HaveShieldedRequirements
Enable with -debug=consensus
2020-10-23 20:16:07 +01:00
Jack Grigg 47c0c65326 Improve reject reasons for unmet shielded requirements
These reject messages end up bubbling up to users via the RPC interface.
Distinguishing between the various failure cases will help users figure
out why their transaction is being rejected.

Uses operator* instead of std::optional::value because the latter was
introduced in macOS 10.14, and our current minimum is 10.12.

Closes zcash/zcash#3114.
2020-10-23 20:16:07 +01:00
Kris Nuttycombe 04b4d42767 Zero-initialize HistoryNode values. 2020-07-23 16:24:48 -06:00
therealyingtong 13aa74aa45
Pass HistoryNode struct to librustzcash FFI 2020-07-21 17:56:47 +08:00
Daira Hopwood 66096d540f Clean up some iterator usage.
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2020-07-13 19:35:26 +01:00
Sean Bowe c3018904c3
Don't throw exception in PopHistoryNode when popping from empty tree.
If we are doing an expected rollback that changes the consensus
branch ID for some upgrade (or introduces one that wasn't present
at the equivalent height) this will occur because
`SelectHistoryCache` selects the tree for the new consensus
branch ID, not the one that existed on the chain being rolled
back.
2020-05-05 17:25:56 -06:00
Jack Grigg 31e5f9cde2 Make peak_pos zero-indexed in CCoinsViewCache::PreloadHistoryTree 2020-04-11 11:52:56 +12:00
Jack Grigg 21d8e5be15 Comment clarifications and fixes 2020-04-11 11:39:00 +12:00
Jack Grigg 15ef73e586 Improve documentation of CCoinsViewCache::PreloadHistoryTree 2020-04-10 19:47:45 +12:00
Jack Grigg 65073157e6 Remove unnecessary else case in CCoinsViewCache::PreloadHistoryTree 2020-04-10 19:47:45 +12:00
Daira Hopwood d47676fe00 Refer to altitude instead of height for history tree peaks 2020-04-10 19:47:45 +12:00
Jack Grigg 2ad84e8564 Comment tweaks and cleanups
Co-Authored-By: Daira Hopwood <daira@jacaranda.org>
2020-04-10 09:53:30 +12:00
Jack Grigg 82fe37d22b Use a C array for HistoryEntry instead of std::array
std::vector<T> is guaranteed to store T contiguously. However, there is
no guarantee that sizeof(std::array<unsigned char, N>) == N, which
prevents us from interpreting std::vector<std::array<unsigned char, N>>
as &[[u8; N]] on the Rust side of the FFI.

Instead, we define HistoryEntry as a struct wrapping a C array, which
(as checked by static_assert) contains no padding.
2020-04-08 08:49:01 +12:00
NikVolf 5608118cc4 use iterative platform-independent log2i 2020-04-08 08:49:01 +12:00
NikVolf cf247bc655 push/pop history with tests
Co-authored-by: Jack Grigg <jack@z.cash>
2020-04-08 08:49:01 +12:00
Daira Hopwood bc909a7a7f Replace http with https: in links to the MIT license.
Also change MIT/X11 to just MIT, since no distinction was intended.

Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2019-07-18 15:26:01 +01:00
Dimitris Apostolou f57f76d789
Rename vjoinsplit to vJoinSplit 2019-06-16 19:13:49 +03:00
Homu 9cd74866c7 Auto merge of #3262 - str4d:2074-perf-1, r=str4d
Bitcoin 0.12 performance improvements

Cherry-picked from the following upstream PRs:

- bitcoin/bitcoin#6918
- bitcoin/bitcoin#6932

Part of #2074.
2018-11-30 15:25:33 -08:00
arielgabizon 06affbca05 rename HaveJoinSplitRequirements for Sapling 2018-10-29 20:56:13 +01:00
Alex Morcos 7335afabd4
ModifyNewCoins saves database lookups
When processing a new transaction, in addition to spending the Coins of its txin's it creates a new Coins for its outputs.  The existing ModifyCoins function will first make sure this Coins does not already exist.  It can not exist due to BIP 30, but because of that the lookup can't be cached and always has to go to the database.  Since we are creating the coins to match the new tx anyway, there is no point in checking if they exist first anyway.

Zcash: Modified to account for the fact that BIP 30 and BIP 34 have applied
from the beginning.
2018-10-24 19:28:39 +08:00
Eirik Ogilvie-Wigley 51e6ed6110 Move FIXME comment to where the fix should happen 2018-09-28 12:16:05 -06:00
Eirik Ogilvie-Wigley a13492744d Use max priority for all shielded transfers 2018-09-28 10:32:30 -06:00
Eirik Ogilvie-Wigley 4fc309f0f5 Rename Merkle Trees to include sprout or sapling 2018-08-01 10:31:09 -06:00
Homu 9acfa0067f Auto merge of #3258 - Eirik0:3056-anchor-test-cases, r=str4d
Add tests for sapling anchors

Closes #3253
2018-06-19 09:28:20 -07:00
Eirik Ogilvie-Wigley 3182b4abc3 Add tests for sapling anchors 2018-05-16 10:31:53 -06:00
Jack Grigg 97b46f00cc
Add valueBalance to value balances, and enforce its consensus rules 2018-05-09 11:34:41 +01:00
Sean Bowe 8c57bbac15 Fix broken error messages. 2018-05-07 14:37:46 -06:00
Sean Bowe e390a475c1 Fix outdated comment 2018-05-07 14:37:46 -06:00
Sean Bowe 1f8be05b63 Add consensus support for Sapling merkle trees. 2018-05-07 14:37:46 -06:00
Sean Bowe 85b39f57bb Add `PushSaplingAnchor` 2018-05-07 14:37:46 -06:00
Sean Bowe c643ff0b51 Add support for PopAnchor(.., SPROUT/SAPLING) 2018-05-07 14:37:46 -06:00
Sean Bowe 27616b9a04 Add support for Sapling anchors in coins/txdb. 2018-05-07 14:37:46 -06:00
Sean Bowe 7703a673ea Generalize the PushAnchor implementation behavior. 2018-05-07 14:37:43 -06:00