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

Track the provenance of UTXOs #1342

Closed
5 tasks done
hdevalence opened this issue Nov 20, 2020 · 1 comment · Fixed by #1358
Closed
5 tasks done

Track the provenance of UTXOs #1342

hdevalence opened this issue Nov 20, 2020 · 1 comment · Fixed by #1358
Assignees
Labels
A-consensus Area: Consensus rule updates C-design Category: Software design work C-enhancement Category: This is an improvement

Comments

@hdevalence
Copy link
Contributor

hdevalence commented Nov 20, 2020

Is your feature request related to a problem? Please describe.

One of the transaction consensus rules, whose previous implementation was removed in f607c98 , requires that transactions with transparent inputs which are the outputs of coinbase transactions must have no transparent outputs. (The previous implementation did not actually check this).

This requires tracking the provenance of UTXOs to some extent, which may require changing the data we store in our database. It might be worth checking what Zcashd does here.

Describe the solution you'd like

Rather than just tracking raw transparent::Outputs, we should track Utxos, a new structure that includes a transparent::Output as well as metadata:

pub struct Utxo {
    pub output: transparent::Output,
    pub height: block::Height,
    pub from_coinbase: bool,
}

This requires:

  • defining the Utxo structure;
  • defining a serialization format for the Utxo structure as stored in the database;
  • incrementing the database format version;
  • changing the zebra_state::Response::Utxo variant to return a Utxo rather than a raw Output;
  • correcting all previous uses of the UTXO code.

Then, in subsequent PRs, we can use this information to implement the relevant consensus rules.

@hdevalence hdevalence added C-enhancement Category: This is an improvement S-needs-triage Status: A bug report needs triage labels Nov 20, 2020
@hdevalence hdevalence added this to the Transaction Validation milestone Nov 20, 2020
@hdevalence hdevalence added A-consensus Area: Consensus rule updates C-design Category: Software design work labels Nov 20, 2020
@hdevalence
Copy link
Contributor Author

Here's the relevant structure in Zcashd (thanks @str4d for the pointer): https://github.com/zcash/zcash/blob/877212414ad40e37cf8e49884a90767c54d59ba2/src/coins.h#L23-L79

@hdevalence hdevalence self-assigned this Nov 23, 2020
@hdevalence hdevalence changed the title Determine whether a UTXO is the output of a coinbase transaction Track the provenance of UTXOs Nov 23, 2020
hdevalence added a commit that referenced this issue Nov 23, 2020
This commit changes the state system and database format to track the
provenance of UTXOs, in addition to the outputs themselves.
Specifically, it tracks the following additional metadata:

- the height at which the UTXO was created;
- whether or not the UTXO was created from a coinbase transaction or
  not.

This metadata will allow us to:

- check the coinbase maturity consensus rule;
- check the coinbase inputs => no transparent outputs rule;
- implement lookup of transactions by utxo (using the height to find the
  block and then scanning the block) for a future RPC mechanism.

Closes #1342
hdevalence added a commit that referenced this issue Nov 23, 2020
This commit changes the state system and database format to track the
provenance of UTXOs, in addition to the outputs themselves.
Specifically, it tracks the following additional metadata:

- the height at which the UTXO was created;
- whether or not the UTXO was created from a coinbase transaction or
  not.

This metadata will allow us to:

- check the coinbase maturity consensus rule;
- check the coinbase inputs => no transparent outputs rule;
- implement lookup of transactions by utxo (using the height to find the
  block and then scanning the block) for a future RPC mechanism.

Closes #1342
hdevalence added a commit that referenced this issue Nov 23, 2020
This commit changes the state system and database format to track the
provenance of UTXOs, in addition to the outputs themselves.
Specifically, it tracks the following additional metadata:

- the height at which the UTXO was created;
- whether or not the UTXO was created from a coinbase transaction or
  not.

This metadata will allow us to:

- check the coinbase maturity consensus rule;
- check the coinbase inputs => no transparent outputs rule;
- implement lookup of transactions by utxo (using the height to find the
  block and then scanning the block) for a future RPC mechanism.

Closes #1342
hdevalence added a commit that referenced this issue Nov 24, 2020
This commit changes the state system and database format to track the
provenance of UTXOs, in addition to the outputs themselves.
Specifically, it tracks the following additional metadata:

- the height at which the UTXO was created;
- whether or not the UTXO was created from a coinbase transaction or
  not.

This metadata will allow us to:

- check the coinbase maturity consensus rule;
- check the coinbase inputs => no transparent outputs rule;
- implement lookup of transactions by utxo (using the height to find the
  block and then scanning the block) for a future RPC mechanism.

Closes #1342
hdevalence added a commit that referenced this issue Nov 24, 2020
This commit changes the state system and database format to track the
provenance of UTXOs, in addition to the outputs themselves.
Specifically, it tracks the following additional metadata:

- the height at which the UTXO was created;
- whether or not the UTXO was created from a coinbase transaction or
  not.

This metadata will allow us to:

- check the coinbase maturity consensus rule;
- check the coinbase inputs => no transparent outputs rule;
- implement lookup of transactions by utxo (using the height to find the
  block and then scanning the block) for a future RPC mechanism.

Closes #1342
@mpguerra mpguerra removed the S-needs-triage Status: A bug report needs triage label Feb 18, 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 C-design Category: Software design work C-enhancement Category: This is an improvement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants