Commit Graph

93 Commits

Author SHA1 Message Date
Sean Bowe
27616b9a04 Add support for Sapling anchors in coins/txdb. 2018-05-07 14:37:46 -06:00
Sean Bowe
f2c6d214e5 Rename hashSaplingAnchorEnd to hashFinalSaplingRoot to match spec. 2018-05-07 14:37:46 -06:00
Sean Bowe
18322f074c Introduce support for GetBestAnchor(SAPLING). 2018-05-07 13:46:06 -06:00
Sean Bowe
008f4ee8e7 Rename GetAnchorAt to GetSproutAnchorAt. 2018-05-07 13:46:06 -06:00
Sean Bowe
8b8d70cad9 Rename DB_ANCHOR to DB_SPROUT_ANCHOR. 2018-05-07 13:46:06 -06:00
Sean Bowe
691a3fa2e9 Rename hashReserved to hashSaplingAnchorEnd. 2018-05-07 13:46:06 -06:00
Sean Bowe
08f0728884 Rename hashAnchor to hashSproutAnchor. 2018-05-07 13:46:06 -06:00
Sean Bowe
d455828fdc Specifically describe anchors as Sprout anchors. 2018-05-07 13:46:06 -06:00
Sean Bowe
28d20bdb11 Rename NullifierType to ShieldedType. 2018-05-07 13:46:06 -06:00
Jack Grigg
1f9dfbb9f0 Fix -Wstring-plus-int warning on clang 2018-05-01 14:55:47 +01:00
Eirik Ogilvie-Wigley
9669920f75 Rename nullifier caches and maps to indicate sprout nullifiers 2018-04-25 11:26:38 -06:00
Eirik Ogilvie-Wigley
708c87f16d Add enum for nullifier type 2018-04-24 09:57:14 -06:00
Eirik Ogilvie-Wigley
685e936c31 Add sapling nullifier set 2018-04-24 09:57:14 -06:00
Jack Grigg
2d7bae5b33 Update CBlockTreeDB::EraseBatchSync for dbwrapper refactor 2018-04-03 21:38:34 +01:00
Wladimir J. van der Laan
809a429ecf dbwrapper: Pass parent CDBWrapper into CDBBatch and CDBIterator
Zcash: Makes future extensions easier.

Original description (when this was introduced upstream):

Pass parent wrapper directly instead of obfuscation key. This
makes it possible for other databases which re-use this code
to use other properties from the database.

Add a namespace dbwrapper_private for private functions to be used
only in dbwrapper.h/cpp and dbwrapper_tests.
2018-04-03 20:40:54 +01:00
Jeff Garzik
f345c41ec4 leveldbwrapper symbol rename: Remove "Level" from class, etc. names 2018-04-03 20:40:54 +01:00
Daniel Kraft
c77586964a trivial: use constants for db keys
Replace literal occurances of the key "prefixes" 'c' and 'b' in txdb.cpp
by the respective constants.
2018-04-03 20:40:54 +01:00
Pieter Wuille
f95bf4c417 Fix chainstate serialized_size computation 2018-04-03 20:40:54 +01:00
James O'Beirne
0d9524ba6b Minor bugfixes
Was "Handle obfuscation in CLevelDBIterator"

Zcash: Only bugfixes
2018-04-03 20:40:54 +01:00
Pieter Wuille
1ebf50b6da Encapsulate CLevelDB iterators cleanly
Conflicts:
	src/leveldb.cpp
	src/leveldb.h
	src/txdb.cpp
2018-04-03 20:40:54 +01:00
Jack Grigg
3a8e1d0cf4 Refactor Zcash changes to CCoinsViewDB
To match upstream changes.
2018-04-03 20:40:54 +01:00
James O'Beirne
0d81464be7 Refactor leveldbwrapper
Was "Add chainstate obfuscation to avoid spurious antivirus detection"

Zcash: Extracted the refactor, omitting the chainstate obfuscation.
2018-04-03 20:40:54 +01:00
Jack Grigg
f5007d8912 When rewinding, remove insufficiently-validated blocks
If a block is insufficiently-validated against a particular branch ID, then we
cannot guarantee that even the block header will be valid under the actual
consensus rules the node will want to apply. Instead require that the blocks are
completely re-validated, by removing them from the block index (which is
equivalent to reducing their validity to BLOCK_VALID_UNKNOWN).
2018-04-03 10:58:31 +01:00
Jack Grigg
704b76358d Use block hash comparison for consistency check when loading block index
The Equihash check caused block index loading to take around 38x longer.
However, we don't need to check it directly, as the only paths to writing a
block header to disk already go through a proof-of-work check (e.g. receiving a
block over the network). By forcing the block header inside the CBlockIndex to
be re-serialized, we retain the benefits of the consistency check without the
overhead at startup.

Co-authored-by: Brad Miller <brad@z.cash>
2018-02-27 00:47:56 +00:00
Homu
50400310af Auto merge of #2977 - str4d:loadblockindexguts-correctness, r=str4d
Check Equihash solution when loading block index

