Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add check to verify mempool state (#6316)
Description --- Added a check to verify that the mempool last processed block is in sync with the blockchain state whenever a new block template is requested, as adding a block to the db and processing the same block in the mempool happens asynchronously. Miners can get block templates with double spending if this is not done. Motivation and Context --- In a recent stress test the following behaviour was observed multiple times: 1. [mempool] New transaction `4776...2001` received with output `000e9...6b57c` 1. [mempool] Transaction `4776d...82001` inserted into the mempool 1. [grpc] Miner mined block `af0c8...c76c0` containing output `000e9...6b57c` 1. [lmdb_db] Output `000e9...6b57c` inserted into the db 1. [grpc] New block template requested (`GetNewBlockTemplate) 1. [mempool] New block template prepared containing output `000e9...6b57c` 1. [mempool] Transaction `4776d...82001` with output `000e9...6b57c` removed from the mempool 1. [mempool] Processed new block `af0c8...c76c0` containing output `000e9...6b57c` 1. [grpc] New block requested (`GetNewBlock`) 1. [grpc] Using the latest block template, `pub fn prepare_new_block(&self, template: NewBlockTemplate)` fails at `let roots = match calculate_mmr_roots(&*db, self.rules(), &block, &mut smt)` with `ERROR Output commitment(000e9e1fd41f672e0b88f89b3d24390beb37d50e8be2967980e24a13d796b57c) already in SMT` How Has This Been Tested? --- System-level stress test to be done What process can a PR reviewer use to test or verify this change? --- Review code change <!-- Checklist --> <!-- 1. Is the title of your PR in the form that would make nice release notes? The title, excluding the conventional commit tag, will be included exactly as is in the CHANGELOG, so please think about it carefully. --> Breaking Changes --- - [x] None - [ ] Requires data directory on base node to be deleted - [ ] Requires hard fork - [ ] Other - Please specify <!-- Does this include a breaking change? If so, include this line as a footer --> <!-- BREAKING CHANGE: Description what the user should do, e.g. delete a database, resync the chain -->
- Loading branch information