Skip to content

Commit

Permalink
feat: improve mempool error msg when mempool out of sync (#6618)
Browse files Browse the repository at this point in the history
Description
---
Improved mempool error message when mempool falls behind the persisted
blockchain db.

Motivation and Context
---
This error will occur in an edge case when the mempool is in the process
of finalizing a block template and just before it is done, a new block
has been added to the blockchain db. As the two processes are
asynchronous, the resolution implemented in the code is to return an
error message so that the client can issue a new request. Meanwhile, the
mempool has time to react to the updated blockchain db state.

How Has This Been Tested?
---
Compile succeed.

What process can a PR reviewer use to test or verify this change?
---
Code review.

<!-- 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
hansieodendaal authored Oct 10, 2024
1 parent b3ea19a commit 8f1b888
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,15 @@ where B: BlockchainBackend + 'static
if last_seen_hash != FixedHash::default() && best_block_header.hash() != &last_seen_hash {
warn!(
target: LOG_TARGET,
"Mempool out of sync - last seen hash '{}' does not match the tip hash '{}'.",
"Mempool out of sync - last seen hash '{}' does not match the tip hash '{}'. This condition \
should auto correct with the next block template request",
last_seen_hash, best_block_header.hash()
);
return Err(CommsInterfaceError::InternalError("Mempool out of sync".to_string()));
return Err(CommsInterfaceError::InternalError(
"Mempool out of sync, blockchain db advanced passed current tip in mempool storage; this \
should auto correct with the next block template request"
.to_string(),
));
}
let mut header = BlockHeader::from_previous(best_block_header.header());
let constants = self.consensus_manager.consensus_constants(header.height);
Expand Down

0 comments on commit 8f1b888

Please sign in to comment.