Skip to content

Commit 98cbaa4

Browse files
committed
Merge branch 'bp/maint-101.1/pr-4785' (#4966)
* bp/maint-101.1/pr-4785: changelog: add #4966 Fix block index not being properly used
2 parents b6646b0 + c22e9af commit 98cbaa4

File tree

6 files changed

+10
-50
lines changed

6 files changed

+10
-50
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- Partially backported PR#4785 to improve performance of shielded sync.
2+
([\#4966](https://github.com/anoma/namada/pull/4966))

Cargo.lock

Lines changed: 0 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@ ics23 = "0.12"
172172
usize-set = { version = "0.10", features = ["serialize-borsh", "serialize-serde"] }
173173
impl-num-traits = "0.2"
174174
indexmap = { package = "nam-indexmap", version = "2.7.1-nam.0", features = ["borsh-schema", "serde"] }
175-
init-once = "0.6"
176175
itertools = "0.14"
177176
jubjub = { package = "nam-jubjub", version = "0.10.1-nam.0" }
178177
k256 = { version = "0.13", default-features = false, features = ["ecdsa", "pkcs8", "precomputed-tables", "serde", "std"]}

crates/sdk/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ ethers.workspace = true
107107
eyre.workspace = true
108108
fd-lock = { workspace = true, optional = true }
109109
futures.workspace = true
110-
init-once.workspace = true
111110
itertools.workspace = true
112111
jubjub = { workspace = true, optional = true }
113112
lazy_static.workspace = true

crates/sdk/src/masp/utilities.rs

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use namada_token::masp::utils::{
2020
};
2121
use namada_tx::event::MaspEvent;
2222
use namada_tx::{IndexedTx, Tx};
23-
use tokio::sync::Semaphore;
23+
use tokio::sync::{OnceCell, Semaphore};
2424

2525
use crate::error::{Error, QueryError};
2626
use crate::masp::{extract_masp_tx, get_indexed_masp_events_at_height};
@@ -234,7 +234,7 @@ struct IndexerMaspClientShared {
234234
indexer_api: reqwest::Url,
235235
/// Bloom filter to help avoid fetching block heights
236236
/// with no MASP notes.
237-
block_index: init_once::InitOnce<Option<(BlockHeight, xorf::BinaryFuse16)>>,
237+
block_index: OnceCell<Option<(BlockHeight, xorf::BinaryFuse16)>>,
238238
/// Maximum number of concurrent fetches.
239239
max_concurrent_fetches: usize,
240240
}
@@ -273,13 +273,9 @@ impl IndexerMaspClient {
273273
indexer_api,
274274
max_concurrent_fetches,
275275
semaphore: Semaphore::new(max_concurrent_fetches),
276-
block_index: {
277-
let mut index = init_once::InitOnce::new();
278-
if !using_block_index {
279-
index.init(|| None);
280-
}
281-
index
282-
},
276+
block_index: OnceCell::new_with(
277+
(!using_block_index).then_some(None),
278+
),
283279
});
284280
Self { client, shared }
285281
}
@@ -428,15 +424,11 @@ impl MaspClient for IndexerMaspClient {
428424
)));
429425
}
430426

431-
let maybe_block_index = self
427+
let maybe_block_index: &Option<_> = self
432428
.shared
433429
.block_index
434-
.try_init_async(async {
435-
let _permit = self.shared.semaphore.acquire().await.unwrap();
436-
self.last_block_index().await.ok()
437-
})
438-
.await
439-
.and_then(Option::as_ref);
430+
.get_or_init(|| async { self.last_block_index().await.ok() })
431+
.await;
440432

441433
let mut fetches = vec![];
442434
loop {

wasm/Cargo.lock

Lines changed: 0 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)