Commit Graph

930 Commits

Author SHA1 Message Date
Pieter Wuille abd22bb674 Add tests for CCoins deserialization 2016-10-20 22:59:50 -07:00
zkbot c99a1c7e4f Auto merge of #1566 - daira:1557.make-v2-txns-standard, r=ageis
1557.make v2 txns standard

Make v2 transactions standard. This also corrects a rule about admitting large orphan transactions into the mempool, to account for v2-specific fields. ref #1557
2016-10-21 01:10:37 -04:00
zkbot f90526579b Auto merge of #1569 - str4d:1552-disable-wallet-encryption, r=daira
Disable wallet encryption

Closes #1552
2016-10-20 17:01:51 -04:00
Jack Grigg d8e06e3f58
Add test that encryptwallet is disabled 2016-10-20 14:45:44 -05:00
Jack Grigg 66a89c08df
Rename bitcoin-tx to zcash-tx
Closes #1565
2016-10-18 16:45:43 -05:00
Jack Grigg 08d6b02d5e
Rename libbitcoinconsensus to libzcashconsensus
Closes #1563
2016-10-18 16:45:37 -05:00
Daira Hopwood 71cc1b58a1 Add tests for IsStandardTx applied to v2 transactions.
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2016-10-18 19:37:55 +01:00
Jack Grigg 3774c944f8
Refactor test code to better test JSDescription::Randomized() 2016-10-18 12:44:56 -05:00
Jack Grigg 7f0aa74666
Implement static method for creating a randomized JSDescription 2016-10-18 10:41:00 -05:00
zkbot 3fceaca3a1 Auto merge of #1506 - bitcartel:master_1478_fix_testnet3_test_issue, r=bitcartel
Stop some wallet tests creating ~/.zcash/testnet3 folder by setting -datadir environment

