Skip to content

Commit 250aa71

Browse files
committed
feat(pool-candidate): Don't proceed to verify transactions snarks when producing or applying a block
1 parent 82e84ab commit 250aa71

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

node/src/ledger/write/ledger_write_state.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ impl LedgerWriteState {
3939
})
4040
.flatten()
4141
}
42+
43+
pub fn is_busy(&self) -> bool {
44+
self.pending_requests().peekable().peek().is_some()
45+
}
4246
}
4347

4448
impl Default for LedgerWriteState {

node/src/transaction_pool/candidate/transaction_pool_candidate_actions.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,14 @@ impl redux::EnablingCondition<crate::State> for TransactionPoolCandidateAction {
113113
.is_some(),
114114
TransactionPoolCandidateAction::Libp2pTransactionsReceived { .. } => true,
115115
TransactionPoolCandidateAction::VerifyNext => {
116-
// TODO: if a block is being applied or produced, skip this action too
117-
state.transition_frontier.sync.is_synced()
116+
// Don't continue if we are producing a block, or we never synced yet
117+
// or if the ledger service is busy.
118+
!state.block_producer.is_producing()
119+
&& state
120+
.transition_frontier
121+
.best_tip()
122+
.is_some_and(|b| !b.is_genesis())
123+
&& !state.ledger.write.is_busy()
118124
}
119125
TransactionPoolCandidateAction::VerifyPending {
120126
peer_id,

0 commit comments

Comments
 (0)