Skip to content

Commit

Permalink
Address code review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
pbeza committed Nov 26, 2024
1 parent fad428c commit f1f210b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
29 changes: 18 additions & 11 deletions core/lib/dal/src/tee_proof_generation_dal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use zksync_db_connection::{
connection::Connection,
error::DalResult,
instrument::{InstrumentExt, Instrumented},
match_query_as,
utils::pg_interval_from_duration,
};
use zksync_types::{tee_types::TeeType, L1BatchNumber};
Expand Down Expand Up @@ -242,7 +243,9 @@ impl TeeProofGenerationDal<'_, '_> {
batch_number: L1BatchNumber,
tee_type: Option<TeeType>,
) -> DalResult<Vec<StorageTeeProof>> {
let query = format!(
let query = match_query_as!(
Vec<StorageTeeProof>,
[
r#"
SELECT
tp.pubkey,
Expand All @@ -257,19 +260,23 @@ impl TeeProofGenerationDal<'_, '_> {
tee_attestations ta ON tp.pubkey = ta.pubkey
WHERE
tp.l1_batch_number = $1
{}
ORDER BY tp.l1_batch_number ASC, tp.tee_type ASC
"#,
tee_type.map_or_else(String::new, |_| "AND tp.tee_type = $2".to_string())
_,
"ORDER BY tp.l1_batch_number ASC, tp.tee_type ASC"
],
match(&tee_type) {
Some(tee_type) => {
("AND tp.tee_type = $2"; i64::from(batch_number.0), tee_type.to_string())
},
None => (""; i64::from(batch_number.0)),
}
);

let mut query = sqlx::query_as(&query).bind(i64::from(batch_number.0));

if let Some(tee_type) = tee_type {
query = query.bind(tee_type.to_string());
}

let proofs: Vec<StorageTeeProof> = query.fetch_all(self.storage.conn()).await.unwrap();
let proofs = query
.instrument("get_tee_proofs")
.with_arg("l1_batch_number", &batch_number)
.fetch_all(self.storage.conn())
.await?;

Ok(proofs)
}
Expand Down
4 changes: 0 additions & 4 deletions core/node/api_server/src/web3/namespaces/unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,6 @@ impl UnstableNamespace {
})
.collect::<Vec<_>>();

if proofs.is_empty() {
return Err(Web3Error::NoBlock);
}

Ok(proofs)
}
}

0 comments on commit f1f210b

Please sign in to comment.