Closes #1478
2016-10-14 17:03:11 -04:00
Simon 6be367ea6d Fix test so that the encrypted wallet is output to the test_bitcoin -datadir folder. 2016-10-14 12:44:22 -07:00
zkbot 8eb672251b Auto merge of #1513 - bitcartel:master_1491_fix_help_message_rpc_z_importkey, r=daira
Fixes #1491 by updating help message for rpc call z_importkey
2016-10-13 19:05:08 -04:00
Simon 5bd677f5c6 Rename client identifier from Satoshi to MagicBean (closes #1481) 2016-10-12 10:50:05 -07:00
Simon e346a0b3f8 Add tests to verify that all z_* rpc calls return an error if there are too many input parameters. 2016-10-12 10:15:12 -07:00
Jack Grigg b6f100cf86
Update tests for account deprecation 2016-10-10 10:47:30 -05:00
zkbot b4526f4d22 Auto merge of #1458 - str4d:1386-remove-findanddelete-and-codeseparator, r=ageis
Remove FindAndDelete and disable OP_CODESEPARATOR

Closes #1386
2016-10-04 21:51:29 -04:00
zkbot 1f4515a8c0 Auto merge of #1477 - zcash:812.change-address-prefixes.0, r=str4d
Update address prefixes

Closes #812 and #1450
2016-10-04 18:59:20 -04:00
Daira Hopwood 9418345fe6 Repair bitcoin-util-test.
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2016-10-04 22:56:33 +01:00
Jack Grigg f92f004714 Fix zkey test 2016-10-04 11:05:57 -07:00
zkbot 4cfbe798bf Auto merge of #1429 - str4d:867-update-dependencies, r=str4d
Update all dependencies

Also re-enables disabled compiler warnings.

Closes #867, #944, #1241, #1255, #1348.
2016-10-04 03:48:42 -04:00
Jack Grigg ee64b5e726 Re-encode hard-coded addresses in tests 2016-10-03 23:53:14 -07:00
Daira Hopwood fbad4cac24 Reencode keys in JSON test data. refs #812
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2016-10-03 23:53:14 -07:00
Jack Grigg a4f2555b35 Mark previously-valid test data as invalid 2016-10-03 20:09:18 -07:00
zkbot efe18f2e9b Auto merge of #1374 - str4d:1106-alert-safe-mode, r=str4d
Enable high-priority alerts to put the RPC into safe mode

This reverts the changes in 986b5e257e and adds a priority check.

Continuation of #1337
Closes #1106
2016-10-03 17:36:59 -04:00
zkbot fa632c1c91 Auto merge of #1468 - str4d:1138-change-versioning-scheme, r=str4d
Change versioning scheme

Closes #1138
2016-10-02 19:29:38 -04:00
Daira Hopwood 0fafbd5d0a Repair FormatSubVersion tests. refs #1138
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2016-10-02 16:44:56 +01:00
Simon 2d6e97ecc5 Add field fMinerTestModeForFoundersRewardScript to chainparams 2016-09-30 18:31:51 -07:00
Jack Grigg 7f01e437a6 Remove OP_CODESEPARATOR from tests 2016-10-01 01:17:32 +13:00
Simon 82bd9ee81b Fix comment and formatting per review 2016-09-29 22:07:38 -07:00
Jack Grigg 6567a7b534 Add tests for alerts enabling RPC safe mode 2016-09-30 17:47:28 +13:00
Simon 73699ceaf6 Add support for spending keys to the encrypted wallet. 2016-09-29 20:17:30 -07:00
Jack Grigg 017abaf694 Assert that new OpenSSL allocators succeed 2016-09-29 17:58:29 +13:00
Jack Grigg fa318aa9fe Upgrade OpenSSL to 1.1.0b
Closes #1348
2016-09-29 12:34:09 +13:00
Daira Hopwood 05e2db116d Remove FindAndDelete. refs #1386
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2016-09-27 00:48:30 +01:00
Simon da5e7e5185 Formatting and updated test per review. 2016-09-08 21:46:15 -07:00
Simon e883ffef91 Add test for calling RPC z_getbalance, z_gettotalbalance, z_listreceivedbyaddress with invalid parameters. 2016-09-08 21:46:15 -07:00
Simon 7b79275eba Add tests to try and improve coverage of perform_joinsplit. 2016-09-08 21:46:14 -07:00
Simon cff6f0ac46 Add friend class for testing private members of AsyncRPCOperation_sendmany. 2016-09-08 21:46:14 -07:00
Simon fc4b127ed3 Add tests for async queue and rpc commands: z_getoperationstatus, z_getoperationresult, z_listoperationids, z_sendmany 2016-09-08 21:46:14 -07:00
Simon b922924d14 Add test for AsyncRPCQueue and AsyncRPCOperation. 2016-09-08 21:46:14 -07:00
zkbot 2271d3feda Auto merge of #1338 - str4d:147-tweak-difficulty-adjustment-algorithm, r=ebfull
Tweaks to difficulty adjustment algorithm

This PR changes the difficulty algorithm to adjust from the average difficulty over the
block window instead of from the last difficulty. It also removes the special rules for the
testnet, which are incompatible with difficulty averaging.

Closes #147 again.
2016-09-08 02:21:13 +00:00
Jack Grigg 4b37cfd5b8 Remove unnecessary method 2016-09-08 12:22:08 +12:00
Simon 805344dcf4 Refactor: replace calls to GetTxid() with GetHash() 2016-09-07 15:12:09 -07:00
Simon a64f681f2c Remove #1144 from input data of script_tests.
Revert script_invalid.json to commit df1609f.
Revert script_valid.json to commit 1c54757.
2016-09-07 15:12:09 -07:00
Simon 5316bd3560 Remove #1144 from bloom_tests by reverting to commit 5012190. 2016-09-07 15:12:09 -07:00
Sean Bowe a4b00373ab Fix transaction test in test_bitcoin. 2016-09-07 13:55:31 -06:00
Jack Grigg 4a749674a8 Update tests for new genesis blocks 2016-09-07 21:05:12 +12:00
Jack Grigg 8f3ec042af Expand bounds on difficulty adjustment 2016-09-06 13:13:23 +12:00
Jack Grigg cb708a99a5 Add comments explaining changed semantics of pow_tests 2016-09-06 11:33:59 +12:00
zkbot 485ace0a1b Auto merge of #1311 - ebfull:cleanup-pp, r=ebfull
Deallocate the public parameters during Shutdown.

This also has it deallocated in `GenerateParams` and `test_bitcoin`. The virtual destructor probably isn't necessary but I added it just in case we need it some other time.
2016-09-02 03:03:45 +00:00
Simon 5d50130bc9 Closes #1315. RPC getblocksubsidy height parameter is now optional and
a test has been added to verify parameter input and results.
2016-08-30 15:11:07 -07:00
Sean Bowe 7ee82c4361 Deallocate the public parameters during Shutdown. 2016-08-26 16:55:43 -06:00
Simon 4b2e557181 Fix comments. 2016-08-24 11:19:34 -07:00
Simon badb9a9c2f Add test coverage for RPC call z_getnewaddress. 2016-08-24 11:19:34 -07:00
Simon 60f762a549 Added wallet rpc tests to cover:
z_importwallet, z_exportwallet
z_importkey, z_exportkey
z_listaddresses
2016-08-24 11:19:34 -07:00
zkbot cd9d373987 Auto merge of #1260 - str4d:1175-byte-array-manipulation, r=ebfull
Update Equihash implementation to match the Zcash spec

Closes #1175
2016-08-24 03:01:13 +00:00
Sean Bowe f0dab51cf3 Implement zkSNARK compression. 2016-08-22 00:36:12 -06:00
zkbot 365845216b Auto merge of #1268 - ThisIsNotOfficialCodeItsJustForks:t1130-upgrade-libsodium, r=ebfull
Upgrade libsodium for AVX2-detection bugfix.

Upgrades libsodium to bring in an AVX2-detection bugfix (to help with #1130).
2016-08-22 02:34:30 +00:00
Taylor Hornby 2902ac7ce8 Use libsodium's s < L check, instead checking that libsodium checks that. 2016-08-18 16:38:20 -06:00
Jack Grigg 5be6abbf84 Store the Equihash solution in minimal representation in the block header
The genesis blocks and miner tests have been regenerated, because changing the
block header serialisation format changes the block hash, and thus validity.

The Equihash solutions have been removed from the bloom test inputs for
simplicity (block validity is not checked there; only a valid serialisation is
necessary).
2016-08-16 16:02:39 +12:00
Jack Grigg caa0348f04 Update Equihash hash generation to match the Zcash spec
Changes:

- floor(512/n)*n/8 bytes of BLAKE2b output is split between floor(512/n)
  adjacent indices, instead of using one hash call per index.

- Parameters with n/(k+1) mod 8 != 0 will expand the BLAKE2b output to byte
  boundaries for colliding, instead of using a longer output and clearing bits.

- The genesis blocks have been regenerated.

- The test vectors have been regenerated.

- The Equihash inputs for the cancellation tests were modified to ensure that
  valid solutions were available to exercise the full solver.
2016-08-16 11:02:04 +12:00
Sean Bowe f5e5707d4c Change memo field size and relocate `ciphertexts` field of JoinSplit description. 2016-08-15 09:39:14 -06:00
Jack Grigg a23507d086 Update tests to account for new Equihash parameters 2016-08-06 17:33:23 +12:00
zkbot 95277e0311 Auto merge of #1144 - bitcartel:zc.v0.11.2.z7_tx_malleability_gettxid, r=bitcartel
A fix for transaction malleability

This PR fixes transaction malleability by not including the sigscript of transaction inputs and joinsplit sigs when hashing the txid.

This PR supercedes PR #1101 which was a minimal solution based on a new serialization flag.

This PR introduces GetTxid() to distinguish between getting a transaction id and the double sha256 hash.

The key changes are:
- Adding GetTxid() method to CTransaction which makes a copy of the transaction, clearing out the sigscript and joinsplitsig fields, before hashing.
- Verifying that every call to GetHash() actually wants a txid, and replacing with GetTxid().
- Renaming GetHash() to GetSerializeHash()
  - Rationale: In future, upstream code we want to merge will use GetHash() but we don't know the intent.  We should check to see if the intent is to receive a txid (most likely) in which case we replace with GetTxid(), or if upstream actually wants a double hash of the transaction we can use GetSerializeHash().
- Updated genesis data in chainparams.cpp

Note that coinbase transactions are excluded as they need the sigscript hashed to help avoid duplicate txids per BIP34:
  - This modification is related to a question from @ebfull on PR #1101 - "Can we think of a way this change allows us to construct two transactions with the same txid which can simultaneously appear in the blockchain? My guess is it would be possible to construct a coinbase transaction of such a form... this surely breaks invariants."

This PR Passes all tests in test_bitcoin (test data was updated in bloom_tests, miner_tests and script_tests).
2016-08-05 19:31:52 +00:00
Simon 0ccb650b5a Update genesis block hashes and test data. 2016-07-27 00:55:48 -07:00
Simon 2481bab2b8 Revert "Set nLockTime in CreateNewBlock() so coinbase txs do not have the same txid."
This reverts commit 29306269f4.
2016-07-27 00:41:26 -07:00
Jack Grigg 51eb5273f5 Equihash: Pass each obtained solution to a callback for immediate checking
Closes #1143
2016-07-27 19:15:49 +12:00
Simon 29306269f4 Set nLockTime in CreateNewBlock() so coinbase txs do not have the same txid.
Update test data in miner_tests.
2016-07-26 17:13:03 -07:00
Simon 10d2c57c0d Replace calls to GetHash() with GetTxid() for transaction objects.
Where the caller intends to receive a transaction id and not a double
SHA256 hash.
2016-07-26 17:13:03 -07:00
Simon 3574c9251f Updated test data for script_tests by uncommenting UPDATE_JSON_TESTS flag. 2016-07-26 17:09:27 -07:00
Simon b742003ee9 Update block and tx data used in bloom filter tests. 2016-07-26 17:09:27 -07:00
Simon 2b9130cd1f Update precomputed equihash solutions used in test. 2016-07-26 17:09:27 -07:00
Jack Grigg 2dbabb1159 Make Equihash solvers cancellable
The miner only cancels the solver when chainActive.Tip() changes.

Closes #1055
2016-07-20 19:17:02 +12:00
zkbot e117ff7651 Auto merge of #1048 - str4d:collect-all-valid-equihash-solns, r=ebfull
Collect all permutations of final solutions

This fixes a small bug where if there was a three-way (or more) collision in the final step, one or more valid solutions would be left out.
2016-07-20 03:54:30 +00:00
Taylor Hornby 838e3c753f Fix the tests that the SIGHASH_SINGLE bugfix breaks. 2016-07-19 16:36:37 -06:00
Taylor Hornby 67f0243533 Remove in-band error signalling from SignatureHash, fixing the SIGHASH_SINGLE bug. 2016-07-19 16:36:35 -06:00
Jack Grigg c6365f4d80 Add test case that requires the fix 2016-07-19 23:33:28 +12:00
zkbot d20d866d89 Auto merge of #1105 - bitcartel:zc.v0.11.2.z6_issue_424, r=ebfull
New private/public key pairs for broadcasting alert messages

Implements #424

Fixes and integrates method of sending alerts as described by upstream here:
- https://gist.github.com/laanwj/0e689cfa37b52bcbbb44

To send an alert:
- Copy private keys into alertkeys.h.
- Modify alert parameters and message found in sendalert.cpp
- Build and run to send the alert e.g. ./zcashd -printtoconsole -sendalert

Tested and verified with local nodes on alpha 6 testnet.
2016-07-18 21:09:46 +00:00
Sean Bowe 22de160219 Fixes for indentation and local variable names. 2016-07-18 10:07:29 -06:00
Sean Bowe 28173cd0de Remove more usage of `serial`. 2016-07-18 10:06:18 -06:00
Sean Bowe 9e511dbbdd Rename CSerialsCacheEntry. 2016-07-18 10:06:18 -06:00
Sean Bowe 1d184d53e1 Rename cacheSerials to cacheNullifiers and fix tests. 2016-07-18 10:06:18 -06:00
Sean Bowe b7e4abd6f7 Rename some usage of 'pour'. 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 d90e46ba8d Renaming SetSerial to SetNullifier. 2016-07-18 10:06:18 -06:00
Sean Bowe 616f8d05af Rename GetSerial to GetNullifier. 2016-07-18 10:06:18 -06:00
Sean Bowe ee964faf3d Rename HavePourRequirements to HaveJoinSplitRequirements. 2016-07-18 10:06:18 -06:00
Sean Bowe bfeaf0049a Rename JSDescription's `serials` to `nullifiers`. 2016-07-18 10:06:18 -06:00
Sean Bowe 8675d94b63 Rename vpour to vjoinsplit. 2016-07-18 10:06:18 -06:00
Sean Bowe a8c68ffe99 Rename CPourTx to JSDescription. 2016-07-18 10:06:18 -06:00
Simon 939aaeb620 New alert test data generated for new alert key pair.
Added test fixture to create new test data.
Added instructions for developer.
2016-07-17 12:36:26 -07:00
zkbot fc127fc2db Auto merge of #1051 - ThisIsNotOfficialCodeItsJustForks:t863-mock-coverage-of-checktransaction, r=ebfull
Add mock test coverage of CheckTransaction

Closes #863.
2016-07-14 18:43:07 +00:00
Taylor Hornby c9c4611d9a Rename zerocash to zcash in some places. 2016-07-11 19:27:52 -06:00
zkbot 6caacc892e Auto merge of #1058 - ebfull:coin-cache, r=ebfull
Flush to disk more consistently by accounting memory usage of serials/anchors in cache.

Closes #626.

It's important that this at least *approximates* the memory usage, so that we flush the cache to disk as expected. It's okay that we overestimate. The serials are stored in keys in the `boost::unordered_map`, so we can simply use that map's `DynamicMemoryUsage`. The anchors are another story.
2016-07-11 17:23:19 +00:00
Sean Bowe ffcd1c57cc Update tests with cache usage computations 2016-07-10 20:53:33 -06:00
Sean Bowe 3cb927661e Remove the mainnet checkpoints. 2016-06-29 14:21:03 -06:00
Taylor Hornby 948d4e6c10 Split JoinSplit proof verification out of CheckTransaction. 2016-06-23 16:35:31 -06:00
zkbot 62a2d12672 Auto merge of #1026 - ebfull:address-serialization, r=ebfull
Zcash address encoding

We need to encode Zcash addresses so they aren't as large and unweildy. We're using Base58Check just like upstream does, and to ensure the first character is "z" in our addresses we must use two bytes for the version string. Two bytes gives us an extra character for free, so this PR targets the beginning of addresses to have "zc".

```
$ ./src/zcash-cli zcrawkeygen
{
    "zcaddress" : "tnvaj4ZbZG83tj4RwZcFeLgJoSt8nw1ZvSCG8EMyowAsXTQgJPat77Y43BVdVCrwrbLy7GG9msJDYdn5hmreHmkXAkX17hb",
    "zcsecretkey" : "SKzkxCRWvscKnroSFyhCqhY332KcDMH4LLNdK2TsSvbmr3CGAB8B",
    "zcviewingkey" : "10aa74046f31cbe5eaa8965d1e104853234c3d6c6e45f9c497ca3a025d159755"
}
```

This PR also encodes the spending keys with a prefix that targets "SK". The spec needs to be updated with these changes.

Testnet addresses will start with "tn".

Closes #572
2016-06-16 18:52:30 +00:00
zkbot 1178df0883 Auto merge of #1004 - str4d:931-difficulty-algorithm, r=ebfull
Implement new difficulty algorithm

Closes #931. Closes #696.
2016-06-15 23:26:49 +00:00
Jack Grigg 5e207f4ea5 Improve comments per review 2016-06-16 10:45:19 +12:00
Sean Bowe f0ae0b11fe Add test to ensure spending keys always encode with 'SK' at beginning. 2016-06-15 16:25:21 -06:00
Sean Bowe 0d6864e465 Added encoding for Zcash spending keys. 2016-06-15 16:03:57 -06:00
Sean Bowe 83ee1903fc Add tests for `CZCPaymentAddress`. 2016-06-15 15:06:07 -06:00
zkbot 6793168a2e Auto merge of #1017 - ebfull:coinbase-must-be-protected, r=ebfull
Enforce that coinbases must be protected

This PR forces miners to place their funds in the private value transfer system, making "transparent coins" opt-in for users, and increasing privacy for all participants on a systemic level.

Closes #101.
2016-06-15 03:06:23 +00:00
Jack Grigg 284e125957 Update tests for new difficulty algorithm 2016-06-15 13:44:27 +12:00
Sean Bowe d212ba320b Disable enforced coinbase protection in miner_tests. 2016-06-14 15:18:52 -06:00
Sean Bowe 542da618df Enforce remaining softfork activation rules unconditionally. 2016-06-14 12:34:38 -06:00
Sean Bowe c0dde76d8a Disable coinbase-must-be-protected rule on regtest. 2016-06-13 12:23:55 -06:00
Sean Bowe 1d38795f50 Prevent coinbases from being spent to transparent outputs. 2016-06-13 11:58:10 -06:00
Jack Grigg f3aee6b109 Update miner tests for platform-independent Equihash 2016-06-12 00:00:26 +12:00
Jack Grigg a6dcf2ee6f Use little-endian for hash personalisation and hashing indices
The test vectors have been regenerated using the basic solver.
2016-06-11 16:28:57 +12:00
Jack Grigg 1dd8ce9ba5 Update tests to account for new Equihash parameters 2016-06-11 15:45:55 +12:00
Jack Grigg 3fe29eab90 Fix failing tests 2016-06-10 16:16:33 +12:00
Jack Grigg a59c352cfd Update tests to account for decreased block interval 2016-06-10 12:02:47 +12:00
zkbot 6ccd212218 Auto merge of #973 - ebfull:chained-pours, r=ebfull
Add chained `JoinSplit`s

Closes #555
2016-06-08 15:23:57 +00:00
Sean Bowe ecd8ca5dbe Minor changes to coins_tests. 2016-06-08 09:15:44 -06:00
Sean Bowe 49ab032b5f Add test to ensure parent treestates only can appear earlier in the transaction or in the global state, not later. 2016-06-07 21:05:25 -06:00
Jack Grigg 50121909aa Update tests to account for reserved field 2016-06-07 22:45:41 +12:00
zkbot d0cc00207b Auto merge of #929 - bitcartel:zc.v0.11.2.z2_fix_717, r=ebfull
Fix issue #717 t

Fix issue #717 where if addrman is starved of addresses (e.g. on testnet)
the Select_() function will loop endlessly trying to find an address,
and therefore eat up 100% cpu time on the 'opencon' thread.

Solution is to (1) add a delay to the loop and (2) restrict the number
of attempts to find an address.  On exiting the loop, we return
to an outer loop in net.cpp which will sleep, add seed nodes and
calculate new addresses.
2016-06-06 20:03:16 +00:00
zkbot 55bf149df9 Auto merge of #921 - str4d:optimised-equihash, r=daira
Optimise memory usage of Equihash implementation

Part of #857.
2016-06-01 13:10:26 +00:00
Sean Bowe 10c33f0f87 Test behavior of chained pour consensus rules. 2016-05-30 22:46:44 -06:00
Sean Bowe 8048f4c048 Ensure merkle tree fixed point removal is tested against inside coins_tests. 2016-05-30 22:46:44 -06:00
Sean Bowe 14b12fde2b Move new coins tests to within coins_tests test suite. 2016-05-30 22:46:44 -06:00
zkbot 19769ba6c5 Auto merge of #976 - ebfull:implement-joinsplit-signatures, r=ebfull
Signing pours with ed25519

This is an alternative to #964 which uses ed25519 instead of secp256k1, and avoids the separate hash for fitting the public key into the `h_sig` block. It's based on @defuse's work in that branch.

Closes #808.
2016-05-31 03:46:30 +00:00
Sean Bowe 7c68cc0747 Add additional assertions. 2016-05-30 21:38:44 -06:00
Sean Bowe e8af0028eb Change error for invalid joinsplit signature for consistency. 2016-05-30 19:38:01 -06:00
Sean Bowe 320f2cc7e0 Switch to Ed25519 for cryptographic binding of joinsplits to transactions. 2016-05-30 11:05:55 -06:00
Taylor Hornby b48122b57b Fix tests for JoinSplit signatures 2016-05-30 11:05:43 -06:00
zkbot b1f699660f Auto merge of #887 - str4d:mining-slow-start, r=ebfull
Implement mining slow start

Closes #762.
2016-05-27 02:15:24 +00:00
Ethan Heilman 1bf2cb1a06 Increase test coverage for addrman and addrinfo
Adds several unittests for CAddrMan and CAddrInfo.
Increases the accuracy of addrman tests.
Removes non-determinism in tests by overriding the random number generator.
Extracts testing code from addrman class to test class.

Signed-off-by: Simon <simon@bitcartel.com>
2016-05-24 12:55:33 -07:00
EthanHeilman 8375e1a3e7 Creates unittests for addrman, makes addrman testable.
Adds several unittests for addrman to verify it works as expected.
Makes small modifications to addrman to allow deterministic and targeted tests.

Signed-off-by: Simon <simon@bitcartel.com>
2016-05-24 11:10:54 -07:00
Sean Bowe 6b5d608899 Update proving key and tests that depend on transaction structure changes 2016-05-24 11:09:17 -06:00
Sean Bowe 9285bba885 Enable binary serializations of proofs and r1cs keys, and make the `CPourTx` proof field fixed-size. 2016-05-24 11:08:31 -06:00
Jack Grigg e95747288a Use template parameters to statically initialise Equihash 2016-05-24 23:16:50 +12:00
Jack Grigg c92c1f6050 Implement index-truncation Equihash optimisation 2016-05-24 12:02:46 +12:00
Jack Grigg a3361e778b Refactor StepRow to make optimisation easier 2016-05-24 12:02:08 +12:00
Taylor Hornby 7c1ccd9006 Remove unused code in libzerocash util.cpp 2016-05-18 11:22:29 -06:00
Taylor Hornby e857a0cd1f Fix build warnings in sighash tests. 2016-05-18 11:22:29 -06:00
Taylor Hornby bf2e3122ac Remove the Merkle tree hash function's fixed point. 2016-05-16 20:20:36 -06:00
Sean Bowe 2dc3599271 Transplant of libzcash. 2016-05-12 16:44:47 -06:00
Sean Bowe 2140639309 Remove scriptPubKey/scriptSig from CPourTx, and add randomSeed. 2016-05-12 16:44:30 -06:00
Jack Grigg 442eff615b Fix failing miner test 2016-05-12 00:01:24 +12:00
Jack Grigg 4f4a8c3c88 Update miner tests to account for mining slow start 2016-05-10 23:03:23 +12:00
Jack Grigg 91818cf28c Update subsidy tests to account for mining slow start 2016-05-10 23:03:23 +12:00
Sean Bowe 5961dcb6da Change ciphertext length to match protocol spec, and refactor the use of constants. 2016-05-05 21:02:03 -06:00
zkbot 92f3c6082a Auto merge of #889 - ebfull:new-imt-redux, r=ebfull
Implement and integrate new Incremental Merkle Tree

This supersedes #823.

----

This is an implementation of a new incremental merkle tree with

* no memory safety issues
* a more sensible internal design
* better space efficiency (tree representation, witnessing)
* simpler API

It is intended that this tracks the behavior of the previous tree, which it does, as verified by tests. I even wrote a little circuit for testing that all the paths work.

This PR also integrates the tree into the codebase and deprecates the old tree in almost all of our code. (I left it alone in `zerocashTest` but everything else has been changed.)

This change is compatible with the testnet but you will need to clear your *local* blockchain data out since the serialized representation of the merkle tree is now different.

Closes #517, Closes #519, Closes #591, Closes #460, Closes #473
2016-05-03 17:33:27 +00:00
Sean Bowe 57f118176f Move NoteEncryption tests to gtest suite. 2016-04-28 16:25:14 -06:00
Sean Bowe 6c36a9fe03 NoteEncryption implementation and integration, removal of ECIES and crypto++ dependencies. 2016-04-28 16:25:12 -06:00
Sean Bowe 6850b45e4d Move incremental merkle tree tests to zcash-gtest. 2016-04-28 16:10:21 -06:00
Sean Bowe d0c4b0e850 Add more well-formedness checks/tests to tree. 2016-04-28 16:07:52 -06:00
Sean Bowe 01e4ff0f74 Improve well-formedness checks and add additional serialization/deserialization tests. 2016-04-28 16:07:52 -06:00
Sean Bowe 6d71658673 Initialize curve/field parameters in case another test hasn't done so. 2016-04-28 16:07:52 -06:00
Sean Bowe 1760b3cd88 Deprecate the old tree and remove old tree tests from the test suite. 2016-04-28 16:07:52 -06:00
Sean Bowe 482aefbd0d Test old tree along with new tree as much as possible. 2016-04-28 16:07:52 -06:00
Sean Bowe 434f328446 Integrate new incremental merkle tree implementation into consensus. 2016-04-28 16:07:52 -06:00
Sean Bowe e1ff849d8d New implementation of incremental merkle tree
This is a new implementation of the incremental merkle tree used by our
scheme to witness commitments to spendable value. It serves as a fixed-sized
accumulator.

This new construction has a much simpler API surface area, avoids memory
safety issues, remains pruned at all times, avoids serialization edge cases,
has more efficient insertion, and is abstract over the depth and hash
function used at the type level.

Further, it lays the groundwork for efficient "fast-forwarding" of witnesses
into the tree as the treestate is updated.
2016-04-28 16:07:52 -06:00
Sean Bowe 291b191bd7 Add serialization for primitive boost::optional<T>. 2016-04-28 16:07:52 -06:00
Taylor Hornby 3098bab6d6 Fix sighash tests 2016-04-28 09:44:12 -06:00
Sean Bowe f3ffa3d27f Implementation of Founders' Reward.
All blocks before the first subsidy halving block, with the exception of
the genesis block, must contain an output which sends 20% of the block
subsidy value to a scriptPubKey `FOUNDERS_REWARD_SCRIPT`.
2016-04-08 14:40:28 -06:00
Jack Grigg aa86873afd Fix pow_tests to work with Equihash
Changing the order of difficulty calculation operations to divide first doesn't
affect the result significantly, but ensures we never overflow the arith_uint256
during multiplication and get an artificial jump in difficulty.
2016-04-08 23:19:03 +12:00
Sean Bowe e22df48519 Fix miner_tests to work with equihash 2016-04-08 22:16:29 +12:00
Jack Grigg cf00c47d5b Fix tests that depend on old block header format
Changes to bloom tests were done by running the following commands:

sed -i 's/\(CDataStream stream(ParseHex(".\{152\}\)\(.\{8\}\)/\100000000000000000000000000000000000000000000000000000000\200/' src/test/bloom_tests.cpp
sed -i 's/\(vector<unsigned char> vch = ParseHex(".\{152\}\)\(.\{8\}\)/\100000000000000000000000000000000000000000000000000000000\200/' src/test/bloom_tests.cpp

and then reverting the single change to the transaction line.
2016-04-08 14:50:56 +12: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
Jack Grigg 020bed6021 Add test vectors for Equihash 2016-04-08 13:56:00 +12:00
Sean Bowe 27a109af01 Improve testing and API of CSHA256 compression. 2016-03-31 16:15:07 -06:00
Sean Bowe 8466467a35 Added SHA256Compress to Bitcoin's SHA256 implementation. 2016-03-31 14:23:56 -06:00
Sean Bowe 6806256b80 Initialize libsodium and remove openssl headers from util.cpp 2016-03-23 16:26:57 -06:00
Sean Bowe a897db652f Reorganizing the zerocash tree. 2016-02-15 15:28:20 -07:00
Nathan Wilcox 8cb250885c Replace magic 2s in rpcwallet and change > to != for arity checks. Replace magic 2's with named constants in test cases. 2016-01-19 14:36:18 -07:00
Sean Bowe cf47198370 Fixed a couple incremental merkle tree bugs breaking consistency checks. 2016-01-19 14:36:10 -07:00
Sean Bowe 03bff15fe2 Enforce zk-SNARK validity during consensus. 2016-01-19 14:36:09 -07:00
Sean Bowe 4f1c37980e Load proving/verifying keys at startup from the public alpha parameters file. 2016-01-19 14:36:04 -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
Sean Bowe 96c31d163f Added CPourTx verification and construction routines. 2016-01-19 14:36:04 -07:00
Sean Bowe 69761d8269 Primitive, context-free consensus changes for CPourTx
* PourTxs cannot appear in coinbase transactions.
* Transactions can only contain empty vin/vouts if they contain a PourTx.
* PourTx public values must be well-formed (not negative or too large).
* Transactions cannot have the same serial twice throughout all PourTxs.
2016-01-19 14:36:04 -07:00
Sean Bowe 5884044ba9 Introduce `vpour` to `CTransaction`.
Transactions of version 2 and above contain a `vpour` field which is a vector of `CPourTx`
objects that embody our protocol. We introduce serialization primitives for boost::array
(we intend for changing the amount of inputs and outputs in the circuit to be simple).

SIGHASH_* operations hash this field like any other for now.
2016-01-19 14:35:59 -07:00
Wladimir J. van der Laan 6c31ac019f
Merge pull request #6825
af6edac *: alias -h for --help (Daniel Cousens)
131d7f9 Change URLs to https in debian/control (Matt Corallo)
7ce2c91 Update debian/changelog and slight tweak to debian/control (Matt Corallo)
4fbfebe Correct spelling mistakes in doc folder (Mitchell Cash)
e42bf16 Clarification of unit test build instructions. (Eric Lombrozo)
54f9dee Update bluematt-key, the old one is long-since revoked (Matt Corallo)
bfc6154 [Trivial] Fixed typo when referring to a previous section in depends/README.md [skip ci] (Chris Kleeschulte)
9e45157 build: disable -Wself-assign (Wladimir J. van der Laan)
33d6825 Bugfix: Allow mining on top of old tip blocks for testnet (fixes testnet-in-a-box use case) (Luke Dashjr)
87a797a build: Remove dependency of bitcoin-cli on secp256k1 (Wladimir J. van der Laan)
a33cd5b [trivial] Fix rpc message "help generate" (MarcoFalke)
6fd0019 Drop "with minimal dependencies" from description (Zak Wilcox)
2394f4d Split bitcoin-tx into its own package (Zak Wilcox)
1e672ae Include bitcoin-tx binary on Debian/Ubuntu (Zak Wilcox)
b3eaa30 [Qt] Raise debug window when requested (MarcoFalke)
01878c9 Fix locking in GetTransaction. (Alex Morcos)
9b9acc2 Fix spelling of Qt (Diego Viola)
2015-11-06 14:08:06 +01:00
Mark Friedenbach f720c5fc9f
Enable policy enforcing GetMedianTimePast as the end point of lock-time constraints
Transactions are not allowed in the memory pool or selected for inclusion in a block until their lock times exceed chainActive.Tip()->GetMedianTimePast(). However blocks including transactions which are only mature under the old rules are still accepted; this is *not* the soft-fork required to actually rely on the new constraint in production.
2015-10-23 21:33:51 +01:00
Wladimir J. van der Laan fc7f0ee28c
Merge pull request #6707
6af25b0 Add BIP65 to getblockchaininfo softforks list (Peter Todd)
ba1da90 Show softfork status in getblockchaininfo (Wladimir J. van der Laan)
70a427b CLTV: Add more tests to improve coverage (Esteban Ordano)
c5a27f4 Add RPC tests for the CHECKLOCKTIMEVERIFY (BIP65) soft-fork (Peter Todd)
5e82e1c Add CHECKLOCKTIMEVERIFY (BIP65) soft-fork logic (Peter Todd)
6ea5ca4 Enable CHECKLOCKTIMEVERIFY as a standard script verify flag (Peter Todd)
4fa7a04 Replace NOP2 with CHECKLOCKTIMEVERIFY (BIP65) (Peter Todd)
6ec08db Move LOCKTIME_THRESHOLD to src/script/script.h (Peter Todd)
684636b Make CScriptNum() take nMaxNumSize as an argument (Peter Todd)
2015-10-23 13:35:06 +02:00
Eric Lombrozo e42bf16ae0 Clarification of unit test build instructions. 2015-10-14 08:21:55 +00:00
Wladimir J. van der Laan e7bcc4aac3
Bump minrelaytxfee default
To bridge the time until a dynamic method for determining this fee is
merged.

This is especially aimed at the stable releases (0.10, 0.11) because
full mempool limiting, as will be in 0.12, is too invasive and risky to
backport.

Github-Pull: #6793
Rebased-From: 28e3249e53b8ef7516636df0f1406466a513095d 4e2efb3c5fde4b1e332cc032e3dc4082ec4e3cac
2015-10-11 10:37:52 +02:00
Esteban Ordano 70a427b2b5 CLTV: Add more tests to improve coverage
Four cases included:

* The CLTV operand type mismatches the tx locktime. In the script it is
  1 (interpreted as block height), but in the tx is 500000000
  (interpreted as date)
* The stack is empty when executing OP_CLTV
* The tx is final by having only one input with MAX_INT sequence number
* The operand for CLTV is negative (after OP_0 OP_1 OP_SUB)

Rebased-From: cb54d17355864fa08826d6511a0d7692b21ef2c9
2015-10-08 17:49:00 +02:00
Peter Todd 4fa7a048d1 Replace NOP2 with CHECKLOCKTIMEVERIFY (BIP65)
<nLockTime> CHECKLOCKTIMEVERIFY -> <nLockTime>

Fails if tx.nLockTime < nLockTime, allowing the funds in a txout to be
locked until some block height or block time in the future is reached.

Only the logic and unittests are implemented; this commit does not have
any actual soft-fork logic in it.

Thanks to Pieter Wuille for rebase.

Credit goes to Gregory Maxwell for the suggestion of comparing the
argument against the transaction nLockTime rather than the current
time/blockheight directly.

Rebased-From: bc60b2b4b401f0adff5b8b9678903ff8feb5867b
2015-10-08 17:46:55 +02:00
Peter Todd 684636ba67 Make CScriptNum() take nMaxNumSize as an argument
While the existing numeric opcodes are all limited to 4-byte bignum
arguments, new opcodes will need different limits.

Rebased-From: 99088d60d8a7747c6d1a7fd5d8cd388be1b3e138
2015-10-08 17:46:55 +02:00
Pieter Wuille 6eed52e05b Only use randomly created nonces in CRollingBloomFilter.
(cherry picked from commit d741371d7d27e228aa64c618c50b23fb5449c3e1)
2015-10-02 12:17:49 +02:00
Peter Todd 83671efe99 Make CRollingBloomFilter set nTweak for you
While CBloomFilter is usually used with an explicitly set nTweak,
CRollingBloomFilter is only used internally. Requiring every caller to
set nTweak is error-prone and redundant; better to have the class handle
that for you with a high-quality randomness source.

Additionally when clearing the filter it makes sense to change nTweak as
well to recover from a bad setting, e.g. due to insufficient randomness
at initialization, so the clear() method is replaced by a reset() method
that sets a new, random, nTweak value.

(cherry picked from commit d2d7ee0e863b286e1c9f9c54659d494fb0a7712d)
2015-10-02 12:17:44 +02:00
Alex Morcos 1f6772e9f0 add unit test for CNetAddr::GetGroup. 2015-09-22 00:43:14 +00:00
Casey Rodarmor 6b51b9b195 Replace boost::reverse_lock with our own. 2015-09-22 00:43:13 +00:00
Casey Rodarmor f6d29a6ca8 Use unique name for AlertNotify tempfile 2015-09-22 00:43:12 +00:00
Gavin Andresen fce474c9df
Use best header chain timestamps to detect partitioning
The partition checking code was using chainActive timestamps
to detect partitioning; with headers-first syncing, it should use
(and with this pull request, does use) pIndexBestHeader timestamps.

Fixes issue #6251

Github-Pull: #6256
Rebased-From: 65b94545036ae6e38e79e9c7166a3ba1ddb83f66
2015-06-15 10:34:07 +02:00
Suhas Daftuar 304892fc03
Be stricter in processing unrequested blocks
AcceptBlock will no longer process an unrequested block, unless it has not
been previously processed and has more work than chainActive.Tip()

Github-Pull: #5875
Rebased-From: 9be0e6837b878f72bd087ce32b7a2f2ffb2fd544
2015-06-03 16:23:46 +02:00
Wladimir J. van der Laan 5901596548
json: fail read_string if string contains trailing garbage
Change `read_string` to fail when not the entire input has been
consumed. This avoids unexpected, even dangerous behavior (fixes #6223).

The new JSON parser adapted in #6121 also solves this problem so in
master this is a temporary fix, but should be backported to older releases.

Also adds tests for the new behavior.

Github-Pull: #6226
Rebased-From: 4e157fc60dae5ca69933ea4c1585a2a078b4d957
2015-06-03 15:16:37 +02:00
Peter Todd 75a4d512cf
Fix off-by-one error w/ nLockTime in the wallet
Previously due to an off-by-one error the wallet ignored
nLockTime-by-height transactions that would be valid in the next block
even though they are accepted into the mempool. The transactions
wouldn't show up until confirmed, nor would they be included in the
unconfirmed balance. Similar to the mempool behavior fix in 665bdd3b,
the wallet code was calling IsFinalTx() directly without taking into
account the fact that doing so tells you if the transaction could have
been mined in the *current* block, rather than the next block.

To fix this we strip IsFinalTx() of non-consensus-critical
functionality, removing the default arguments, and add CheckFinalTx() to
check if a transaction will be final in the next block.

Github-Pull: #6183
Rebased-From: 28bf06236d3b385e95fe26a7a742395b30efd6ee
2015-06-01 12:35:49 +02:00
Wladimir J. van der Laan c7c9af381c
Merge pull request #5669
da29ecb Consensus: MOVEONLY: Move CValidationState from main consensus/validation (jtimon)
27afcd8 Consensus: Refactor: Decouple CValidationState from main::AbortNode() (Cory Fields)
2015-05-27 15:00:02 +02:00
Wladimir J. van der Laan 182686cdbd
Merge pull request #6186
b45c50c Fix two problems in CSubNet parsing (Wladimir J. van der Laan)
19e8d7b Simplify code for CSubnet (Wladimir J. van der Laan)
2015-05-27 09:08:39 +02:00
Michael Ford 8697ff33ed Remove duplicate chainparams.h include from alert_tests 2015-05-26 17:16:21 +08:00
Wladimir J. van der Laan e9af4e65b5
Merge pull request #5947
36cba8f Alert if it is very likely we are getting a bad chain (Gavin Andresen)
2015-05-26 10:41:17 +02:00
Wladimir J. van der Laan b45c50ce51 Fix two problems in CSubNet parsing
Fix two CSubNet constructor problems:

- The use of `/x` where 8 does not divide x was broken, due to a
  bit-order issue

- The use of e.g. `1.2.3.4/24` where the netmasked bits in the network
  are not 0 was broken. Fix this by explicitly normalizing the netwok
  according to the bitmask.

Also add tests for these cases.

Fixes #6179. Thanks to @jonasschnelli for reporting and initial fix.
2015-05-26 08:59:59 +02:00