Skip to content

Conversation

@sipa
Copy link
Member

@sipa sipa commented Jun 13, 2017

Superset of #10559

This removes the possibility for GetCoin/HaveCoin/HaveCoinInCache to return true while the respective coin is spent. By doing it across all calls, some extra checks can be eliminated.

coins_tests is modified to call HaveCoin sometimes before and sometimes after AccessCoin. A further change is needed because the semantics for GetCoin slightly changed, causing a pruned entry in the parent cache to not be pulled into the child in FetchCoin.

@sipa
Copy link
Member Author

sipa commented Jun 16, 2017

@morcos @ryanofsky Feel like having a look at this?

Copy link
Contributor

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

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

utACK 6ba5394841172944082e0c7447f404d6609337f3. Nice change. I'd call it a superset of the change in #10559 though instead of an alternative.

Copy link
Contributor

Choose a reason for hiding this comment

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

What's the point of the two InsecureRandBits calls skipping the new BOOST_CHECKs? It seems like the checks should always pass and aren't very expensive. Is the point to avoid creating cache entries during the test? Maybe add a comment saying why this only randomly checks HaveCoin results.

Copy link
Member Author

@sipa sipa Jun 22, 2017

Choose a reason for hiding this comment

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

Added a comment, and shuffled the code a bit to make it clearer.

@sipa sipa force-pushed the simplehavecoin branch from 6ba5394 to 007e965 Compare June 22, 2017 22:23
@sipa
Copy link
Member Author

sipa commented Jun 23, 2017

@ryanofsky Oh yes, indeed! Rebased on top of #10559.

@sipa sipa force-pushed the simplehavecoin branch from 007e965 to 04087f7 Compare June 23, 2017 01:38
Copy link
Contributor

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

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

utACK 04087f7d83360482e031e9ecbcc97a29fb3b1b8a. Only new changes are test cleanup and rebase.

Copy link
Contributor

@paveljanik paveljanik left a comment

Choose a reason for hiding this comment

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

utACK 04087f7

Copy link
Contributor

@paveljanik paveljanik Jun 26, 2017

Choose a reason for hiding this comment

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

micro nit eachSPCother

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

@laanwj laanwj self-assigned this Jun 26, 2017
@sipa sipa force-pushed the simplehavecoin branch from 04087f7 to a1b2fc7 Compare June 26, 2017 23:15
@sipa
Copy link
Member Author

sipa commented Jun 26, 2017

Rebased.

This removes the possibility for GetCoin/HaveCoin/HaveCoinInCache to return
true while the respective coin is spent. By doing it across all calls, some
extra checks can be eliminated.

coins_tests is modified to call HaveCoin sometimes before and sometimes
after AccessCoin. A further change is needed because the semantics for
GetCoin slightly changed, causing a pruned entry in the parent cache to not
be pulled into the child in FetchCoin.
@sipa sipa force-pushed the simplehavecoin branch from a1b2fc7 to 21180ff Compare June 26, 2017 23:16
@laanwj
Copy link
Member

laanwj commented Jun 27, 2017

utACK 21180ff, certainly makes the API better

@laanwj laanwj merged commit 21180ff into bitcoin:master Jun 27, 2017
laanwj added a commit that referenced this pull request Jun 27, 2017
21180ff Simplify return values of GetCoin/HaveCoin(InCache) (Pieter Wuille)

Tree-SHA512: eae0aa64fa1308191100cdc7cdc790c825f33b066c200a18b5895d7d5806cee1cc4caba1766ef3379a7cf93dde4bbae2bc9be92947935f5741f5c126d3ee991b
@morcos
Copy link
Contributor

morcos commented Jun 27, 2017

posthumous utACK

@sipa, I'd misinterpreted this #10559 (comment) to imply you wanted ViewMempool functions to include whether the mempool contains a spend. But now I think you didn't want that and are happy with where we are now? If so, so am I.

@sipa
Copy link
Member Author

sipa commented Jun 27, 2017

@morcos Yes, the CCoinsViewMemPool view is internally consistent and follows all expectations of a CCoinsView. It just still contains outputs spent inside the mempool.

@TheBlueMatt
Copy link
Contributor

Postumous utACK, there are a bunch of places that are only barely safe before this change, and this makes them much more clearly safe 👍 .

codablock pushed a commit to codablock/dash that referenced this pull request Oct 26, 2017
21180ff Simplify return values of GetCoin/HaveCoin(InCache) (Pieter Wuille)

Tree-SHA512: eae0aa64fa1308191100cdc7cdc790c825f33b066c200a18b5895d7d5806cee1cc4caba1766ef3379a7cf93dde4bbae2bc9be92947935f5741f5c126d3ee991b
codablock pushed a commit to codablock/dash that referenced this pull request Oct 31, 2017
21180ff Simplify return values of GetCoin/HaveCoin(InCache) (Pieter Wuille)

Tree-SHA512: eae0aa64fa1308191100cdc7cdc790c825f33b066c200a18b5895d7d5806cee1cc4caba1766ef3379a7cf93dde4bbae2bc9be92947935f5741f5c126d3ee991b
schancel pushed a commit to givelotus/lotusd that referenced this pull request Jul 18, 2019
Summary:
21180ff Simplify return values of GetCoin/HaveCoin(InCache) (Pieter Wuille)

Tree-SHA512: eae0aa64fa1308191100cdc7cdc790c825f33b066c200a18b5895d7d5806cee1cc4caba1766ef3379a7cf93dde4bbae2bc9be92947935f5741f5c126d3ee991b

Backport of Core PR10581
bitcoin/bitcoin#10581

Test Plan:
  make check
  test_runner.py

Reviewers: deadalnix, Fabien, jasonbcox, markblundeberg, O1 Bitcoin ABC, #bitcoin_abc

Reviewed By: deadalnix, O1 Bitcoin ABC, #bitcoin_abc

Differential Revision: https://reviews.bitcoinabc.org/D3620
jonspock pushed a commit to jonspock/devault that referenced this pull request Aug 29, 2019
Summary:
21180ff Simplify return values of GetCoin/HaveCoin(InCache) (Pieter Wuille)

Tree-SHA512: eae0aa64fa1308191100cdc7cdc790c825f33b066c200a18b5895d7d5806cee1cc4caba1766ef3379a7cf93dde4bbae2bc9be92947935f5741f5c126d3ee991b

Backport of Core PR10581
bitcoin/bitcoin#10581

Test Plan:
  make check
  test_runner.py

Reviewers: deadalnix, Fabien, jasonbcox, markblundeberg, O1 Bitcoin ABC, #bitcoin_abc

Reviewed By: deadalnix, O1 Bitcoin ABC, #bitcoin_abc

Differential Revision: https://reviews.bitcoinabc.org/D3620
proteanx pushed a commit to devaultcrypto/devault that referenced this pull request Sep 4, 2019
Summary:
21180ff Simplify return values of GetCoin/HaveCoin(InCache) (Pieter Wuille)

Tree-SHA512: eae0aa64fa1308191100cdc7cdc790c825f33b066c200a18b5895d7d5806cee1cc4caba1766ef3379a7cf93dde4bbae2bc9be92947935f5741f5c126d3ee991b

Backport of Core PR10581
bitcoin/bitcoin#10581

Test Plan:
  make check
  test_runner.py

Reviewers: deadalnix, Fabien, jasonbcox, markblundeberg, O1 Bitcoin ABC, #bitcoin_abc

Reviewed By: deadalnix, O1 Bitcoin ABC, #bitcoin_abc

Differential Revision: https://reviews.bitcoinabc.org/D3620
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants