Commit Graph

1246 Commits

Author SHA1 Message Date
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
Homu
f62fff80d5 Auto merge of #3255 - str4d:sapling-value-pool, r=ebfull
Track net value entering and exiting the Sapling circuit
2018-05-16 10:46:32 -07:00
Eirik Ogilvie-Wigley
3182b4abc3 Add tests for sapling anchors 2018-05-16 10:31:53 -06:00
Homu
ae6c2587d3 Auto merge of #3232 - ebfull:3207-sapling-validation, r=str4d
Sapling validation

**Also review https://github.com/zcash/librustzcash/pull/7**

This is an attempt to tackle much of https://github.com/zcash/zcash/issues/3065
2018-05-10 10:21:15 -07:00
Jack Grigg
ae97177c86 Track net value entering and exiting the Sapling circuit 2018-05-09 16:02:23 -04:00
Jack Grigg
97b46f00cc Add valueBalance to value balances, and enforce its consensus rules 2018-05-09 11:34:41 +01:00
Sean Bowe
b4db32f53c Check Sapling Spend/Output proofs and signatures. 2018-05-08 14:30:26 -06:00
Sean Bowe
55fabd8272 Refactor so that dataToBeSigned can be used later in the function for other purposes. 2018-05-08 14:28:01 -06:00
Sean Bowe
6eea48bf96 Remove unnecessary IsCoinbase() check. Coinbases are guaranteed to have empty vjoinsplit. 2018-05-08 14:23:09 -06:00
Homu
333b9a0d0b Auto merge of #3170 - ebfull:sapling-merkle-tree, r=ebfull
Sapling merkle tree implementation

Closes #3056.

Please also review https://github.com/zcash/librustzcash/pull/8

This PR:

1. Introduces ZCSaplingIncrementalMerkleTree using Pedersen hashes.
2. Adds support for Sapling anchors into consensus rules. (Adds commitments, checks anchors are correct, handles block (dis)connects, etc.)
3. Handles mempool eviction for obsolete anchors.
4. Enforces correctness of block's Sapling root field
5. Changes miner to correctly apply the Sapling root to the block header
6. Handles mempool consistency checks for anchors
2018-05-07 20:37:46 -07:00
Sean Bowe
98d2f090ca Evict transactions with obsolete anchors from the mempool 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
c643ff0b51 Add support for PopAnchor(.., SPROUT/SAPLING) 2018-05-07 14:37:46 -06:00
Sean Bowe
e814be60fe Rename hashSproutAnchorEnd to hashFinalSproutRoot to be consistent. 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
2bd59e1473 Rename PushAnchor to PushSproutAnchor. 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
08f0728884 Rename hashAnchor to hashSproutAnchor. 2018-05-07 13:46:06 -06:00
Sean Bowe
28d20bdb11 Rename NullifierType to ShieldedType. 2018-05-07 13:46:06 -06:00
Homu
1d4235dce7 Auto merge of #3239 - str4d:sapling-default-tx-version, r=str4d
Update CreateNewContextualCMutableTransaction for Sapling

Part of #3063.
2018-05-07 12:27:47 -07:00
Homu
265eca3f47 Auto merge of #3212 - str4d:2864-sapling-tx-size-limit, r=str4d
Raise 100kB transaction size limit from Sapling activation

Closes #2864.
2018-05-07 02:20:42 -07:00
Homu
8ef1d333b5 Auto merge of #2894 - per-gron:dont-export-unless-needed, r=str4d
Make some globals static that can be

I wrote this patch as part of making a Bazel build system but it really is independent from that so I'm putting this as a separate PR.

External linkage does not help and just encourages sloppy dependencies (ie using symbols only declared in a cpp file in some other cpp file) and can lead to weird issues when there are name collisions.
2018-05-04 15:05:43 -07:00
Jack Grigg
25fee3509a Rename MAX_TX_SIZE to MAX_TX_SIZE_AFTER_SAPLING 2018-05-04 11:17:30 +01:00
Jack Grigg
15ec5525e3 Raise 100kB transaction size limit from Sapling activation
Closes #2864.
2018-05-04 11:17:30 +01:00
Jack Grigg
fa70084c87 Expire Overwinter transactions before the Sapling activation height 2018-05-03 12:27:56 +01:00
Jack Grigg
dc889d7f52 Update CreateNewContextualCMutableTransaction to create Sapling transactions 2018-05-03 12:02:51 +01:00
Homu
0a8d0c25e8 Auto merge of #3220 - Eirik0:3209-fix-CheckTransaction, r=str4d
Implement consensus rules about the number of Spend and Output Descriptions in a transaction

