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

Add blockchain.NewUtxoEntry() #1588

Merged
merged 1 commit into from
Jun 15, 2020
Merged

Conversation

adiabat
Copy link
Contributor

@adiabat adiabat commented May 29, 2020

In developing utreexo we're using btcd & libraries quite a bit. The current exported methods for adding entries to a UtxoViewpoint don't work for utreexo though.

AddTxOut() and AddTxOuts() both require a whole transaction, including the inputs, which are only there to calculate the txid. In the utreexo setup, we only have the outpoint and txout data, but not the rest of the transaction we'd like to add into the UtxoViewpoint. Directly creating one with NewUtxoEntry() seems like the smallest change that doesn't affect anything else in btcd.

Another way to do it would be exporting the current addTxOut() method, but that would conflict with the current exported AddTxOut() method. (which, granted, is only used in 1 place in mempool.go, and that usage could be adapted to give the TxOut rather than whole transaction) Adding a NewUtxoEntry() constructor seemed simplest but changing AddTxOut() would work just as well.

For reference, our usage of UtxoViewpoint is here: https://github.com/mit-dci/utreexo/pull/135/files#diff-3f7b8f9991ea957f1f4ad9f5a95415f0R96

If there are other options we'd also look at those. Hope we can get something like this in and be able to use the master branch of btcd for uteexo software. Thanks!

Copy link
Member

@jcvernaleo jcvernaleo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Happy to merge it in. One minor request. Could you change the commit message to follow these guidelines a bit better:
https://github.com/btcsuite/btcd/blob/master/docs/code_contribution_guidelines.md#ModelGitCommitMessages

Specifically, the length of the summary and also you give a great description in the PR comment, but not in the commit message itself.

…point

The current methods to add to a UtxoViewpoint don't allow for a situation where
we have only UTXO data but not a whole transaction.  This commit allows
contstruction of a UtxoEntry without requiring a full MsgTx.

AddTxOut() and AddTxOuts() both require a whole transaction, including the inputs,
which are only used in order to calculate the txid.  In some situations, such as
with use of the utreexo accumulator, we only have the utxo data but not the
transaction which created it.

For reference, utreexo's initial usage of the blockchain.NewUtxoEntry() function is at
https://github.com/mit-dci/utreexo/pull/135/files#diff-3f7b8f9991ea957f1f4ad9f5a95415f0R96
@adiabat
Copy link
Contributor Author

adiabat commented Jun 8, 2020

OK, I ammended the git commit message to have more of the info from the PR text (minus alternatives since that might be confusing in a commit message)

Copy link
Member

@jcvernaleo jcvernaleo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

@jcvernaleo jcvernaleo merged commit a383a71 into btcsuite:master Jun 15, 2020
@onyb onyb mentioned this pull request Jul 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants