Skip to content

Conversation

@promag
Copy link
Contributor

@promag promag commented Aug 13, 2017

Replace all mapBlockIndex lookups with the new LookupBlockIndex(). In some cases it avoids a second lookup.

@promag promag force-pushed the 2017-08-lookup-block-index branch 2 times, most recently from 63e918e to 171213c Compare August 13, 2017 16:34
src/rest.cpp Outdated
Copy link
Contributor Author

Choose a reason for hiding this comment

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

!pblockindex

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same as above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Remove assert.

@promag promag force-pushed the 2017-08-lookup-block-index branch 3 times, most recently from fb505b2 to 51d4607 Compare August 13, 2017 23:22
@jonasschnelli
Copy link
Contributor

Concept ACK

@TheBlueMatt
Copy link
Contributor

This may make #10692 a bit simpler, though I'm not sure it matters what order they come in.

@promag promag force-pushed the 2017-08-lookup-block-index branch 2 times, most recently from 930b525 to c515391 Compare August 15, 2017 15:07
@promag
Copy link
Contributor Author

promag commented Aug 15, 2017

Fixed bug and rebased.

@promag
Copy link
Contributor Author

promag commented Aug 22, 2017

@laanwj I believe it's ready.

@laanwj
Copy link
Member

laanwj commented Aug 22, 2017

Concept ACK

Copy link
Contributor

@meshcollider meshcollider left a comment

Choose a reason for hiding this comment

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

utACK

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe explicit cast to bool here for clarity

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Prefer this?

return LookupBlockIndex(inv.hash) != nullptr;

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah or a ternary or even an if statement would be a lot clearer

@promag promag force-pushed the 2017-08-lookup-block-index branch from c515391 to 1d1768f Compare August 25, 2017 14:22
@promag
Copy link
Contributor Author

promag commented Aug 25, 2017

Rebased and fixed @meshcollider comment.

src/validation.h Outdated
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Missing assert lock is held.

Copy link
Contributor

Choose a reason for hiding this comment

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

Missing EXCLUSIVE_LOCKS_REQUIRED(cs_main) too :-)

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 1d1768f2978bafaf166bfa218c899ddaeeccad2d

Copy link
Contributor

Choose a reason for hiding this comment

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

In some of these places you could do

if (const CBlockIndex* pindex = LookupBlockIndex(wtx.hashBlock))

to reduce the scope of the pindex variables.

Copy link
Contributor

Choose a reason for hiding this comment

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

I didn't know you could declare inside an if statement. Cool.

@promag
Copy link
Contributor Author

promag commented Nov 2, 2017

Thanks @ryanofsky, I have to rebase and then I'll take into account your comment above.

@promag promag force-pushed the 2017-08-lookup-block-index branch 2 times, most recently from 8337539 to a029cd4 Compare November 3, 2017 15:14
Copy link
Contributor

@jimpo jimpo left a comment

Choose a reason for hiding this comment

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

Concept ACK. This is much cleaner.

src/init.cpp Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

Need to keep the !mapBlockIndex.empty().

Copy link
Contributor

Choose a reason for hiding this comment

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

Needs a !

@promag
Copy link
Contributor Author

promag commented Dec 6, 2017

This needs rebase. I can do it and adapt the new code if there is interest in merging it quick.

Maybe it should also make BlockMap mapBlockIndex static?

cc @MarcoFalke @laanwj

@TheBlueMatt
Copy link
Contributor

Concept ACK. Would like to see this rebased sooner rather than later.

@promag promag force-pushed the 2017-08-lookup-block-index branch from a029cd4 to 6d9f555 Compare December 13, 2017 15:36
@promag
Copy link
Contributor Author

promag commented Dec 13, 2017

Forgot to tackle @ryanofsky comment above..

@promag promag force-pushed the 2017-08-lookup-block-index branch from 6d9f555 to e741b98 Compare December 13, 2017 16:07
@maflcko
Copy link
Member

maflcko commented Dec 13, 2017

travis failure:

Assertion failed: lock cs_main not held in ./validation.h:433; locks held:

LarryRuane pushed a commit to LarryRuane/zcash that referenced this pull request Apr 26, 2021
LarryRuane pushed a commit to LarryRuane/zcash that referenced this pull request Apr 26, 2021
LarryRuane pushed a commit to LarryRuane/zcash that referenced this pull request Apr 26, 2021
When accessing mapBlockIndex cs_main must be held.

zcash: cherry picked from commit f814a3e
zcash: bitcoin/bitcoin#11041
LarryRuane pushed a commit to LarryRuane/zcash that referenced this pull request Apr 26, 2021
@rebroad
Copy link
Contributor

rebroad commented May 11, 2021

@promag What's the reason for avoiding mapBlockIndex lookups?

@promag
Copy link
Contributor Author

promag commented May 11, 2021

@rebroad it avoids duplicate lookups - its unnecessary work.

LarryRuane pushed a commit to LarryRuane/zcash that referenced this pull request May 27, 2021
LarryRuane pushed a commit to LarryRuane/zcash that referenced this pull request May 27, 2021
LarryRuane pushed a commit to LarryRuane/zcash that referenced this pull request May 27, 2021
When accessing mapBlockIndex cs_main must be held.

zcash: cherry picked from commit f814a3e
zcash: bitcoin/bitcoin#11041
LarryRuane pushed a commit to LarryRuane/zcash that referenced this pull request May 27, 2021
gades pushed a commit to cosanta/cosanta-core that referenced this pull request Mar 13, 2022
Contains both the changes done upstream and changes done in Dash codebase

Signed-off-by: pasta <[email protected]>
gades pushed a commit to cosanta/cosanta-core that referenced this pull request Mar 22, 2022
gades pushed a commit to cosanta/cosanta-core that referenced this pull request Mar 22, 2022
…OCKORDER

33eb907 Fix ComputeTimeSmart test failure with -DDEBUG_LOCKORDER (Russell Yanofsky)

Pull request description:

  Failure looks like:

  ```
  Entering test case "ComputeTimeSmart"
  test_bitcoin: sync.cpp:100: void potential_deadlock_detected(const std::pair<void*, void*>&, const LockStack&, const LockStack&): Assertion `false' failed.
  unknown location(0): fatal error in "ComputeTimeSmart": signal: SIGABRT (application abort requested)
  wallet/test/wallet_tests.cpp(566): last checkpoint
  ```

  Reproducible with:

  ```
  ./configure --enable-debug
  make -C src test/test_bitcoin && src/test/test_bitcoin --log_level=test_suite --run_test=wallet_tests/ComputeTimeSmart
  ```

  Seems to be caused by acquiring `cs_main` inside `CWallet::ComputeTimeSmart` in bitcoin#11041.

  I think this may be causing timeouts on travis like: https://travis-ci.org/bitcoin/bitcoin/jobs/353005676#L2692

Tree-SHA512: b263cd122ea9c88204d1d8e7e35291c71ea6319f05114c5009235a75dbd0f669bc0394f44afeed0d9eb08c2a956cd7c08f1ac4ef28616932fef9b43eaac5521b
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Aug 18, 2022
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.