# 15 Nov 2021 ## Inputs - https://github.com/willcl-ark/onboarding-to-bitcoin-core - https://github.com/chaincodelabs/bitcoin-core-onboarding - https://github.com/lsilva01/dissecting-bitcoin-core-v01 - Connections ## Progress ### Architectural tour of Bitcoin Core Videos Watched 3 Architectural tour of Bitcoin Core videos, by JamesOB. ### PR Review [Protocol](https://hackmd.io/AjZ34stoSR6zBtuyoTai8w) #### **1. Add `ChainstateManager::ProcessTransaction`** https://bitcoincore.reviews/23173 1. <ins>Did you review the PR? Concept ACK, approach ACK, tested ACK, or NACK?</ins> Reviewed PR, concept approach and run all Unit Tests and specific changed tests ![](https://i.imgur.com/flCu1Hh.png) Specific unit tests changed in this PR: - txvalidation_tests.cpp - txvalidationcache_tests.cpp - validation_block_tests.cpp ![](https://i.imgur.com/VjF5x2W.png) 2. <ins>What is cs_main?</ins> It is a Mutex class (a synchronization primitive that can be used to protect shared data from being simultaneously accessed by multiple threads) and it is locked in several places of the codebase, specially around wallet sync and mempool processes. 2. <ins>Which components currently call AcceptToMemoryPool()? List all the places that we’ll call ATMP.</ins> * On `Validation.cpp` file, `CChainState::MaybeUpdateMempoolForReorg()` * On `Validation.cpp` file, `MempoolAcceptResult ChainstateManager::ProcessTransaction()` 3. <ins>What does CTxMemPool::check() do? Whose responsibility is it to call that function?</ins> It asserts the total tx size, fees and inner usages (not sure) in the mempool are correct. It is called for validating the Mempool state. 4. <ins>What does the bypass_limits argument in ATMP do? In which circumstances is ATMP call with bypass_limits set to true?</ins> Bypass_limits means that we won't force the mempool fee and capacity limits. Not sure in which circumstances we will use it. 5. <ins>One of the commit logs reads: > “This logic is not necessary for memory pool transactions, as AcceptToMemoryPool already refuses previously-known transaction ids entirely.” refers to the logic at https://github.com/bitcoin/bitcoin/blob/a206b0ea12eb4606b93323268fc81a4f1f952531/src/main.cpp#L484-L486, which was later removed in commit 450cbb0944cd20a06ce806e6679a1f4c83c50db2. <ins>What was the change that removed that logic?</ins> 7. <ins>The last commit is to Always call mempool.check() after processing a new transaction. Does that add any overhead to processing/relaying transactions? Why/why not?</ins> #### **2. Coalesce Chainstate loading sequence between {,non-}unittest codepaths`** 1. <ins>Did you review the PR? Concept ACK, approach ACK, tested ACK, or NACK?</ins> Reviewed PR. ![](https://i.imgur.com/z2V2NEx.png) 2. <ins>This PR distinguishes between “soft failures” and “hard failures” when loading the chainstate. What is the difference between those two? </ins> **Soft failure:** a failure that might be recovered from with a reindex * ERROR_CHAINSTATE_UPGRADE_FAILED * ERROR_REPLAYBLOCKS_FAILED * ERROR_LOADCHAINTIP_FAILED **Hard failure:** a failure that definitively cannot be recovered from with a reindex * ERROR_LOADING_BLOCK_DB * ERROR_BAD_GENESIS_BLOCK * ERROR_PRUNED_NEEDS_REINDEX * ERROR_LOAD_GENESIS_BLOCK_FAILED 3. <ins>The first commit (init: Extract chainstate loading sequence) touches a large number of lines and extracts logic from AppInitMain() into a dedicated LoadChainstateSequence() function. How did you satisfy yourself that this commit didn’t introduce any behaviour changes?</ins> 4. <ins>Commit init/chainstate: Decouple from stringy errors changes the return type of LoadChainstateSequence() from a boolean to an (optional) enum. How did you satisfy yourself that the commit didn’t introduce any behaviour changes?</ins> Make sense that states are represented with enums instead of bools. We are not modeling a boolean condition but the status of the chain (errors), which have more than 1 state? ![](https://i.imgur.com/X53BLvv.png) ### Testcases Revision None ## Next Steps * Effective Modern C++, Scott Meyers * Programming Bitcoin, Jimmy Song * Bitcoin from the Command Line [started] * Explore lightning node and Lightning Polar tool in depth [when starting Lightning Topics] * https://www.twitch.tv/achow101/videos