Zebra/zebra-chain/src
Janito Vaqueiro Ferreira Filho 0e89236405
Reject V5 transactions before NU5 activation (#2285)
* Add a `Transaction::version` getter

Returns the version of the transaction as a `u32`.

* Add `Transaction::is_overwintered` helper method

Returns if the `fOverwintered` flag should be set for the transaction's
version.

* Use new helpers to serialize transaction version

Reduce the repeated code and make it less error-prone with future
changes.

* Add getter methods to `transaction::Request` type

Refactor to move the type deconstruction code into the `Request` type.
The main objective is to make it easier to split the call handler into
methods that receive the request directly.

* Refactor to create `verify_v4_transaction` helper

Split the code specific to V4 transactions into a separate helper
method.

* Create `verify_v5_transaction` helper method

Prepare a separate method to have the validation code.

* Add `UnsupportedByNetworkUpgrade` error variant

An error for when a transaction's version isn't supported by the network
upgrade of the block it's included or for the current network upgrade if
the transaction is for the mempool.

* Verify a V5 transaction's network upgrade

For now, only NU5 supports V5 transactions.

* Test that V5 transaction is rejected on Canopy

Create a fake V5 transaction and try to verify it using a block height
from Canopy's activation. The verifier should reject the transaction
with an error saying that the network upgrade does not support that
transaction version.

* Test if V5 tx. is accepted after NU5 activation

Create a fake V5 transaction and pretend it is placed in a block that
has a height after the NU5 activation. The test should succeed, but
since the NU5 activation height has not been specified yet (neither for
the testnet nor the mainnet), for now this test is marked as
`should_panic`.

* Add `TODO` comment to the code

Add more detail to what's left to do, and link to the appropriate PRs.

* Use `u32` to store transaction version

Use a type consistent with how the version is specified.

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

Co-authored-by: teor <teor@riseup.net>
2021-06-15 10:15:59 +10:00
..
block ZIP-221: integrate MMR tree from librustcash (without Orchard) (#2227) 2021-06-11 11:25:48 -03:00
orchard Security: Stop panicking on invalid reserved orchard::Flags bits (#2284) 2021-06-15 10:04:18 +10:00
parameters Clippy: remove needless borrows 2021-06-07 18:33:58 -04:00
primitives ZIP-221: integrate MMR tree from librustcash (without Orchard) (#2227) 2021-06-11 11:25:48 -03:00
sapling Clippy: remove needless borrows 2021-06-07 18:33:58 -04:00
serialization Clippy: remove needless borrows 2021-06-07 18:33:58 -04:00
sprout Derive Arbitrary impls for a bunch of chain and network types (#2179) 2021-05-24 11:10:07 -04:00
transaction Reject V5 transactions before NU5 activation (#2285) 2021-06-15 10:15:59 +10:00
transparent Make debugging easier on proptests with large vectors (#2232) 2021-06-02 10:18:04 -03:00
work Standardise clippy lints and require docs (#2238) 2021-06-04 08:48:40 +10:00
amount.rs Move the check in `transaction::check::sapling_balances_match` to `V4` deserialization (#2234) 2021-06-04 08:53:00 +10:00
block.rs ZIP-221: integrate MMR tree from librustcash (without Orchard) (#2227) 2021-06-11 11:25:48 -03:00
fmt.rs Make debugging easier on proptests with large vectors (#2232) 2021-06-02 10:18:04 -03:00
lib.rs Standardise clippy lints and require docs (#2238) 2021-06-04 08:48:40 +10:00
orchard.rs Orchard data in V5 parsing (#2116) 2021-05-21 00:42:06 +00:00
parameters.rs Cleanup a few arbitrary impls (#2222) 2021-05-28 09:49:28 -03:00
primitives.rs ZIP-221: integrate MMR tree from librustcash (without Orchard) (#2227) 2021-06-11 11:25:48 -03:00
sapling.rs Rebase tidies 2021-04-30 00:48:23 -04:00
serialization.rs Add a DateTime32 type for 32-bit serialized times (#2210) 2021-05-31 12:52:34 +10:00
shutdown.rs Fix shutdown panics (#1637) 2021-02-03 19:03:28 +10:00
sprout.rs Move the preallocate tests into their own files (#1977) 2021-04-07 12:32:27 +10:00
transaction.rs Reject V5 transactions before NU5 activation (#2285) 2021-06-15 10:15:59 +10:00
transparent.rs chain: add custom Debug for CoinbaseData 2020-11-21 14:09:15 -05:00
work.rs export proptest impls for use in downstream crates (#1092) 2020-09-23 18:52:52 -07:00