An additional consistency check, which also ensures that the in-memory representation
matches the stored index.
2018-02-21 19:05:23 -08:00
Jack Grigg
44488400c1 Check Equihash solution when loading block index 2018-02-21 22:37:19 +00:00
Homu
6264927fef Auto merge of #2931 - jc23424:hashreserved-diskindex, r=str4d
read hashReserved from disk

This fixes a bug where the hashReserved field of the block header is not properly read back into CBlockIndex when loaded from disk. This happens to cause no issues currently because hashReserved has always been its default value (== 0), but if a block were ever mined where this was not the case, headers read back from disk would appear to have an invalid solution
2018-02-21 14:35:58 -08:00
Jack Grigg
828940b163 Use a boost::optional for nCachedBranchId
This enables us to distinguish between it being unset vs. being set to zero.
2018-02-06 22:42:18 +00:00
jc
15fb13f629 read hashReserved from disk block index 2018-02-04 21:40:14 -05:00
Jack Grigg
9e851450ab Adjust rewind logic to use the network upgrade mechanism 2018-02-04 22:58:42 +00:00
Jack Grigg
ad6a36ad02 Track net value entering and exiting the Sprout circuit
Delta values will be stored for new blocks; old blocks can be filled in by
re-indexing. The net value currently in the Sprout circuit is only calculated
when delta values for all previous blocks are present.
2017-12-14 22:06:11 +00:00
Jack Grigg
c66c731adf Add a benchmark for calling ConnectBlock on a block with many inputs
Requires placing block-107134.tar.gz (containing the block, and a fake CoinsDB
containing its inputs) into the base directory of the repository. This can be
generated using qa/zcash/create_benchmark_archive.py (see the script for usage
details).

To facilitate generation of the fake CoinsDB, an additional field 'valueZat' has
been added to 'getrawtransaction' containing the integer number of zatoshis
instead of a decimal number of ZEC.

Closes #2355.
2017-05-18 11:03:46 +12:00
Wladimir J. van der Laan
a0455eca11 rpc: make gettxoutsettinfo run lock-free
For leveldb "An iterator operates on a snapshot of the database taken
when the iterator is created". This means that it is unnecessary to
lock out other threads while computing statistics, and neither to hold
cs_main for the whole time. Let the thread run free.
2017-03-02 13:23:03 -08:00
Jack Grigg
b6961fc112 Increment witnesses for new transactions on rescan
Closes #1400
2016-10-17 09:55:02 -05:00
Sean Bowe
22de160219 Fixes for indentation and local variable names. 2016-07-18 10:07:29 -06:00
Sean Bowe
9e511dbbdd Rename CSerialsCacheEntry. 2016-07-18 10:06:18 -06:00
Sean Bowe
bb64be52fe Rename mapSerials to mapNullifiers. 2016-07-18 10:06:18 -06:00
Sean Bowe
d889a287ae Rename CSerialsMap to CNullifiersMap. 2016-07-18 10:06:18 -06:00
Sean Bowe
616f8d05af Rename GetSerial to GetNullifier. 2016-07-18 10:06:18 -06:00
Taylor Hornby
bf2e3122ac Remove the Merkle tree hash function's fixed point. 2016-05-16 20:20:36 -06:00
Sean Bowe
434f328446 Integrate new incremental merkle tree implementation into consensus. 2016-04-28 16:07:52 -06:00
Jack Grigg
fdda3c5085 Use Equihash for Proof-of-Work
The main and test networks are configured to use parameters that are currently
low-memory but usable with the basic solver; they will be increased once the
solver is optimised. The regtest network is configured to have extremely low
memory usage for speed.

Note that Bitcoin's double-hasher is used for the difficulty check. This does
not match the paper, but is simpler than changing the block header
serialization. Single hashing is kept for the EquiHash solver because there is
no requirement on execution time there, only on memory usage.
2016-04-08 13:56:00 +12:00
Sean Bowe
d66877afb3 Added mapSerials consensus rules to prohibit double-spending. 2016-01-19 14:36:09 -07:00
Sean Bowe
45d6bee945 Add mapSerials infrastructure to CCoinsView.
This adds the TXDB/CCoinsViewCache primitives necessary for
writing consensus rules for mapSerials later.
2016-01-19 14:36:04 -07:00
Sean Bowe
9f25631d50 Add mapAnchors infrastructure to CCoinsView.
This adds the TXDB/CCoinsViewCache primitives necessary for
writing consensus rules for mapAnchors later.
2016-01-19 14:36:04 -07:00
Jorge Timón
d698ef690f Consensus: Refactor: Decouple pow.o from chainparams.o 2015-03-26 00:47:51 +01:00
Jorge Timón
8a893c949b Includes: Do not include main.h from any other header 2015-03-24 17:23:32 +01:00
Pavel Janík
5262fde0ec Remove whitespaces before double colon in errors and logs 2015-01-31 17:38:28 -05:00
Earlz
14d023f1ae change hardcoded character constants to a set of descriptive named constants for database keys 2015-01-25 10:56:30 -05:00
Wladimir J. van der Laan
4f1524966a Replace direct use of 0 with SetNull and IsNull
Replace x=0 with .SetNull(),
x==0 with IsNull(), x!=0 with !IsNull().
Replace uses of uint256(0) with uint256().
2015-01-05 15:45:34 +01:00