Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZIP-209: Validate transaction value balances - Implementation #2381

Closed
teor2345 opened this issue Jun 24, 2021 · 0 comments · Fixed by #2566
Closed

ZIP-209: Validate transaction value balances - Implementation #2381

teor2345 opened this issue Jun 24, 2021 · 0 comments · Fixed by #2566
Labels
A-consensus Area: Consensus rule updates A-rust Area: Updates to Rust code C-enhancement Category: This is an improvement NU Sprout Network Upgrade: Sprout specific tasks (before Overwinter) NU-1 Sapling Network Upgrade: Sapling specific tasks NU-5 Network Upgrade: NU5 specific tasks

Comments

@teor2345
Copy link
Contributor

teor2345 commented Jun 24, 2021

Motivation

Specifications

Transparent

Transparent inputs to a transaction insert value into a transparent transaction value pool associated with the transaction, and transparent outputs remove value from this pool. As in Bitcoin, the remaining value in the pool is available to miners as a fee.

Consensus rule: The remaining value in the transparent transaction value pool MUST be nonnegative.

https://zips.z.cash/protocol/protocol.pdf#transactions

Sprout

vold takes value from the transparent transaction value pool and vnew adds value to the transparent transaction
value pool . As a result, vold is treated like an output value, whereas vnew is treated like an input value.

As stated in § 4.3 ‘JoinSplit Descriptions’ on p. 36, either vold or vnew MUST be zero.

https://zips.z.cash/protocol/protocol.pdf#joinsplitbalance

Sapling

A positive Sapling balancing value takes value from the Sapling transaction value pool and adds it to the transparent transaction value pool . A negative Sapling balancing value does the reverse. As a result, positive vbalanceSapling is treated like an input to the transparent transaction value pool , whereas negative vbalanceSapling is treated like an output from that pool.

https://zips.z.cash/protocol/protocol.pdf#saplingbalance

Orchard

vbalanceOrchard is encoded in a transaction as the field valueBalanceOrchard. If a transaction has no Action descriptions, vbalanceOrchard is implicitly zero. Transaction fields are described in § 7.1 ‘Transaction Encoding and Consensus’ on p. 116.

A positive Orchard balancing value takes value from the Orchard transaction value pool and adds it to the transparent transaction value pool . A negative Orchard balancing value does the reverse. As a result, positive vbalanceOrchard is treated like an input to the transparent transaction value pool , whereas negative vbalanceOrchard is treated like an output from that pool.

https://zips.z.cash/protocol/protocol.pdf#orchardbalance

Designs

Solution

Alternatives

Related Work

@teor2345 teor2345 added C-enhancement Category: This is an improvement S-needs-triage Status: A bug report needs triage labels Jun 24, 2021
@teor2345 teor2345 changed the title Validate transaction value balances ZIP-209: Validate transaction value balances Jun 24, 2021
@teor2345 teor2345 changed the title ZIP-209: Validate transaction value balances ZIP-209: Validate transaction value balances - Implementation Jun 24, 2021
@teor2345 teor2345 added this to the 2021 Sprint 13 milestone Jun 24, 2021
@teor2345 teor2345 added A-consensus Area: Consensus rule updates A-rust Area: Updates to Rust code NU Sprout Network Upgrade: Sprout specific tasks (before Overwinter) P-Medium NU-1 Sapling Network Upgrade: Sapling specific tasks NU-5 Network Upgrade: NU5 specific tasks labels Jun 24, 2021
@mpguerra mpguerra removed the S-needs-triage Status: A bug report needs triage label Jun 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-consensus Area: Consensus rule updates A-rust Area: Updates to Rust code C-enhancement Category: This is an improvement NU Sprout Network Upgrade: Sprout specific tasks (before Overwinter) NU-1 Sapling Network Upgrade: Sapling specific tasks NU-5 Network Upgrade: NU5 specific tasks
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants