Zebra/zebra-consensus/src
Janito Vaqueiro Ferreira Filho 36d488edb4
Reject a mempool transaction if it has internal spend conflicts (#2843)
* Reorder imports to follow convention

Place the imports from `std` at the top.

* Add transaction errors for double spends

Add a variant for each pool. They represent a double spend inside a
transaction.

* Add `check::spend_conflicts` implementation

Checks if a transaction has spend conflicts, i.e., if a transaction
spends a UTXO more than once or if it reveals a nullifier more than
once.

* Reject transactions with internal spend conflicts

The transaction verifier should reject transactions that spend the same
transparent UTXO or that reveal the same nullifier.

* Add transparent spend consensus rule

Add it to the documentation to help with understanding and auditing it.

Co-authored-by: teor <teor@riseup.net>

* Use different nullifiers by default

Don't use the same nullifier twice when mocking a
`sprout::JoinSplitData` because it will lead to an invalid transaction.

* Test transactions with repeated spend outpoints

Since that represents a spend conflict, they should be rejected.

* Test duplicate nullifiers in joinsplit

Check if a mock transaction with a joinsplit that reveals the same
nullifier twice is rejected.

* Test duplicate nullifiers across joinsplits

Check if a duplicate nullifier in two different joinsplits in the same
transaction is rejected.

* Test V4 transaction with duplicate Sapling spend

Check if a V4 transaction that has a duplicate Sapling spend is
rejected.

* Test V5 transaction with duplicate Sapling spend

Check if a V5 transaction that has a duplicate Sapling spend is
rejected.

* Test V5 transaction with duplicate Orchard actions

Check if a V5 transaction that has duplicate Orchard actions is rejected
by the transaction verifier.

Co-authored-by: teor <teor@riseup.net>
2021-10-28 02:49:28 +00:00
..
block Fix or disable the new clippy::question_mark lint (#2946) 2021-10-25 19:34:34 +00:00
chain Return a transaction verifier from `zebra_consensus::init` (#2665) 2021-08-25 15:07:26 +00:00
checkpoint Add `zebra_state::init_test` helper function for tests (#2539) 2021-07-28 20:55:01 -03:00
parameters Replace smart quotes with ascii quotes 2021-03-15 03:18:10 -04:00
primitives Fix or disable recent nightly clippy lints (#2817) 2021-10-01 15:26:06 +00:00
transaction Reject a mempool transaction if it has internal spend conflicts (#2843) 2021-10-28 02:49:28 +00:00
block.rs Ignore AlreadyInChain error in the syncer (#2890) 2021-10-20 11:07:19 +10:00
chain.rs Return a transaction verifier from `zebra_consensus::init` (#2665) 2021-08-25 15:07:26 +00:00
checkpoint.rs Ignore AlreadyInChain error in the syncer (#2890) 2021-10-20 11:07:19 +10:00
config.rs Allow deliberate instances of the clippy::derivable_impls lint (#2788) 2021-09-22 10:43:27 -03:00
error.rs Reject a mempool transaction if it has internal spend conflicts (#2843) 2021-10-28 02:49:28 +00:00
lib.rs Ignore AlreadyInChain error in the syncer (#2890) 2021-10-20 11:07:19 +10:00
parameters.rs move genesis parameters to zebra-chain (#1151) 2020-10-12 14:08:23 -07:00
primitives.rs Merge pull request #2318 from ZcashFoundation/redpallas-verifier 2021-07-02 02:50:23 -04:00
script.rs Send looked up UTXOs to the transaction verifier (#2849) 2021-10-12 00:25:20 +00:00
transaction.rs Reject a mempool transaction if it has internal spend conflicts (#2843) 2021-10-28 02:49:28 +00:00