SetLastBlockProcessedInMem more in AttachChain, add not null locator check in WriteBestBlock. Add log and few assertions in wallet_reorgstore test.
        
      The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/32580.
See the guideline for information on the review process.
| Type | Reviewers | 
|---|---|
| ACK | achow101, pablomartin4btc | 
| Stale ACK | Prabhat1308 | 
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.
3112fb5
        
      
Few follows-ups from #30221: Use `SetLastBlockProcessedInMem` more in
`AttachChain`, add not null locator check in `WriteBestBlock`. Add log
and few assertions in `wallet_reorgstore` test.
127         # Upon reload after the crash, since the chainstate was not flushed, the tip contains the previously abandoned
128-        # coinbase. This should be rescanned and now un-abandoned.
129+        # coinbase. This was rescanned and now un-abandoned.
130         wallet = node.get_wallet_rpc("reorg_crash")
131         assert_equal(wallet.gettransaction(coinbase_tx_id)['details'][0]['abandoned'], False)
132+        assert_greater_than(wallet.getwalletinfo()['immature_balance'], 0)
                               KeyError: 'immature_balance'
89@@ -90,7 +90,7 @@ def test_coinbase_automatic_abandon_during_startup(self):
90         assert_equal(wallet0.gettransaction(descendant_tx_id)['details'][0]['abandoned'], True)
91 
92     def test_reorg_handling_during_unclean_shutdown(self):
93-        self.log.info("Test that wallet doesn't crash due to a duplicate block disconnection event after an unclean shutdown")
94+        self.log.info("Test that wallet transactions are un-abandoned in case of temporarily invalidated blocks and wallet doesn't crash due to a duplicate block disconnection event after an unclean shutdown")
nit: I haven’t seen the format I’m proposing here but just to make it more clear if it makes sense…
0        self.log.info(
1            "Test that on a duplicate block disconnection event after unclean shutdown:\n"
2            "    - wallet transactions are un-abandoned after temporarily invalidated blocks;\n"
3            "    - wallet doesn't crash.")
edited: moved the closing parenthesis up
cr-ACK 1b5c545e82fe3cf5027f16b43e2306aeb8d4ef9b
Reviewed #30221 to verify the agreed follow-ups:
wallet.cpp:
setLastBlockProcessedInMem - #30221 (review)(!loc.IsNull()) - #30221 (review)wallet_reorgsrestore.py:
Left a small nit on the test log update.