Closes #3209.
Part of #3065.
2018-05-01 07:09:52 -07:00
Marshall Gaucher
b300118002 Merge pull request #2813 from str4d/2074-uacomment
Implement uacomment config parameter
2018-04-30 09:12:38 -06:00
Eirik Ogilvie-Wigley
812098256f Coinbase transactions can not have shielded spend or output 2018-04-26 15:53:26 -06:00
Eirik Ogilvie-Wigley
4b4662b06d Make sure transactions have non-empty outputs 2018-04-26 15:24:59 -06:00
Sean Bowe
6679855147 Check that duplicate Sapling nullifiers don't exist within a transaction. 2018-04-25 17:10:34 -06: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
cab341e1a8 Add sapling nullifiers to db and mempool 2018-04-24 17:16:43 -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
b1608eed82 Add a constant for Overwinter's transaction version 2018-04-23 20:39:04 +01:00
Jack Grigg
72540cee4a Add Sapling v4 transactions to IsStandard 2018-04-19 16:25:04 +01:00
Jack Grigg
987b8ee60e Adjust consensus rules to require v4 transactions from Sapling activation 2018-04-19 05:01:47 +01:00
Jack Grigg
a8e5ae92ba GetSerializeSize changes in Zcash-specific code 2018-04-16 07:38:38 -06:00
Pieter Wuille
b8a6579366 Make GetSerializeSize a wrapper on top of CSizeComputer
Given that in default GetSerializeSize implementations created by
ADD_SERIALIZE_METHODS we're already using CSizeComputer(), get rid
of the specialized GetSerializeSize methods everywhere, and just use
CSizeComputer. This removes a lot of code which isn't actually used
anywhere.

For CCompactSize and CVarInt this actually removes a more efficient
size computing algorithm, which is brought back in a later commit.
2018-04-16 07:38:38 -06:00
Pavol Rusnak
2bc62dc4e3 limit total length of user agent comments
Reworked-By: Wladimir J. van der Laan <laanwj@gmail.com>
2018-04-13 07:40:34 -06:00
Jack Grigg
39ee63c876 When rewinding, reset pindexBestInvalid if it is pointing to a removed block 2018-04-11 21:46:58 -06:00
R E Broadley
4f31d82395 Allow filterclear messages for enabling TX relay only.
An example of where this might be useful is allowing a node to connect blocksonly during IBD but then becoming a full-node once caught up with the latest block. This might also even want to be the default behaviour since during IBD most TXs appear to be orphans, and are routinely dropped (for example when a node disconnects). Therefore, this can waste a lot of bandwidth.

Additionally, another pull could be written to stop relaying of TXs to nodes that are clearly far behind the latest block and are running a node that doesn't store many orphan TXs, such as recent versions of Bitcoin Core.
2018-04-05 01:30:38 +01:00
Jack Grigg
2b7fcab8fc Move bloom filter filtering logic back into command "switch" 2018-04-05 01:30:38 +01:00
Matt Corallo
1c82adeb87 Don't do mempool lookups for "mempool" command without a filter 2018-04-05 01:30:12 +01:00
Patick Strateman
f07ad43553 Add enforcenodebloom option.
Previously peers which implement a protocol version less than NO_BLOOM_VERSION
would not be disconnected for sending a filter command, regardless of the
peerbloomfilter option.

Many node operators do not wish to provide expensive bloom filtering for SPV
clients, previously they had to cherry pick the commit which enabled the
disconnect logic.

The default should remain false until a sufficient percent of SPV clients
have updated.
2018-04-05 01:30:12 +01:00
Patick Strateman
d06ae252a0 Move bloom filter filtering logic outside of command "switch" (giant if/else).
Moving this logic outside of the "switch" makes it far simpler to
enable the forced disconnect by a parameter.
2018-04-05 01:30:12 +01:00
Matt Corallo
8bc4461326 Add NODE_BLOOM service bit and bump protocol version
Lets nodes advertise that they offer bloom filter support explicitly.
The protocol version bump allows SPV nodes to assume that NODE_BLOOM is
set if NODE_NETWORK is set for pre-170004 nodes.

Also adds an option to turn bloom filter support off for nodes which
advertise a version number >= 170004. Nodes attempting to use bloom
filters on such protocol versions are banned, and a later upgade
should drop nodes of an older version which attempt to use bloom
filters.

Much code stolen from Peter Todd.

Zcash: Implements Zcash equivalent of BIP 111; deploys with Overwinter
2018-04-05 01:30:12 +01:00
Daira Hopwood
473a113241 Don't increase banscore if the transaction only just expired.
Author: Jack Grigg <str4d@z.cash>
2018-04-04 01:29:47 +01:00
Jay Graber
e4dff510b4 Set ban score for expired txs to 0 2018-04-03 23:50:43 +01:00