Skip to content

Commit 9ea3c37

Browse files
authored
fix(mempool): remove redundant connections (#4378)
## What ❔ <!-- What are the changes this PR brings about? --> <!-- Example: This PR adds a PR template to the repo. --> <!-- (For bigger PRs adding more context is appreciated) --> ## Why ❔ <!-- Why are these changes done? What goal do they contribute to? What are the principles behind them? --> <!-- The `Why` has to be clear to non-Matter Labs entities running their own ZK Chain --> <!-- Example: PR templates ensure PR reviewers, observers, and future iterators are in context about the evolution of repos. --> ## Is this a breaking change? - [ ] Yes - [ ] No ## Operational changes <!-- Any config changes? Any new flags? Any changes to any scripts? --> <!-- Please add anything that non-Matter Labs entities running their own ZK Chain may need to know --> ## Checklist <!-- Check your PR fulfills the following items. --> <!-- For draft PRs check the boxes as you complete them. --> - [ ] PR title corresponds to the body of PR (we generate changelog entries from PRs). - [ ] Tests for the changes have been added / updated. - [ ] Documentation comments have been added / updated. - [ ] Code has been formatted via `zkstack dev fmt` and `zkstack dev lint`. Signed-off-by: Danil <[email protected]>
1 parent 93b2086 commit 9ea3c37

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

core/node/state_keeper/src/io/mempool.rs

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -553,19 +553,12 @@ impl MempoolIO {
553553
max_wait: Duration,
554554
) -> anyhow::Result<Option<L1BatchParams>> {
555555
// Check if there is an existing unsealed batch
556-
if let Some(unsealed_storage_batch) = self
557-
.pool
558-
.connection_tagged("state_keeper")
559-
.await?
560-
.blocks_dal()
561-
.get_unsealed_l1_batch()
562-
.await?
563-
{
556+
let mut storage = self.pool.connection_tagged("state_keeper").await?;
557+
if let Some(unsealed_storage_batch) = storage.blocks_dal().get_unsealed_l1_batch().await? {
564558
let protocol_version = unsealed_storage_batch
565559
.protocol_version
566560
.context("unsealed batch is missing protocol version")?;
567561

568-
let mut storage = self.pool.connection_tagged("state_keeper").await?;
569562
let interop_roots = storage
570563
.interop_root_dal()
571564
.get_interop_roots_for_first_l2_block_in_pending_batch()
@@ -589,14 +582,13 @@ impl MempoolIO {
589582

590583
let deadline = Instant::now() + max_wait;
591584

592-
let previous_protocol_version = self
593-
.pool
594-
.connection_tagged("state_keeper")
595-
.await?
585+
let previous_protocol_version = storage
596586
.blocks_dal()
597587
.pending_protocol_version()
598588
.await
599589
.context("Failed loading previous protocol version")?;
590+
drop(storage);
591+
600592
// Block until at least one transaction in the mempool can match the filter (or timeout happens).
601593
// This is needed to ensure that block timestamp is not too old.
602594
for _ in 0..poll_iters(self.delay_interval, max_wait) {

0 commit comments

Comments
 (0)