Skip to content

Commit 7a5c1e2

Browse files
authored
Merge pull request #1101 from openmina/feat/dont-verify-transactions-when-producing
feat(pool-candidate): Don't proceed to verify transactions snarks when producing or applying a block
2 parents 82e84ab + 39f5e7b commit 7a5c1e2

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
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,

node/testing/src/node/rust/config.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,11 @@ impl RustNodeTestingConfig {
9999
self
100100
}
101101

102+
pub fn initial_time(mut self, time: redux::Timestamp) -> Self {
103+
self.initial_time = time;
104+
self
105+
}
106+
102107
pub fn with_peer_id(mut self, bytes: [u8; 32]) -> Self {
103108
self.peer_id = TestPeerId::Bytes(bytes);
104109
self

node/testing/src/scenarios/p2p/pubsub.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ pub struct P2pReceiveMessage;
1818

1919
impl P2pReceiveMessage {
2020
pub async fn run(self, mut runner: ClusterRunner<'_>) {
21-
let config = RustNodeTestingConfig::devnet_default().initial_peers(hosts::devnet());
21+
let config = RustNodeTestingConfig::devnet_default()
22+
.initial_peers(hosts::devnet())
23+
.initial_time(redux::Timestamp::global_now());
2224

2325
let retransmitter_openmina_node = runner.add_rust_node(config);
2426

0 commit comments

Comments
 (0)