Skip to content

Conversation

jonatack
Copy link
Member

@jonatack jonatack commented Apr 28, 2022

Picks up the remaining review feedback in #21726 and #24956.

  • make the global function GetFirstStoredBlock() a member of the BlockManager class
  • pass the start_block param of GetFirstStoredBlock() by reference instead of a pointer
  • use GetBlockTime() for RPC getblockchaininfo#time

@jonatack jonatack changed the title blockstorage, refactor: improve GetFirstStoredBlock() blockstorage, refactor: GetFirstStoredBlock() follow-ups Apr 28, 2022
@jonatack jonatack force-pushed the GetFirstStoredBlock-improvements branch from e12d4f0 to e2b954e Compare April 28, 2022 18:53
@jonatack
Copy link
Member Author

Updated now that #24956 is merged, and ready for review.

@jonatack jonatack changed the title blockstorage, refactor: GetFirstStoredBlock() follow-ups refactor: GetFirstStoredBlock() and getblockchaininfo follow-ups Apr 28, 2022
Copy link
Member

@maflcko maflcko left a comment

Choose a reason for hiding this comment

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

ACK e2b954e

@fanquake fanquake merged commit 194b414 into bitcoin:master Apr 29, 2022
@jonatack jonatack deleted the GetFirstStoredBlock-improvements branch April 29, 2022 11:50
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Apr 29, 2022
…ninfo follow-ups

e2b954e rpc: use GetBlockTime() for getblockchaininfo#time (Jon Atack)
86ce844 blockstorage, refactor: pass GetFirstStoredBlock() start_block by reference (Jon Atack)
ed12c0a blockstorage, refactor: make GetFirstStoredBlock() a member of BlockManager (Jon Atack)

Pull request description:

  Picks up the remaining review feedback in bitcoin#21726 and bitcoin#24956.

  - make the global function `GetFirstStoredBlock()` a member of the `BlockManager` class
  - pass the `start_block` param of `GetFirstStoredBlock()` by reference instead of a pointer
  - use `GetBlockTime()` for RPC getblockchaininfo#time

ACKs for top commit:
  MarcoFalke:
    ACK e2b954e

Tree-SHA512: 546e3c2e18245996b5b286829a605ae919eff3510963ec71b7c9ede521b1f501697e5b2f9d35d7a0606a74cbc8907201c58acf1e2cf7daaa86eefe2e3a8e296b
@@ -390,10 +390,10 @@ bool BlockManager::IsBlockPruned(const CBlockIndex* pblockindex)
return (m_have_pruned && !(pblockindex->nStatus & BLOCK_HAVE_DATA) && pblockindex->nTx > 0);
}

const CBlockIndex* GetFirstStoredBlock(const CBlockIndex* start_block) {
const CBlockIndex* BlockManager::GetFirstStoredBlock(const CBlockIndex& start_block)
Copy link
Member

Choose a reason for hiding this comment

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

In theory start_block could be marked LIFETIMEBOUND.

Copy link
Member Author

Choose a reason for hiding this comment

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

In theory start_block could be marked LIFETIMEBOUND.

Ah, yes; done in #25060.

maflcko pushed a commit to bitcoin-core/gui that referenced this pull request May 4, 2022
…rstStoredBlock()::start_time

4cb9d21 blockstorage: add LIFETIMEBOUND to GetFirstStoredBlock()::start_time (Jon Atack)

Pull request description:

  Suggested in bitcoin/bitcoin#25016 (comment), the lifetimebound attribute here indicates that a resource owned by the `start_block` param of `CBlockIndex* BlockManager::GetFirstStoredBlock()` can be retained by the method's return value, which enables detecting the use of out-of-scope stack memory (ASan `stack-use-after-scope`) at compile time.

  See https://releases.llvm.org/12.0.0/tools/clang/docs/AttributeReference.html#lifetimebound and #22278 for related discussion, and #25040 for a similar example.

ACKs for top commit:
  MarcoFalke:
    review ACK 4cb9d21

Tree-SHA512: a3f5ef83ebb6f08555d7c89f2437a682071b4ad77a7aa3326b6d2282c909bf9fcf4dac6bf05ee1d9931f2102cad4a02df5468bde1cf377d7126e84e8541604dc
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request May 4, 2022
…dBlock()::start_time

4cb9d21 blockstorage: add LIFETIMEBOUND to GetFirstStoredBlock()::start_time (Jon Atack)

Pull request description:

  Suggested in bitcoin#25016 (comment), the lifetimebound attribute here indicates that a resource owned by the `start_block` param of `CBlockIndex* BlockManager::GetFirstStoredBlock()` can be retained by the method's return value, which enables detecting the use of out-of-scope stack memory (ASan `stack-use-after-scope`) at compile time.

  See https://releases.llvm.org/12.0.0/tools/clang/docs/AttributeReference.html#lifetimebound and bitcoin#22278 for related discussion, and bitcoin#25040 for a similar example.

ACKs for top commit:
  MarcoFalke:
    review ACK 4cb9d21

Tree-SHA512: a3f5ef83ebb6f08555d7c89f2437a682071b4ad77a7aa3326b6d2282c909bf9fcf4dac6bf05ee1d9931f2102cad4a02df5468bde1cf377d7126e84e8541604dc
@bitcoin bitcoin locked and limited conversation to collaborators May 3, 2023
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.

4 participants