Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: templates #6731

Merged
merged 2 commits into from
Jan 9, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -257,16 +257,29 @@ where B: BlockchainBackend + 'static
},
NodeCommsRequest::GetNewBlockTemplate(request) => {
let best_block_header = self.blockchain_db.fetch_tip_header().await?;
let last_seen_hash = self.mempool.get_last_seen_hash().await?;
let mut is_mempool_synced = true;
if last_seen_hash != FixedHash::default() && best_block_header.hash() != &last_seen_hash {
let mut last_seen_hash = self.mempool.get_last_seen_hash().await?;
let mut is_mempool_synced = false;
let mut counter = 0;
// this will wait a max of 100ms before returning anyway with a potential broken template
// We need to ensure the mempool has seen the latest base node height before we can be confident the
// template is correct
while !is_mempool_synced && counter < 10 {
SWvheerden marked this conversation as resolved.
Show resolved Hide resolved
if best_block_header.hash() == &last_seen_hash {
is_mempool_synced = true;
} else {
tokio::time::sleep(std::time::Duration::from_millis(10)).await;
last_seen_hash = self.mempool.get_last_seen_hash().await?;
counter += 1;
}
}

if !is_mempool_synced {
warn!(
target: LOG_TARGET,
"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()
);
is_mempool_synced = false;
}
let mut header = BlockHeader::from_previous(best_block_header.header());
let constants = self.consensus_manager.consensus_constants(header.height);
Expand Down
Loading