diff --git a/.github/workflows/build-core-template.yml b/.github/workflows/build-core-template.yml index 453333ca4c88..9a6587b189e4 100644 --- a/.github/workflows/build-core-template.yml +++ b/.github/workflows/build-core-template.yml @@ -42,6 +42,7 @@ jobs: - external-node - contract-verifier - cross-external-nodes-checker + - snapshots-creator steps: - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3 with: diff --git a/Cargo.lock b/Cargo.lock index da74a2a1ee70..7bbe6918771b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7577,14 +7577,12 @@ dependencies = [ "anyhow", "futures 0.3.29", "prometheus_exporter", - "serde", - "serde_json", + "rand 0.8.5", "tokio", "tracing", "vise", "vlog", "zksync_config", - "zksync_core", "zksync_dal", "zksync_env_config", "zksync_object_store", @@ -10315,12 +10313,14 @@ dependencies = [ "google-cloud-auth", "google-cloud-storage", "http", + "prost", "serde_json", "tempdir", "tokio", "tracing", "vise", "zksync_config", + "zksync_protobuf", "zksync_types", ] @@ -10482,6 +10482,7 @@ dependencies = [ "num_enum 0.6.1", "once_cell", "parity-crypto", + "prost", "rlp", "secp256k1 0.27.0", "serde", diff --git a/core/bin/snapshots_creator/Cargo.toml b/core/bin/snapshots_creator/Cargo.toml index c11cbbb49495..42c06db347c1 100644 --- a/core/bin/snapshots_creator/Cargo.toml +++ b/core/bin/snapshots_creator/Cargo.toml @@ -18,7 +18,6 @@ zksync_dal = { path = "../../lib/dal" } zksync_env_config = { path = "../../lib/env_config" } zksync_utils = { path = "../../lib/utils" } zksync_types = { path = "../../lib/types" } -zksync_core = { path = "../../lib/zksync_core" } zksync_object_store = { path = "../../lib/object_store" } vlog = { path = "../../lib/vlog" } @@ -26,5 +25,6 @@ anyhow = "1.0" tokio = { version = "1", features = ["full"] } tracing = "0.1" futures = "0.3" -serde = { version = "1.0.189", features = ["derive"] } -serde_json = "1.0" + +[dev-dependencies] +rand = "0.8" diff --git a/core/bin/snapshots_creator/src/chunking.rs b/core/bin/snapshots_creator/src/chunking.rs index 248f2de53597..11768febd44f 100644 --- a/core/bin/snapshots_creator/src/chunking.rs +++ b/core/bin/snapshots_creator/src/chunking.rs @@ -3,7 +3,10 @@ use std::ops; use zksync_types::{H256, U256}; use zksync_utils::u256_to_h256; -pub fn get_chunk_hashed_keys_range(chunk_id: u64, chunks_count: u64) -> ops::RangeInclusive { +pub(crate) fn get_chunk_hashed_keys_range( + chunk_id: u64, + chunks_count: u64, +) -> ops::RangeInclusive { assert!(chunks_count > 0); let mut stride = U256::MAX / chunks_count; let stride_minus_one = if stride < U256::MAX { @@ -20,3 +23,47 @@ pub fn get_chunk_hashed_keys_range(chunk_id: u64, chunks_count: u64) -> ops::Ran } u256_to_h256(start)..=u256_to_h256(end) } + +#[cfg(test)] +mod tests { + use zksync_utils::h256_to_u256; + + use super::*; + + #[test] + fn chunking_is_correct() { + for chunks_count in (2..10).chain([42, 256, 500, 1_001, 12_345]) { + println!("Testing chunks_count={chunks_count}"); + let chunked_ranges: Vec<_> = (0..chunks_count) + .map(|chunk_id| get_chunk_hashed_keys_range(chunk_id, chunks_count)) + .collect(); + + assert_eq!(*chunked_ranges[0].start(), H256::zero()); + assert_eq!( + *chunked_ranges.last().unwrap().end(), + H256::repeat_byte(0xff) + ); + for window in chunked_ranges.windows(2) { + let [prev_chunk, next_chunk] = window else { + unreachable!(); + }; + assert_eq!( + h256_to_u256(*prev_chunk.end()) + 1, + h256_to_u256(*next_chunk.start()) + ); + } + + let chunk_sizes: Vec<_> = chunked_ranges + .iter() + .map(|chunk| h256_to_u256(*chunk.end()) - h256_to_u256(*chunk.start()) + 1) + .collect(); + + // Check that chunk sizes are roughly equal. Due to how chunks are constructed, the sizes + // of all chunks except for the last one are the same, and the last chunk size may be slightly smaller; + // the difference in sizes is lesser than the number of chunks. + let min_chunk_size = chunk_sizes.iter().copied().min().unwrap(); + let max_chunk_size = chunk_sizes.iter().copied().max().unwrap(); + assert!(max_chunk_size - min_chunk_size < U256::from(chunks_count)); + } + } +} diff --git a/core/bin/snapshots_creator/src/main.rs b/core/bin/snapshots_creator/src/main.rs index 300b12572f99..69aee643abdf 100644 --- a/core/bin/snapshots_creator/src/main.rs +++ b/core/bin/snapshots_creator/src/main.rs @@ -1,11 +1,8 @@ -mod chunking; - -use std::{cmp::max, time::Duration}; +//! Snapshot creator utility. Intended to run on a schedule, with each run creating a new snapshot. use anyhow::Context as _; use prometheus_exporter::PrometheusExporterConfig; use tokio::sync::{watch, Semaphore}; -use vise::{Buckets, Gauge, Histogram, Metrics, Unit}; use zksync_config::{configs::PrometheusConfig, PostgresConfig, SnapshotsCreatorConfig}; use zksync_dal::ConnectionPool; use zksync_env_config::{object_store::SnapshotsObjectStoreConfig, FromEnv}; @@ -18,28 +15,15 @@ use zksync_types::{ }; use zksync_utils::ceil_div; -use crate::chunking::get_chunk_hashed_keys_range; - -#[derive(Debug, Metrics)] -#[metrics(prefix = "snapshots_creator")] -struct SnapshotsCreatorMetrics { - storage_logs_chunks_count: Gauge, - - storage_logs_chunks_left_to_process: Gauge, - - #[metrics(buckets = Buckets::LATENCIES, unit = Unit::Seconds)] - snapshot_generation_duration: Histogram, - - snapshot_l1_batch: Gauge, - - #[metrics(buckets = Buckets::LATENCIES, unit = Unit::Seconds)] - storage_logs_processing_duration: Histogram, +use crate::{ + chunking::get_chunk_hashed_keys_range, + metrics::{FactoryDepsStage, StorageChunkStage, METRICS}, +}; - #[metrics(buckets = Buckets::LATENCIES, unit = Unit::Seconds)] - factory_deps_processing_duration: Histogram, -} -#[vise::register] -pub(crate) static METRICS: vise::Global = vise::Global::new(); +mod chunking; +mod metrics; +#[cfg(test)] +mod tests; async fn maybe_enable_prometheus_metrics( stop_receiver: watch::Receiver, @@ -70,14 +54,23 @@ async fn process_storage_logs_single_chunk( ) -> anyhow::Result { let _permit = semaphore.acquire().await?; let hashed_keys_range = get_chunk_hashed_keys_range(chunk_id, chunks_count); - let latency = METRICS.storage_logs_processing_duration.start(); let mut conn = pool.access_storage_tagged("snapshots_creator").await?; + + let latency = + METRICS.storage_logs_processing_duration[&StorageChunkStage::LoadFromPostgres].start(); let logs = conn .snapshots_creator_dal() .get_storage_logs_chunk(miniblock_number, hashed_keys_range) .await .context("Error fetching storage logs count")?; drop(conn); + let latency = latency.observe(); + tracing::info!( + "Loaded chunk {chunk_id} ({} logs) from Postgres in {latency:?}", + logs.len() + ); + + let latency = METRICS.storage_logs_processing_duration[&StorageChunkStage::SaveToGcs].start(); let storage_logs_chunk = SnapshotStorageLogsChunk { storage_logs: logs }; let key = SnapshotStorageLogsStorageKey { l1_batch_number, @@ -87,18 +80,15 @@ async fn process_storage_logs_single_chunk( .put(key, &storage_logs_chunk) .await .context("Error storing storage logs chunk in blob store")?; - let output_filepath_prefix = blob_store.get_storage_prefix::(); let output_filepath = format!("{output_filepath_prefix}/{filename}"); + let latency = latency.observe(); - let elapsed = latency.observe(); let tasks_left = METRICS.storage_logs_chunks_left_to_process.dec_by(1) - 1; tracing::info!( - "Finished chunk number {chunk_id}, overall_progress {}/{}, step took {elapsed:?}, output stored in {output_filepath}", - chunks_count - tasks_left, - chunks_count - ); - + "Saved chunk {chunk_id} (overall progress {}/{chunks_count}) in {latency:?} to location: {output_filepath}", + chunks_count - tasks_left + ); Ok(output_filepath) } @@ -108,25 +98,34 @@ async fn process_factory_deps( miniblock_number: MiniblockNumber, l1_batch_number: L1BatchNumber, ) -> anyhow::Result { - let latency = METRICS.factory_deps_processing_duration.start(); let mut conn = pool.access_storage_tagged("snapshots_creator").await?; + + tracing::info!("Loading factory deps from Postgres..."); + let latency = + METRICS.factory_deps_processing_duration[&FactoryDepsStage::LoadFromPostgres].start(); let factory_deps = conn .snapshots_creator_dal() .get_all_factory_deps(miniblock_number) .await?; - let factory_deps = SnapshotFactoryDependencies { factory_deps }; drop(conn); + let latency = latency.observe(); + tracing::info!("Loaded {} factory deps in {latency:?}", factory_deps.len()); + + tracing::info!("Saving factory deps to GCS..."); + let latency = METRICS.factory_deps_processing_duration[&FactoryDepsStage::SaveToGcs].start(); + let factory_deps = SnapshotFactoryDependencies { factory_deps }; let filename = blob_store .put(l1_batch_number, &factory_deps) .await .context("Error storing factory deps in blob store")?; let output_filepath_prefix = blob_store.get_storage_prefix::(); let output_filepath = format!("{output_filepath_prefix}/{filename}"); - let elapsed = latency.observe(); + let latency = latency.observe(); tracing::info!( - "Finished factory dependencies, step took {elapsed:?} , output stored in {}", - output_filepath + "Saved {} factory deps in {latency:?} to location: {output_filepath}", + factory_deps.factory_deps.len() ); + Ok(output_filepath) } @@ -134,17 +133,23 @@ async fn run( blob_store: Box, replica_pool: ConnectionPool, master_pool: ConnectionPool, + min_chunk_count: u64, ) -> anyhow::Result<()> { let latency = METRICS.snapshot_generation_duration.start(); - let config = SnapshotsCreatorConfig::from_env().context("SnapshotsCreatorConfig::from_env")?; let mut conn = replica_pool .access_storage_tagged("snapshots_creator") .await?; - // we subtract 1 so that after restore, EN node has at least one l1 batch to fetch - let l1_batch_number = conn.blocks_dal().get_sealed_l1_batch_number().await? - 1; + // We subtract 1 so that after restore, EN node has at least one L1 batch to fetch + let sealed_l1_batch_number = conn.blocks_dal().get_sealed_l1_batch_number().await?; + assert_ne!( + sealed_l1_batch_number, + L1BatchNumber(0), + "Cannot create snapshot when only the genesis L1 batch is present in Postgres" + ); + let l1_batch_number = sealed_l1_batch_number - 1; let mut master_conn = master_pool .access_storage_tagged("snapshots_creator") @@ -155,33 +160,31 @@ async fn run( .await? .is_some() { - tracing::info!("Snapshot for L1 batch number {l1_batch_number} already exists, exiting",); + tracing::info!("Snapshot for L1 batch number {l1_batch_number} already exists, exiting"); return Ok(()); } drop(master_conn); - let last_miniblock_number_in_batch = conn + let (_, last_miniblock_number_in_batch) = conn .blocks_dal() .get_miniblock_range_of_l1_batch(l1_batch_number) .await? - .context("Error fetching last miniblock number")? - .1; + .context("Error fetching last miniblock number")?; let distinct_storage_logs_keys_count = conn .snapshots_creator_dal() .get_distinct_storage_logs_keys_count(l1_batch_number) .await?; - drop(conn); let chunk_size = config.storage_logs_chunk_size; - // we force at least 10 chunks to avoid situations where only one chunk is created in tests - let chunks_count = max(10, ceil_div(distinct_storage_logs_keys_count, chunk_size)); + // We force the minimum number of chunks to avoid situations where only one chunk is created in tests. + let chunks_count = ceil_div(distinct_storage_logs_keys_count, chunk_size).max(min_chunk_count); METRICS.storage_logs_chunks_count.set(chunks_count); tracing::info!( - "Creating snapshot for storage logs up to miniblock {last_miniblock_number_in_batch}, l1_batch {}", - l1_batch_number.0 + "Creating snapshot for storage logs up to miniblock {last_miniblock_number_in_batch}, \ + L1 batch {l1_batch_number}" ); tracing::info!("Starting to generate {chunks_count} chunks of expected size {chunk_size}"); @@ -210,15 +213,14 @@ async fn run( ) }); let mut storage_logs_output_files = futures::future::try_join_all(tasks).await?; - tracing::info!("Finished generating snapshot, storing progress in db"); + // Sanity check: the number of files should equal the number of chunks. + assert_eq!(storage_logs_output_files.len(), chunks_count as usize); + storage_logs_output_files.sort(); + tracing::info!("Finished generating snapshot, storing progress in Postgres"); let mut master_conn = master_pool .access_storage_tagged("snapshots_creator") .await?; - - storage_logs_output_files.sort(); - //sanity check - assert_eq!(storage_logs_output_files.len(), chunks_count as usize); master_conn .snapshots_dal() .add_snapshot( @@ -237,10 +239,12 @@ async fn run( "storage_logs_chunks_count: {}", METRICS.storage_logs_chunks_count.get() ); - Ok(()) } +/// Minimum number of storage log chunks to produce. +const MIN_CHUNK_COUNT: u64 = 10; + #[tokio::main] async fn main() -> anyhow::Result<()> { let (stop_sender, stop_receiver) = watch::channel(false); @@ -284,7 +288,7 @@ async fn main() -> anyhow::Result<()> { .build() .await?; - run(blob_store, replica_pool, master_pool).await?; + run(blob_store, replica_pool, master_pool, MIN_CHUNK_COUNT).await?; tracing::info!("Finished running snapshot creator!"); stop_sender.send(true).ok(); Ok(()) diff --git a/core/bin/snapshots_creator/src/metrics.rs b/core/bin/snapshots_creator/src/metrics.rs new file mode 100644 index 000000000000..194ed8f1e680 --- /dev/null +++ b/core/bin/snapshots_creator/src/metrics.rs @@ -0,0 +1,43 @@ +//! Metrics for the snapshot creator. + +use std::time::Duration; + +use vise::{Buckets, EncodeLabelSet, EncodeLabelValue, Family, Gauge, Histogram, Metrics, Unit}; + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, EncodeLabelValue, EncodeLabelSet)] +#[metrics(label = "stage", rename_all = "snake_case")] +pub(crate) enum FactoryDepsStage { + LoadFromPostgres, + SaveToGcs, +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, EncodeLabelValue, EncodeLabelSet)] +#[metrics(label = "stage", rename_all = "snake_case")] +pub(crate) enum StorageChunkStage { + LoadFromPostgres, + SaveToGcs, +} + +#[derive(Debug, Metrics)] +#[metrics(prefix = "snapshots_creator")] +pub(crate) struct SnapshotsCreatorMetrics { + /// Number of chunks in the most recently generated snapshot. Set when a snapshot generation starts. + pub storage_logs_chunks_count: Gauge, + /// Number of chunks left to process for the snapshot being currently generated. + pub storage_logs_chunks_left_to_process: Gauge, + /// Total latency of snapshot generation. + #[metrics(buckets = Buckets::LATENCIES, unit = Unit::Seconds)] + pub snapshot_generation_duration: Histogram, + /// L1 batch number for the most recently generated snapshot. Set *after* the snapshot + /// is fully generated. + pub snapshot_l1_batch: Gauge, + /// Latency of storage log chunk processing split by stage. + #[metrics(buckets = Buckets::LATENCIES, unit = Unit::Seconds)] + pub storage_logs_processing_duration: Family>, + /// Latency of factory deps processing split by stage. + #[metrics(buckets = Buckets::LATENCIES, unit = Unit::Seconds)] + pub factory_deps_processing_duration: Family>, +} + +#[vise::register] +pub(crate) static METRICS: vise::Global = vise::Global::new(); diff --git a/core/bin/snapshots_creator/src/tests.rs b/core/bin/snapshots_creator/src/tests.rs new file mode 100644 index 000000000000..33d7a225b7d6 --- /dev/null +++ b/core/bin/snapshots_creator/src/tests.rs @@ -0,0 +1,241 @@ +//! Lower-level tests for the snapshot creator component. + +use std::collections::{HashMap, HashSet}; + +use rand::{thread_rng, Rng}; +use zksync_dal::StorageProcessor; +use zksync_types::{ + block::{BlockGasCount, L1BatchHeader, MiniblockHeader}, + snapshots::{SnapshotFactoryDependency, SnapshotStorageLog}, + AccountTreeId, Address, ProtocolVersion, StorageKey, StorageLog, H256, +}; + +use super::*; + +fn gen_storage_logs(rng: &mut impl Rng, count: usize) -> Vec { + (0..count) + .map(|_| { + let key = StorageKey::new(AccountTreeId::from_fixed_bytes(rng.gen()), H256(rng.gen())); + StorageLog::new_write_log(key, H256(rng.gen())) + }) + .collect() +} + +fn gen_factory_deps(rng: &mut impl Rng, count: usize) -> HashMap> { + (0..count) + .map(|_| { + let factory_len = 32 * rng.gen_range(32..256); + let mut factory = vec![0_u8; factory_len]; + rng.fill_bytes(&mut factory); + (H256(rng.gen()), factory) + }) + .collect() +} + +#[derive(Debug, Default)] +struct ExpectedOutputs { + deps: HashSet, + storage_logs: HashSet, +} + +async fn create_miniblock( + conn: &mut StorageProcessor<'_>, + miniblock_number: MiniblockNumber, + block_logs: Vec, +) { + let miniblock_header = MiniblockHeader { + number: miniblock_number, + timestamp: 0, + hash: H256::from_low_u64_be(u64::from(miniblock_number.0)), + l1_tx_count: 0, + l2_tx_count: 0, + base_fee_per_gas: 0, + l1_gas_price: 0, + l2_fair_gas_price: 0, + base_system_contracts_hashes: Default::default(), + protocol_version: Some(Default::default()), + virtual_blocks: 0, + }; + + conn.blocks_dal() + .insert_miniblock(&miniblock_header) + .await + .unwrap(); + conn.storage_logs_dal() + .insert_storage_logs(miniblock_number, &[(H256::zero(), block_logs)]) + .await; +} + +async fn create_l1_batch( + conn: &mut StorageProcessor<'_>, + l1_batch_number: L1BatchNumber, + logs_for_initial_writes: &[StorageLog], +) { + let mut header = L1BatchHeader::new( + l1_batch_number, + 0, + Address::default(), + Default::default(), + Default::default(), + ); + header.is_finished = true; + conn.blocks_dal() + .insert_l1_batch(&header, &[], BlockGasCount::default(), &[], &[]) + .await + .unwrap(); + conn.blocks_dal() + .mark_miniblocks_as_executed_in_l1_batch(l1_batch_number) + .await + .unwrap(); + + let mut written_keys: Vec<_> = logs_for_initial_writes.iter().map(|log| log.key).collect(); + written_keys.sort_unstable(); + conn.storage_logs_dedup_dal() + .insert_initial_writes(l1_batch_number, &written_keys) + .await; +} + +async fn prepare_postgres( + rng: &mut impl Rng, + conn: &mut StorageProcessor<'_>, + block_count: u32, +) -> ExpectedOutputs { + conn.protocol_versions_dal() + .save_protocol_version_with_tx(ProtocolVersion::default()) + .await; + + let mut outputs = ExpectedOutputs::default(); + for block_number in 0..block_count { + let logs = gen_storage_logs(rng, 100); + create_miniblock(conn, MiniblockNumber(block_number), logs.clone()).await; + + let factory_deps = gen_factory_deps(rng, 10); + conn.storage_dal() + .insert_factory_deps(MiniblockNumber(block_number), &factory_deps) + .await; + + // Since we generate `logs` randomly, all of them are written the first time. + create_l1_batch(conn, L1BatchNumber(block_number), &logs).await; + + if block_number + 1 < block_count { + let factory_deps = + factory_deps + .into_values() + .map(|bytecode| SnapshotFactoryDependency { + bytecode: bytecode.into(), + }); + outputs.deps.extend(factory_deps); + + let hashed_keys: Vec<_> = logs.iter().map(|log| log.key.hashed_key()).collect(); + let expected_l1_batches_and_indices = conn + .storage_logs_dal() + .get_l1_batches_and_indices_for_initial_writes(&hashed_keys) + .await; + + let logs = logs.into_iter().map(|log| { + let (l1_batch_number_of_initial_write, enumeration_index) = + expected_l1_batches_and_indices[&log.key.hashed_key()]; + SnapshotStorageLog { + key: log.key, + value: log.value, + l1_batch_number_of_initial_write, + enumeration_index, + } + }); + outputs.storage_logs.extend(logs); + } + } + outputs +} + +#[tokio::test] +async fn persisting_snapshot_metadata() { + let pool = ConnectionPool::test_pool().await; + let mut rng = thread_rng(); + let object_store_factory = ObjectStoreFactory::mock(); + let object_store = object_store_factory.create_store().await; + + // Insert some data to Postgres. + let mut conn = pool.access_storage().await.unwrap(); + prepare_postgres(&mut rng, &mut conn, 10).await; + + run(object_store, pool.clone(), pool.clone(), MIN_CHUNK_COUNT) + .await + .unwrap(); + + // Check snapshot metadata in Postgres. + let snapshots = conn.snapshots_dal().get_all_snapshots().await.unwrap(); + assert_eq!(snapshots.snapshots_l1_batch_numbers.len(), 1); + let snapshot_l1_batch_number = snapshots.snapshots_l1_batch_numbers[0]; + assert_eq!(snapshot_l1_batch_number, L1BatchNumber(8)); + + let snapshot_metadata = conn + .snapshots_dal() + .get_snapshot_metadata(snapshot_l1_batch_number) + .await + .unwrap() + .expect("No snapshot metadata"); + assert_eq!(snapshot_metadata.l1_batch_number, snapshot_l1_batch_number); + let factory_deps_path = &snapshot_metadata.factory_deps_filepath; + assert!(factory_deps_path.ends_with(".proto.gzip")); + assert_eq!( + snapshot_metadata.storage_logs_filepaths.len(), + MIN_CHUNK_COUNT as usize + ); + for path in &snapshot_metadata.storage_logs_filepaths { + let path = path.strip_prefix("storage_logs_snapshots/").unwrap(); + assert!(path.ends_with(".proto.gzip")); + } +} + +#[tokio::test] +async fn persisting_snapshot_factory_deps() { + let pool = ConnectionPool::test_pool().await; + let mut rng = thread_rng(); + let object_store_factory = ObjectStoreFactory::mock(); + let object_store = object_store_factory.create_store().await; + + // Insert some data to Postgres. + let mut conn = pool.access_storage().await.unwrap(); + let expected_outputs = prepare_postgres(&mut rng, &mut conn, 10).await; + + run(object_store, pool.clone(), pool.clone(), MIN_CHUNK_COUNT) + .await + .unwrap(); + let snapshot_l1_batch_number = L1BatchNumber(8); + + let object_store = object_store_factory.create_store().await; + let SnapshotFactoryDependencies { factory_deps } = + object_store.get(snapshot_l1_batch_number).await.unwrap(); + let actual_deps: HashSet<_> = factory_deps.into_iter().collect(); + assert_eq!(actual_deps, expected_outputs.deps); +} + +#[tokio::test] +async fn persisting_snapshot_logs() { + let pool = ConnectionPool::test_pool().await; + let mut rng = thread_rng(); + let object_store_factory = ObjectStoreFactory::mock(); + let object_store = object_store_factory.create_store().await; + + // Insert some data to Postgres. + let mut conn = pool.access_storage().await.unwrap(); + let expected_outputs = prepare_postgres(&mut rng, &mut conn, 10).await; + + run(object_store, pool.clone(), pool.clone(), MIN_CHUNK_COUNT) + .await + .unwrap(); + let snapshot_l1_batch_number = L1BatchNumber(8); + + let object_store = object_store_factory.create_store().await; + let mut actual_logs = HashSet::new(); + for chunk_id in 0..MIN_CHUNK_COUNT { + let key = SnapshotStorageLogsStorageKey { + l1_batch_number: snapshot_l1_batch_number, + chunk_id, + }; + let chunk: SnapshotStorageLogsChunk = object_store.get(key).await.unwrap(); + actual_logs.extend(chunk.storage_logs.into_iter()); + } + assert_eq!(actual_logs, expected_outputs.storage_logs); +} diff --git a/core/lib/constants/src/contracts.rs b/core/lib/constants/src/contracts.rs index d74c0e0319a7..5e49f83e5e1d 100644 --- a/core/lib/constants/src/contracts.rs +++ b/core/lib/constants/src/contracts.rs @@ -95,6 +95,16 @@ pub const SHA256_PRECOMPILE_ADDRESS: Address = H160([ 0x00, 0x00, 0x00, 0x02, ]); +pub const EC_ADD_PRECOMPILE_ADDRESS: Address = H160([ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x06, +]); + +pub const EC_MUL_PRECOMPILE_ADDRESS: Address = H160([ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x07, +]); + pub const ERC20_TRANSFER_TOPIC: H256 = H256([ 221, 242, 82, 173, 27, 226, 200, 155, 105, 194, 176, 104, 252, 55, 141, 170, 149, 43, 167, 241, 99, 196, 161, 22, 40, 245, 90, 77, 245, 35, 179, 239, diff --git a/core/lib/dal/migrations/20231208134254_drop_old_witness_generation_related_tables.down.sql b/core/lib/dal/migrations/20231208134254_drop_old_witness_generation_related_tables.down.sql new file mode 100644 index 000000000000..0f4351be7b77 --- /dev/null +++ b/core/lib/dal/migrations/20231208134254_drop_old_witness_generation_related_tables.down.sql @@ -0,0 +1,83 @@ +CREATE TABLE IF NOT EXISTS witness_inputs +( + l1_batch_number BIGINT NOT NULL PRIMARY KEY, + merkle_tree_paths BYTEA, + created_at TIMESTAMP NOT NULL, + updated_at TIMESTAMP NOT NULL, + status TEXT NOT NULL, + time_taken TIME DEFAULT '00:00:00'::TIME WITHOUT TIME ZONE NOT NULL, + processing_started_at TIMESTAMP, + error VARCHAR, + attempts INTEGER DEFAULT 0 NOT NULL, + merkel_tree_paths_blob_url TEXT, + is_blob_cleaned boolean DEFAULT false NOT NULL, + protocol_version INTEGER + CONSTRAINT witness_inputs_prover_protocol_version_fkey REFERENCES prover_protocol_versions +); +CREATE INDEX IF NOT EXISTS witness_inputs_blob_cleanup_status_index ON witness_inputs (status, is_blob_cleaned); + + +CREATE TABLE leaf_aggregation_witness_jobs +( + l1_batch_number BIGINT NOT NULL PRIMARY KEY, + basic_circuits BYTEA NOT NULL, + basic_circuits_inputs BYTEA NOT NULL, + number_of_basic_circuits INTEGER NOT NULL, + status TEXT NOT NULL, + processing_started_at TIMESTAMP, + time_taken TIME, + error TEXT, + created_at TIMESTAMP NOT NULL, + updated_at TIMESTAMP NOT NULL, + attempts INTEGER DEFAULT 0 NOT NULL, + basic_circuits_blob_url TEXT, + basic_circuits_inputs_blob_url TEXT, + is_blob_cleaned BOOLEAN DEFAULT FALSE NOT NULL, + protocol_version INTEGER + CONSTRAINT leaf_aggregation_witness_jobs_prover_protocol_version_fkey REFERENCES prover_protocol_versions +); +CREATE INDEX IF NOT EXISTS leaf_aggregation_witness_jobs_blob_cleanup_status_index ON leaf_aggregation_witness_jobs (status, is_blob_cleaned); + + +CREATE TABLE node_aggregation_witness_jobs +( + l1_batch_number BIGINT NOT NULL PRIMARY KEY, + leaf_layer_subqueues BYTEA, + aggregation_outputs BYTEA, + number_of_leaf_circuits INTEGER, + status TEXT NOT NULL, + processing_started_at TIMESTAMP, + time_taken TIME, + error TEXT, + created_at TIMESTAMP NOT NULL, + updated_at TIMESTAMP NOT NULL, + attempts INTEGER DEFAULT 0 NOT NULL, + leaf_layer_subqueues_blob_url TEXT, + aggregation_outputs_blob_url TEXT, + is_blob_cleaned BOOLEAN DEFAULT FALSE NOT NULL, + protocol_version INTEGER + CONSTRAINT node_aggregation_witness_jobs_prover_protocol_version_fkey REFERENCES prover_protocol_versions +); +CREATE INDEX IF NOT EXISTS node_aggregation_witness_jobs_blob_cleanup_status_index ON node_aggregation_witness_jobs (status, is_blob_cleaned); + + +CREATE TABLE scheduler_witness_jobs +( + l1_batch_number BIGINT NOT NULL PRIMARY KEY, + scheduler_witness BYTEA NOT NULL, + final_node_aggregations BYTEA, + status TEXT NOT NULL, + processing_started_at TIMESTAMP, + time_taken TIME, + error TEXT, + created_at TIMESTAMP NOT NULL, + updated_at TIMESTAMP NOT NULL, + attempts INTEGER DEFAULT 0 NOT NULL, + aggregation_result_coords BYTEA, + scheduler_witness_blob_url TEXT, + final_node_aggregations_blob_url TEXT, + is_blob_cleaned BOOLEAN DEFAULT FALSE NOT NULL, + protocol_version INTEGER + CONSTRAINT scheduler_witness_jobs_prover_protocol_version_fkey REFERENCES prover_protocol_versions +); +CREATE INDEX IF NOT EXISTS scheduler_witness_jobs_blob_cleanup_status_index ON scheduler_witness_jobs (status, is_blob_cleaned); diff --git a/core/lib/dal/migrations/20231208134254_drop_old_witness_generation_related_tables.up.sql b/core/lib/dal/migrations/20231208134254_drop_old_witness_generation_related_tables.up.sql new file mode 100644 index 000000000000..54d4ba26e594 --- /dev/null +++ b/core/lib/dal/migrations/20231208134254_drop_old_witness_generation_related_tables.up.sql @@ -0,0 +1,4 @@ +DROP TABLE IF EXISTS witness_inputs; +DROP TABLE IF EXISTS leaf_aggregation_witness_jobs; +DROP TABLE IF EXISTS node_aggregation_witness_jobs; +DROP TABLE IF EXISTS scheduler_witness_jobs; diff --git a/core/lib/dal/sqlx-data.json b/core/lib/dal/sqlx-data.json index 750e20896b20..1ca26edfdeaa 100644 --- a/core/lib/dal/sqlx-data.json +++ b/core/lib/dal/sqlx-data.json @@ -1,37 +1,51 @@ { "db": "PostgreSQL", - "0002e8b596794ae9396de8ac621b30dcf0befdff28c5bc23d713185f7a410df4": { + "00b88ec7fcf40bb18e0018b7c76f6e1df560ab1e8935564355236e90b6147d2f": { "describe": { "columns": [], "nullable": [], "parameters": { "Left": [ - "Text", + "Time", + "Int8" + ] + } + }, + "query": "\n UPDATE scheduler_witness_jobs_fri\n SET\n status = 'successful',\n updated_at = NOW(),\n time_taken = $1\n WHERE\n l1_batch_number = $2\n " + }, + "012bed5d34240ed28c331c8515c381d82925556a4801f678b8786235d525d784": { + "describe": { + "columns": [], + "nullable": [], + "parameters": { + "Left": [ + "Int4", + "Int8", "Int8" ] } }, - "query": "UPDATE proof_generation_details SET status=$1, updated_at = now() WHERE l1_batch_number = $2" + "query": "\n UPDATE l1_batches\n SET\n eth_commit_tx_id = $1,\n updated_at = NOW()\n WHERE\n number BETWEEN $2 AND $3\n " }, - "002a901f2802beb48e4d15437fba9a04885a5e4f8f17089a09f31edfd7b3d0bb": { + "015350f8d729ef490553550a68f07703b2581dda4fe3c00be6c5422c78980c4b": { "describe": { "columns": [ { - "name": "number", + "name": "max?", "ordinal": 0, - "type_info": "Int8" + "type_info": "Int4" } ], "nullable": [ - false + null ], "parameters": { "Left": [] } }, - "query": "SELECT number FROM miniblocks WHERE consensus IS NOT NULL ORDER BY number DESC LIMIT 1" + "query": "\n SELECT\n MAX(id) AS \"max?\"\n FROM\n protocol_versions\n " }, - "00bd80fd83aff559d8d9232c2e98a12a1dd2c8f31792cd915e2cf11f28e583b7": { + "01ac5343beb09ec5bd45b39d560e57a83f37da8999849377dfad60b44989be39": { "describe": { "columns": [ { @@ -134,179 +148,108 @@ ] } }, - "query": "\n UPDATE node_aggregation_witness_jobs_fri\n SET status = 'in_progress', attempts = attempts + 1,\n updated_at = now(), processing_started_at = now(),\n picked_by = $2\n WHERE id = (\n SELECT id\n FROM node_aggregation_witness_jobs_fri\n WHERE status = 'queued'\n AND protocol_version = ANY($1)\n ORDER BY l1_batch_number ASC, depth ASC, id ASC\n LIMIT 1\n FOR UPDATE\n SKIP LOCKED\n )\n RETURNING node_aggregation_witness_jobs_fri.*\n " + "query": "\n UPDATE node_aggregation_witness_jobs_fri\n SET\n status = 'in_progress',\n attempts = attempts + 1,\n updated_at = NOW(),\n processing_started_at = NOW(),\n picked_by = $2\n WHERE\n id = (\n SELECT\n id\n FROM\n node_aggregation_witness_jobs_fri\n WHERE\n status = 'queued'\n AND protocol_version = ANY ($1)\n ORDER BY\n l1_batch_number ASC,\n depth ASC,\n id ASC\n LIMIT\n 1\n FOR UPDATE\n SKIP LOCKED\n )\n RETURNING\n node_aggregation_witness_jobs_fri.*\n " }, - "0141169c8375ae975598aca5351ea162948f72b2c325619f57c756db028bed74": { + "01e4cde73867da612084c3f6fe882d56bbace9013f1d95ea0926eef1fb48039b": { "describe": { "columns": [ { - "name": "id", + "name": "l1_batch_number", "ordinal": 0, - "type_info": "Int4" + "type_info": "Int8" }, { - "name": "eth_tx_id", + "name": "factory_deps_filepath", "ordinal": 1, - "type_info": "Int4" - }, - { - "name": "tx_hash", - "ordinal": 2, "type_info": "Text" }, { - "name": "base_fee_per_gas", - "ordinal": 3, - "type_info": "Int8" - }, - { - "name": "priority_fee_per_gas", - "ordinal": 4, - "type_info": "Int8" - }, - { - "name": "signed_raw_tx", - "ordinal": 5, - "type_info": "Bytea" - }, - { - "name": "nonce", - "ordinal": 6, - "type_info": "Int8" + "name": "storage_logs_filepaths", + "ordinal": 2, + "type_info": "TextArray" } ], "nullable": [ false, false, - false, - false, - false, - true, false ], "parameters": { - "Left": [] + "Left": [ + "Int8" + ] } }, - "query": "SELECT eth_txs_history.id, eth_txs_history.eth_tx_id, eth_txs_history.tx_hash, eth_txs_history.base_fee_per_gas, eth_txs_history.priority_fee_per_gas, eth_txs_history.signed_raw_tx, eth_txs.nonce FROM eth_txs_history JOIN eth_txs ON eth_txs.id = eth_txs_history.eth_tx_id WHERE eth_txs_history.sent_at_block IS NULL AND eth_txs.confirmed_eth_tx_history_id IS NULL ORDER BY eth_txs_history.id DESC" + "query": "\n SELECT\n l1_batch_number,\n factory_deps_filepath,\n storage_logs_filepaths\n FROM\n snapshots\n WHERE\n l1_batch_number = $1\n " }, - "01a21fe42c5c0ec0f848739235b8175b62b0ffe503b823c128dd620fec047784": { + "01f72dfc1eee6360a8ef7809874a1b4ba7fe355ebc02ea49a054aa073ce324ba": { "describe": { "columns": [], "nullable": [], "parameters": { "Left": [ - "Text", - "Int4", - "Text" + "ByteaArray", + "ByteaArray" ] } }, - "query": "UPDATE gpu_prover_queue_fri SET instance_status = 'available', updated_at = now() WHERE instance_host = $1::text::inet AND instance_port = $2 AND instance_status = 'full' AND zone = $3\n " + "query": "\n UPDATE storage\n SET\n value = u.value\n FROM\n UNNEST($1::bytea[], $2::bytea[]) AS u (key, value)\n WHERE\n u.key = hashed_key\n " }, - "01ebdc5b524e85033fb06d9166475f365643f744492e59ff12f10b419dd6d485": { + "026ab7dd7407f10074a2966b5eac2563a3e061bcc6505d8c295b1b2517f85f1b": { "describe": { "columns": [ { - "name": "bytecode_hash", + "name": "number", "ordinal": 0, - "type_info": "Bytea" + "type_info": "Int8" } ], "nullable": [ false ], + "parameters": { + "Left": [] + } + }, + "query": "\n SELECT\n number\n FROM\n l1_batches\n LEFT JOIN eth_txs_history AS prove_tx ON (l1_batches.eth_prove_tx_id = prove_tx.eth_tx_id)\n WHERE\n prove_tx.confirmed_at IS NOT NULL\n ORDER BY\n number DESC\n LIMIT\n 1\n " + }, + "03c585c7e9f918e608757496088c7e3b6bdb2a08149d5f443310607d3c78988c": { + "describe": { + "columns": [ + { + "name": "storage_refunds", + "ordinal": 0, + "type_info": "Int8Array" + } + ], + "nullable": [ + true + ], "parameters": { "Left": [ "Int8" ] } }, - "query": "SELECT bytecode_hash FROM factory_deps WHERE miniblock_number > $1" + "query": "\n SELECT\n storage_refunds\n FROM\n l1_batches\n WHERE\n number = $1\n " }, - "03a34f0fd82bed22f14c5b36554bb958d407e9724fa5ea5123edc3c6607e545c": { + "04fbbd198108d2614a3b29fa795994723ebe57b3ed209069bd3db906921ef1a3": { "describe": { "columns": [ { - "name": "block_hash?", + "name": "min?", "ordinal": 0, - "type_info": "Bytea" - }, - { - "name": "address!", - "ordinal": 1, - "type_info": "Bytea" - }, - { - "name": "topic1!", - "ordinal": 2, - "type_info": "Bytea" - }, - { - "name": "topic2!", - "ordinal": 3, - "type_info": "Bytea" - }, - { - "name": "topic3!", - "ordinal": 4, - "type_info": "Bytea" - }, - { - "name": "topic4!", - "ordinal": 5, - "type_info": "Bytea" - }, - { - "name": "value!", - "ordinal": 6, - "type_info": "Bytea" - }, - { - "name": "miniblock_number!", - "ordinal": 7, "type_info": "Int8" }, { - "name": "l1_batch_number?", - "ordinal": 8, + "name": "max?", + "ordinal": 1, "type_info": "Int8" - }, - { - "name": "tx_hash!", - "ordinal": 9, - "type_info": "Bytea" - }, - { - "name": "tx_index_in_block!", - "ordinal": 10, - "type_info": "Int4" - }, - { - "name": "event_index_in_block!", - "ordinal": 11, - "type_info": "Int4" - }, - { - "name": "event_index_in_tx!", - "ordinal": 12, - "type_info": "Int4" } ], "nullable": [ - true, - true, - true, - true, - true, - true, - true, - true, - true, - true, - true, - true, - true + null, + null ], "parameters": { "Left": [ @@ -314,19 +257,25 @@ ] } }, - "query": "\n WITH events_select AS (\n SELECT\n address, topic1, topic2, topic3, topic4, value,\n miniblock_number, tx_hash, tx_index_in_block,\n event_index_in_block, event_index_in_tx\n FROM events\n WHERE miniblock_number > $1\n ORDER BY miniblock_number ASC, event_index_in_block ASC\n )\n SELECT miniblocks.hash as \"block_hash?\",\n address as \"address!\", topic1 as \"topic1!\", topic2 as \"topic2!\", topic3 as \"topic3!\", topic4 as \"topic4!\", value as \"value!\",\n miniblock_number as \"miniblock_number!\", miniblocks.l1_batch_number as \"l1_batch_number?\", tx_hash as \"tx_hash!\",\n tx_index_in_block as \"tx_index_in_block!\", event_index_in_block as \"event_index_in_block!\", event_index_in_tx as \"event_index_in_tx!\"\n FROM events_select\n INNER JOIN miniblocks ON events_select.miniblock_number = miniblocks.number\n ORDER BY miniblock_number ASC, event_index_in_block ASC\n " + "query": "\n SELECT\n MIN(miniblocks.number) AS \"min?\",\n MAX(miniblocks.number) AS \"max?\"\n FROM\n miniblocks\n WHERE\n l1_batch_number = $1\n " }, - "06d90ea65c1e06bd871f090a0fb0e8772ea5e923f1da5310bedd8dc90e0827f4": { + "05267e9774056bb0f984918ab861a2ee78eb59628d0429e89b27d185f83512be": { "describe": { "columns": [ { - "name": "eth_commit_tx_id", + "name": "tx_hash", "ordinal": 0, - "type_info": "Int4" + "type_info": "Bytea" + }, + { + "name": "call_trace", + "ordinal": 1, + "type_info": "Bytea" } ], "nullable": [ - true + false, + false ], "parameters": { "Left": [ @@ -334,7 +283,20 @@ ] } }, - "query": "SELECT eth_commit_tx_id FROM l1_batches WHERE number = $1" + "query": "\n SELECT\n *\n FROM\n call_traces\n WHERE\n tx_hash IN (\n SELECT\n hash\n FROM\n transactions\n WHERE\n miniblock_number = $1\n )\n " + }, + "0587fadb4f7a014caddf9e540cd2a1ece830de8777d945d48bd9c796fefb3253": { + "describe": { + "columns": [], + "nullable": [], + "parameters": { + "Left": [ + "Text", + "Int8" + ] + } + }, + "query": "\n UPDATE prover_jobs\n SET\n status = $1,\n updated_at = NOW()\n WHERE\n id = $2\n " }, "07310d96fc7e258154ad510684e33d196907ebd599e926d305e5ef9f26afa2fa": { "describe": { @@ -358,87 +320,116 @@ }, "query": "INSERT INTO eth_txs_history (eth_tx_id, base_fee_per_gas, priority_fee_per_gas, tx_hash, signed_raw_tx, created_at, updated_at, confirmed_at) VALUES ($1, 0, 0, $2, '\\x00', now(), now(), $3) RETURNING id" }, - "07bb6aa5f4ffe0b753cca8ac92c65bd7618db908250e5bf9e835f54b1dd04755": { + "08024b2ba970d2fdac2a71c9c7c73be42a289d034670ca4e644f5df1e4614ddf": { "describe": { "columns": [], "nullable": [], "parameters": { "Left": [ "Int8", - "TextArray", - "Text" + "Text", + "Int4", + "Bytea", + "Int4", + "Text", + "Int4" ] } }, - "query": "INSERT INTO snapshots (l1_batch_number, storage_logs_filepaths, factory_deps_filepath, created_at, updated_at) VALUES ($1, $2, $3, NOW(), NOW())" + "query": "\n INSERT INTO\n prover_jobs (\n l1_batch_number,\n circuit_type,\n sequence_number,\n prover_input,\n aggregation_round,\n circuit_input_blob_url,\n protocol_version,\n status,\n created_at,\n updated_at\n )\n VALUES\n ($1, $2, $3, $4, $5, $6, $7, 'queued', NOW(), NOW())\n ON CONFLICT (l1_batch_number, aggregation_round, sequence_number) DO NOTHING\n " }, - "09768b376996b96add16a02d1a59231cb9b525cd5bd19d22a76149962d4c91c2": { + "083991abb3f1c2183d1bd1fb2ad4710daa723e2d9a23317c347f6081465c3643": { + "describe": { + "columns": [ + { + "name": "attempts", + "ordinal": 0, + "type_info": "Int2" + } + ], + "nullable": [ + false + ], + "parameters": { + "Left": [ + { + "Custom": { + "kind": { + "Enum": [ + "Queued", + "ManuallySkipped", + "InProgress", + "Successful", + "Failed" + ] + }, + "name": "basic_witness_input_producer_job_status" + } + }, + "Int8", + "Time", + "Text", + { + "Custom": { + "kind": { + "Enum": [ + "Queued", + "ManuallySkipped", + "InProgress", + "Successful", + "Failed" + ] + }, + "name": "basic_witness_input_producer_job_status" + } + } + ] + } + }, + "query": "\n UPDATE basic_witness_input_producer_jobs\n SET\n status = $1,\n updated_at = NOW(),\n time_taken = $3,\n error = $4\n WHERE\n l1_batch_number = $2\n AND status != $5\n RETURNING\n basic_witness_input_producer_jobs.attempts\n " + }, + "08e59ed8e2fd1a74e19d8bf0d131e4ee6682a89fb86f3b715a240805d44e6d87": { "describe": { "columns": [], "nullable": [], "parameters": { "Left": [ - "Bytea", - "Bytea", - "Bytea", - "Bytea", - "Bytea", - "Bytea", - "Bool", - "Bytea", "Int8", - "Bytea", - "Bytea", - "Bytea", - "Int8" + "Text" ] } }, - "query": "UPDATE l1_batches SET hash = $1, merkle_root_hash = $2, compressed_repeated_writes = $3, compressed_initial_writes = $4, l2_l1_compressed_messages = $5, l2_l1_merkle_root = $6, zkporter_is_available = $7, parent_hash = $8, rollup_last_leaf_index = $9, pass_through_data_hash = $10, meta_parameters_hash = $11, compressed_state_diffs = $12, updated_at = now() WHERE number = $13 AND hash IS NULL" + "query": "\n INSERT INTO\n proof_generation_details (l1_batch_number, status, proof_gen_data_blob_url, created_at, updated_at)\n VALUES\n ($1, 'ready_to_be_proven', $2, NOW(), NOW())\n ON CONFLICT (l1_batch_number) DO NOTHING\n " }, - "0a3c928a616b5ebc0b977bd773edcde721ca1c652ae2f8db41fb75cecdecb674": { + "0914f0ad03d6a8c55d287f94917c6f03469d78bf4f45f5fd1eaf37171db2f04a": { "describe": { "columns": [ { - "name": "count", + "name": "l1_batch_number", "ordinal": 0, "type_info": "Int8" } ], "nullable": [ - null + false ], "parameters": { - "Left": [ - "Int8" - ] + "Left": [] } }, - "query": "SELECT COUNT(*) FROM storage_logs WHERE miniblock_number = $1" + "query": "\n SELECT\n l1_batch_number\n FROM\n proof_generation_details\n WHERE\n status NOT IN ('generated', 'skipped')\n ORDER BY\n l1_batch_number ASC\n LIMIT\n 1\n " }, - "0cbbcd30fde109c4c44162f94b6ed9bab4e9db9948d03e584c2cab543449d298": { + "0a3c928a616b5ebc0b977bd773edcde721ca1c652ae2f8db41fb75cecdecb674": { "describe": { "columns": [ { - "name": "status", + "name": "count", "ordinal": 0, - "type_info": "Text" - }, - { - "name": "error", - "ordinal": 1, - "type_info": "Text" - }, - { - "name": "compilation_errors", - "ordinal": 2, - "type_info": "Jsonb" + "type_info": "Int8" } ], "nullable": [ - false, - true, - true + null ], "parameters": { "Left": [ @@ -446,63 +437,119 @@ ] } }, - "query": "SELECT status, error, compilation_errors FROM contract_verification_requests WHERE id = $1" + "query": "SELECT COUNT(*) FROM storage_logs WHERE miniblock_number = $1" }, - "0d1bed183c38304ff1a6c8c78dca03964e2e188a6d01f98eaf0c6b24f19b8b6f": { + "0a3cb11f5bdcb8da31dbd4e3016fced141fb29dd8b6c32dd2dc3452dc294fe1f": { "describe": { "columns": [], "nullable": [], "parameters": { "Left": [ - "ByteaArray" + "Int4", + "Int8", + "Bytea", + "Bytea", + "Bytea", + "Bytea", + "Bytea", + "Bytea", + "Bytea", + "Bytea" + ] + } + }, + "query": "\n INSERT INTO\n protocol_versions (\n id,\n timestamp,\n recursion_scheduler_level_vk_hash,\n recursion_node_level_vk_hash,\n recursion_leaf_level_vk_hash,\n recursion_circuits_set_vks_hash,\n bootloader_code_hash,\n default_account_code_hash,\n verifier_address,\n upgrade_tx_hash,\n created_at\n )\n VALUES\n ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, NOW())\n " + }, + "0a53fc3c90a14038c9f3f32c3e2e5f7edcafa4fc6757264a96a46dbf7dd1f9cc": { + "describe": { + "columns": [], + "nullable": [], + "parameters": { + "Left": [ + "Bytea", + "Bytea", + "Numeric", + "Numeric", + "Numeric", + "Jsonb", + "Int8", + "Numeric", + "Numeric", + "Bytea", + "Int4", + "Numeric", + "Bytea", + "Bytea", + "Int4", + "Numeric", + "Bytea", + "Timestamp" ] } }, - "query": "UPDATE transactions SET in_mempool = FALSE FROM UNNEST ($1::bytea[]) AS s(address) WHERE transactions.in_mempool = TRUE AND transactions.initiator_address = s.address" + "query": "\n INSERT INTO\n transactions (\n hash,\n is_priority,\n initiator_address,\n gas_limit,\n max_fee_per_gas,\n gas_per_pubdata_limit,\n data,\n priority_op_id,\n full_fee,\n layer_2_tip_fee,\n contract_address,\n l1_block_number,\n value,\n paymaster,\n paymaster_input,\n tx_format,\n l1_tx_mint,\n l1_tx_refund_recipient,\n received_at,\n created_at,\n updated_at\n )\n VALUES\n (\n $1,\n TRUE,\n $2,\n $3,\n $4,\n $5,\n $6,\n $7,\n $8,\n $9,\n $10,\n $11,\n $12,\n $13,\n $14,\n $15,\n $16,\n $17,\n $18,\n NOW(),\n NOW()\n )\n ON CONFLICT (hash) DO NOTHING\n " }, - "0d99b4015b29905862991e4f1a44a1021d48f50e99cb1701e7496ce6c3e15dc6": { + "0bdcf87f6910c7222b621f76f71bc6e326e15dca141050bc9d7dacae98a430e8": { "describe": { "columns": [ { - "name": "number", + "name": "hash", "ordinal": 0, - "type_info": "Int8" + "type_info": "Bytea" } ], "nullable": [ - null + true ], "parameters": { - "Left": [] + "Left": [ + "Int8" + ] } }, - "query": "SELECT MAX(number) as \"number\" FROM l1_batches WHERE is_finished = TRUE" + "query": "\n SELECT\n hash\n FROM\n l1_batches\n WHERE\n number = $1\n " }, - "0e001ef507253b4fd3a87e379c8f2e63fa41250b1a396d81697de2b7ea71215e": { + "0c899c68886f76a232ffac0454cdfbf962636347864fc365fafa46c7a2da5f30": { "describe": { "columns": [ { - "name": "count!", + "name": "virtual_blocks", "ordinal": 0, "type_info": "Int8" } ], "nullable": [ - null + false ], "parameters": { "Left": [ - "Int8", - "Bytea", - "Bytea", - "Bytea", - "Bytea" + "Int8" + ] + } + }, + "query": "\n SELECT\n virtual_blocks\n FROM\n miniblocks\n WHERE\n number = $1\n " + }, + "0c95fbfb3a816bd49fd06e3a4f0a52daa202279bf612a9278f663deb78bc6e41": { + "describe": { + "columns": [ + { + "name": "protocol_version", + "ordinal": 0, + "type_info": "Int4" + } + ], + "nullable": [ + true + ], + "parameters": { + "Left": [ + "Int8" ] } }, - "query": "SELECT COUNT(*) as \"count!\" FROM l1_batches WHERE number = $1 AND hash = $2 AND merkle_root_hash = $3 AND parent_hash = $4 AND l2_l1_merkle_root = $5" + "query": "\n SELECT\n protocol_version\n FROM\n l1_batches\n WHERE\n number = $1\n " }, - "0ee31e6e2ec60f427d8dec719ec0ba03ef75bc610e878ae32b0bf61c4c2c1366": { + "0d13b8947b1bafa9e5bc6fdc70a986511265c541d81b1d21f0a751ae1399c626": { "describe": { "columns": [ { @@ -570,113 +617,86 @@ ] } }, - "query": "UPDATE gpu_prover_queue_fri SET instance_status = 'reserved', updated_at = now(), processing_started_at = now() WHERE id in ( SELECT id FROM gpu_prover_queue_fri WHERE specialized_prover_group_id=$2 AND zone=$3 AND ( instance_status = 'available' OR (instance_status = 'reserved' AND processing_started_at < now() - $1::interval) ) ORDER BY updated_at ASC LIMIT 1 FOR UPDATE SKIP LOCKED ) RETURNING gpu_prover_queue_fri.*\n " + "query": "\n UPDATE gpu_prover_queue_fri\n SET\n instance_status = 'reserved',\n updated_at = NOW(),\n processing_started_at = NOW()\n WHERE\n id IN (\n SELECT\n id\n FROM\n gpu_prover_queue_fri\n WHERE\n specialized_prover_group_id = $2\n AND zone = $3\n AND (\n instance_status = 'available'\n OR (\n instance_status = 'reserved'\n AND processing_started_at < NOW() - $1::INTERVAL\n )\n )\n ORDER BY\n updated_at ASC\n LIMIT\n 1\n FOR UPDATE\n SKIP LOCKED\n )\n RETURNING\n gpu_prover_queue_fri.*\n " }, - "0f5897b5e0109535caa3d49f899c65e5080511d49305558b59b185c34227aa18": { + "0e1317c908de3d9b9b87b51802cbe545198d7debecd65dc2165731c8a0c0f508": { "describe": { "columns": [ { - "name": "nonce!", + "name": "l1_batch_number!", "ordinal": 0, "type_info": "Int8" + }, + { + "name": "circuit_type", + "ordinal": 1, + "type_info": "Text" } ], "nullable": [ - true + null, + false ], "parameters": { - "Left": [ - "Bytea", - "Int8" - ] + "Left": [] } }, - "query": "SELECT nonce as \"nonce!\" FROM transactions WHERE initiator_address = $1 AND nonce >= $2 AND is_priority = FALSE AND (miniblock_number IS NOT NULL OR error IS NULL) ORDER BY nonce" + "query": "\n SELECT\n MIN(l1_batch_number) AS \"l1_batch_number!\",\n circuit_type\n FROM\n prover_jobs\n WHERE\n aggregation_round = 0\n AND (\n status = 'queued'\n OR status = 'in_progress'\n OR status = 'in_gpu_proof'\n OR status = 'failed'\n )\n GROUP BY\n circuit_type\n " }, - "0f8a603899280c015b033c4160bc064865103e9d6d63a369f07a8e5d859a7b14": { + "10959c91f01ce0da196f4c6eaf0661a097308d9f81024fdfef24a14418202730": { "describe": { "columns": [ { - "name": "timestamp", + "name": "verification_info", "ordinal": 0, - "type_info": "Int8" + "type_info": "Jsonb" } ], "nullable": [ - false + true ], "parameters": { "Left": [ - "Int8" + "Bytea" ] } }, - "query": "SELECT timestamp FROM miniblocks WHERE number = $1" + "query": "\n SELECT\n verification_info\n FROM\n contracts_verification_info\n WHERE\n address = $1\n " }, - "0fd885074c624bea478ec0a24a499cf1278773cdba92550439da5d3b70cbf38c": { + "11af69fc254e54449b64c086667700a95e4c37a7a18531b3cdf120394cb055b9": { "describe": { "columns": [ { - "name": "count!", + "name": "l1_batch_number", "ordinal": 0, "type_info": "Int8" - }, - { - "name": "status!", - "ordinal": 1, - "type_info": "Text" } ], "nullable": [ - null, false ], "parameters": { - "Left": [] + "Left": [ + "Interval" + ] } }, - "query": "\n SELECT COUNT(*) as \"count!\", status as \"status!\"\n FROM prover_jobs\n GROUP BY status\n " + "query": "\n UPDATE proof_generation_details\n SET\n status = 'picked_by_prover',\n updated_at = NOW(),\n prover_taken_at = NOW()\n WHERE\n l1_batch_number = (\n SELECT\n l1_batch_number\n FROM\n proof_generation_details\n WHERE\n status = 'ready_to_be_proven'\n OR (\n status = 'picked_by_prover'\n AND prover_taken_at < NOW() - $1::INTERVAL\n )\n ORDER BY\n l1_batch_number ASC\n LIMIT\n 1\n FOR UPDATE\n SKIP LOCKED\n )\n RETURNING\n proof_generation_details.l1_batch_number\n " }, - "13e5f6a2a73eaa979229611ffdbed86d6e5e1bad0c645d39b56fdc47f5c17971": { + "12ab208f416e2875f89e558f0d4aff3a06b7a9c1866132d62e4449fa9436c7c4": { "describe": { - "columns": [ - { - "name": "hashed_key", - "ordinal": 0, - "type_info": "Bytea" - } - ], - "nullable": [ - false - ], + "columns": [], + "nullable": [], "parameters": { "Left": [ - "Int8", + "Text", "Int8" ] } }, - "query": "SELECT DISTINCT hashed_key FROM storage_logs WHERE miniblock_number BETWEEN $1 and $2" - }, - "14815f61d37d274f9aea1125ca4d368fd8c45098b0017710c0ee18d23d994c15": { - "describe": { - "columns": [ - { - "name": "number", - "ordinal": 0, - "type_info": "Int8" - } - ], - "nullable": [ - false - ], - "parameters": { - "Left": [] - } - }, - "query": "SELECT number FROM l1_batches LEFT JOIN eth_txs_history AS prove_tx ON (l1_batches.eth_prove_tx_id = prove_tx.eth_tx_id) WHERE prove_tx.confirmed_at IS NOT NULL ORDER BY number DESC LIMIT 1" + "query": "\n UPDATE node_aggregation_witness_jobs_fri\n SET\n status = 'failed',\n error = $1,\n updated_at = NOW()\n WHERE\n id = $2\n " }, - "157fc4ef4f5fd831399219850bc59ec0bd32d938ec8685dacaf913efdccfe7fe": { + "12ab8ba692a42f528450f2adf8d263298abc0521734f807fbf45484158b167b2": { "describe": { "columns": [ { @@ -689,64 +709,92 @@ false ], "parameters": { - "Left": [ - "Numeric" - ] + "Left": [] } }, - "query": "SELECT l1_address FROM tokens WHERE market_volume > $1" + "query": "\n SELECT\n l1_address\n FROM\n tokens\n WHERE\n well_known = FALSE\n " }, - "1658e6fce121904c1353e51663fc307b01e02bc412ee46ac17e0f5acacd0b5c4": { + "136569d7eb4037fd77e0fac2246c68e8e15a831f1a45dc3b2240d5c6809d5ef2": { "describe": { "columns": [ { - "name": "l1_batch_number", + "name": "id", "ordinal": 0, - "type_info": "Int8" + "type_info": "Int4" }, { - "name": "factory_deps_filepath", + "name": "timestamp", "ordinal": 1, - "type_info": "Text" + "type_info": "Int8" }, { - "name": "storage_logs_filepaths", + "name": "recursion_scheduler_level_vk_hash", "ordinal": 2, - "type_info": "TextArray" + "type_info": "Bytea" + }, + { + "name": "recursion_node_level_vk_hash", + "ordinal": 3, + "type_info": "Bytea" + }, + { + "name": "recursion_leaf_level_vk_hash", + "ordinal": 4, + "type_info": "Bytea" + }, + { + "name": "recursion_circuits_set_vks_hash", + "ordinal": 5, + "type_info": "Bytea" + }, + { + "name": "bootloader_code_hash", + "ordinal": 6, + "type_info": "Bytea" + }, + { + "name": "default_account_code_hash", + "ordinal": 7, + "type_info": "Bytea" + }, + { + "name": "verifier_address", + "ordinal": 8, + "type_info": "Bytea" + }, + { + "name": "upgrade_tx_hash", + "ordinal": 9, + "type_info": "Bytea" + }, + { + "name": "created_at", + "ordinal": 10, + "type_info": "Timestamp" } ], "nullable": [ false, false, + false, + false, + false, + false, + false, + false, + false, + true, false ], "parameters": { "Left": [ - "Int8" + "Int4" ] } }, - "query": "SELECT l1_batch_number, factory_deps_filepath, storage_logs_filepaths FROM snapshots WHERE l1_batch_number = $1" - }, - "166dcd8d504ba3f52a9e44a05305ed00954ab9b5302be4bb5ab05dfd2272afca": { - "describe": { - "columns": [ - { - "name": "state!", - "ordinal": 0, - "type_info": "Jsonb" - } - ], - "nullable": [ - false - ], - "parameters": { - "Left": [] - } - }, - "query": "SELECT state as \"state!\" FROM consensus_replica_state WHERE fake_key" + "query": "\n SELECT\n *\n FROM\n protocol_versions\n WHERE\n id = $1\n " }, - "16bca6f4258ff3db90a26a8550c5fc35e666fb698960486528fceba3e452fd62": { + "139318ef312eac6a70e9f4382b57920144e985bc70250f711170a47c7dfe0bec": { "describe": { "columns": [ { @@ -995,492 +1043,491 @@ ] } }, - "query": "SELECT number, l1_batches.timestamp, is_finished, l1_tx_count, l2_tx_count, fee_account_address, bloom, priority_ops_onchain_data, hash, parent_hash, commitment, compressed_write_logs, compressed_contracts, eth_prove_tx_id, eth_commit_tx_id, eth_execute_tx_id, merkle_root_hash, l2_to_l1_logs, l2_to_l1_messages, used_contract_hashes, compressed_initial_writes, compressed_repeated_writes, l2_l1_compressed_messages, l2_l1_merkle_root, l1_gas_price, l2_fair_gas_price, rollup_last_leaf_index, zkporter_is_available, l1_batches.bootloader_code_hash, l1_batches.default_aa_code_hash, base_fee_per_gas, aux_data_hash, pass_through_data_hash, meta_parameters_hash, protocol_version, compressed_state_diffs, system_logs, events_queue_commitment, bootloader_initial_content_commitment FROM l1_batches LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number JOIN protocol_versions ON protocol_versions.id = l1_batches.protocol_version WHERE eth_commit_tx_id IS NULL AND number != 0 AND protocol_versions.bootloader_code_hash = $1 AND protocol_versions.default_account_code_hash = $2 AND commitment IS NOT NULL AND (protocol_versions.id = $3 OR protocol_versions.upgrade_tx_hash IS NULL) AND events_queue_commitment IS NOT NULL AND bootloader_initial_content_commitment IS NOT NULL ORDER BY number LIMIT $4" + "query": "\n SELECT\n number,\n l1_batches.timestamp,\n is_finished,\n l1_tx_count,\n l2_tx_count,\n fee_account_address,\n bloom,\n priority_ops_onchain_data,\n hash,\n parent_hash,\n commitment,\n compressed_write_logs,\n compressed_contracts,\n eth_prove_tx_id,\n eth_commit_tx_id,\n eth_execute_tx_id,\n merkle_root_hash,\n l2_to_l1_logs,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_compressed_messages,\n l2_l1_merkle_root,\n l1_gas_price,\n l2_fair_gas_price,\n rollup_last_leaf_index,\n zkporter_is_available,\n l1_batches.bootloader_code_hash,\n l1_batches.default_aa_code_hash,\n base_fee_per_gas,\n aux_data_hash,\n pass_through_data_hash,\n meta_parameters_hash,\n protocol_version,\n compressed_state_diffs,\n system_logs,\n events_queue_commitment,\n bootloader_initial_content_commitment\n FROM\n l1_batches\n LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number\n JOIN protocol_versions ON protocol_versions.id = l1_batches.protocol_version\n WHERE\n eth_commit_tx_id IS NULL\n AND number != 0\n AND protocol_versions.bootloader_code_hash = $1\n AND protocol_versions.default_account_code_hash = $2\n AND commitment IS NOT NULL\n AND (\n protocol_versions.id = $3\n OR protocol_versions.upgrade_tx_hash IS NULL\n )\n AND events_queue_commitment IS NOT NULL\n AND bootloader_initial_content_commitment IS NOT NULL\n ORDER BY\n number\n LIMIT\n $4\n " }, - "173da19a30bde9f034de97c1427f3166d9615d46cdaa30f1645a36f42926fa63": { + "15858168fea6808c6d59d0e6d8f28a20420763a3a22899ad0e5f4b953b615a9e": { "describe": { "columns": [ { "name": "id", "ordinal": 0, "type_info": "Int4" - }, - { - "name": "nonce", - "ordinal": 1, - "type_info": "Int8" - }, - { - "name": "raw_tx", - "ordinal": 2, - "type_info": "Bytea" - }, - { - "name": "contract_address", - "ordinal": 3, - "type_info": "Text" - }, - { - "name": "tx_type", - "ordinal": 4, - "type_info": "Text" - }, - { - "name": "gas_used", - "ordinal": 5, - "type_info": "Int8" - }, - { - "name": "created_at", - "ordinal": 6, - "type_info": "Timestamp" - }, - { - "name": "updated_at", - "ordinal": 7, - "type_info": "Timestamp" - }, - { - "name": "has_failed", - "ordinal": 8, - "type_info": "Bool" - }, - { - "name": "sent_at_block", - "ordinal": 9, - "type_info": "Int4" - }, - { - "name": "confirmed_eth_tx_history_id", - "ordinal": 10, - "type_info": "Int4" - }, - { - "name": "predicted_gas_cost", - "ordinal": 11, - "type_info": "Int8" } ], "nullable": [ - false, - false, - false, - false, - false, - true, - false, - false, - false, - true, - true, false ], "parameters": { "Left": [ "Bytea", - "Int8", - "Text", - "Text", - "Int8" - ] - } - }, - "query": "INSERT INTO eth_txs (raw_tx, nonce, tx_type, contract_address, predicted_gas_cost, created_at, updated_at) VALUES ($1, $2, $3, $4, $5, now(), now()) RETURNING *" - }, - "17a42a97e87a675bd465103ebedc63d6d091e5bb093c7905de70aed3dc71d823": { - "describe": { - "columns": [], - "nullable": [], - "parameters": { - "Left": [ - "Int8" - ] - } - }, - "query": "DELETE FROM storage_logs WHERE miniblock_number > $1" - }, - "191fb8c0549267b515aaa7acc199675be1ea113e9137195468bb8ce64a099ae8": { - "describe": { - "columns": [ - { - "name": "serialized_events_queue", - "ordinal": 0, - "type_info": "Jsonb" - } - ], - "nullable": [ - false - ], - "parameters": { - "Left": [ - "Int8" + "Bytea", + "Bytea", + "Bytea" ] } }, - "query": "SELECT serialized_events_queue FROM events_queue WHERE l1_batch_number = $1" + "query": "\n SELECT\n id\n FROM\n prover_fri_protocol_versions\n WHERE\n recursion_circuits_set_vks_hash = $1\n AND recursion_leaf_level_vk_hash = $2\n AND recursion_node_level_vk_hash = $3\n AND recursion_scheduler_level_vk_hash = $4\n " }, - "1948ab14bafbb3ba0098563f22d958c9383877788980fe51bd217987898b1c92": { + "15893d68429ba09662ee27935653c17c7a7939195dd2d9aa42512b1479d2ed20": { "describe": { "columns": [ { - "name": "hashed_key!", + "name": "number", "ordinal": 0, - "type_info": "Bytea" + "type_info": "Int8" }, { - "name": "value?", + "name": "l1_batch_number!", "ordinal": 1, - "type_info": "Bytea" - } - ], - "nullable": [ - null, - null - ], - "parameters": { - "Left": [ - "ByteaArray", - "Int8" - ] - } - }, - "query": "SELECT u.hashed_key as \"hashed_key!\", (SELECT value FROM storage_logs WHERE hashed_key = u.hashed_key AND miniblock_number <= $2 ORDER BY miniblock_number DESC, operation_number DESC LIMIT 1) as \"value?\" FROM UNNEST($1::bytea[]) AS u(hashed_key)" - }, - "19b89495be8aa735db039ccc8a262786c58e54f132588c48f07d9537cf21d3ed": { - "describe": { - "columns": [ + "type_info": "Int8" + }, { - "name": "sent_at_block", - "ordinal": 0, - "type_info": "Int4" - } - ], - "nullable": [ - true - ], - "parameters": { - "Left": [ - "Int4" - ] - } - }, - "query": "SELECT sent_at_block FROM eth_txs_history WHERE eth_tx_id = $1 AND sent_at_block IS NOT NULL ORDER BY created_at ASC LIMIT 1" - }, - "19c8d9e449034ce7fd501541e5e71e2d5957bf2329e52166f4981955a847e175": { - "describe": { - "columns": [ + "name": "last_batch_miniblock?", + "ordinal": 2, + "type_info": "Int8" + }, { - "name": "value!", - "ordinal": 0, - "type_info": "Bytea" + "name": "timestamp", + "ordinal": 3, + "type_info": "Int8" }, { - "name": "l1_address!", - "ordinal": 1, + "name": "l1_gas_price", + "ordinal": 4, + "type_info": "Int8" + }, + { + "name": "l2_fair_gas_price", + "ordinal": 5, + "type_info": "Int8" + }, + { + "name": "bootloader_code_hash", + "ordinal": 6, "type_info": "Bytea" }, { - "name": "l2_address!", - "ordinal": 2, + "name": "default_aa_code_hash", + "ordinal": 7, "type_info": "Bytea" }, { - "name": "symbol!", - "ordinal": 3, - "type_info": "Varchar" + "name": "virtual_blocks", + "ordinal": 8, + "type_info": "Int8" }, { - "name": "name!", - "ordinal": 4, - "type_info": "Varchar" + "name": "hash", + "ordinal": 9, + "type_info": "Bytea" }, { - "name": "decimals!", - "ordinal": 5, + "name": "consensus", + "ordinal": 10, + "type_info": "Jsonb" + }, + { + "name": "protocol_version!", + "ordinal": 11, "type_info": "Int4" }, { - "name": "usd_price?", - "ordinal": 6, - "type_info": "Numeric" + "name": "fee_account_address?", + "ordinal": 12, + "type_info": "Bytea" } ], "nullable": [ false, + null, + null, false, false, false, + true, + true, false, false, - true + true, + true, + false ], "parameters": { "Left": [ - "ByteaArray", - "Bytea", - "Bytea", - "Bytea" + "Int8" ] } }, - "query": "\n SELECT storage.value as \"value!\",\n tokens.l1_address as \"l1_address!\", tokens.l2_address as \"l2_address!\",\n tokens.symbol as \"symbol!\", tokens.name as \"name!\", tokens.decimals as \"decimals!\", tokens.usd_price as \"usd_price?\"\n FROM storage\n INNER JOIN tokens ON\n storage.address = tokens.l2_address OR (storage.address = $2 AND tokens.l2_address = $3)\n WHERE storage.hashed_key = ANY($1) AND storage.value != $4\n " + "query": "\n SELECT\n miniblocks.number,\n COALESCE(\n miniblocks.l1_batch_number,\n (\n SELECT\n (MAX(number) + 1)\n FROM\n l1_batches\n )\n ) AS \"l1_batch_number!\",\n (\n SELECT\n MAX(m2.number)\n FROM\n miniblocks m2\n WHERE\n miniblocks.l1_batch_number = m2.l1_batch_number\n ) AS \"last_batch_miniblock?\",\n miniblocks.timestamp,\n miniblocks.l1_gas_price,\n miniblocks.l2_fair_gas_price,\n miniblocks.bootloader_code_hash,\n miniblocks.default_aa_code_hash,\n miniblocks.virtual_blocks,\n miniblocks.hash,\n miniblocks.consensus,\n miniblocks.protocol_version AS \"protocol_version!\",\n l1_batches.fee_account_address AS \"fee_account_address?\"\n FROM\n miniblocks\n LEFT JOIN l1_batches ON miniblocks.l1_batch_number = l1_batches.number\n WHERE\n miniblocks.number = $1\n " }, - "1a91acea72e56513a2a9e667bd5a2c171baa5fec01c51dcb7c7cf33f736c854d": { + "1689c212d411ebd99a22210519ea2d505a1aabf52ff4136d2ed1b39c70dd1632": { "describe": { "columns": [ { - "name": "tx_hash", + "name": "hash", "ordinal": 0, "type_info": "Bytea" }, { - "name": "index_in_block", + "name": "is_priority", "ordinal": 1, - "type_info": "Int4" + "type_info": "Bool" }, { - "name": "l1_batch_tx_index", + "name": "full_fee", "ordinal": 2, - "type_info": "Int4" + "type_info": "Numeric" }, { - "name": "block_number", + "name": "layer_2_tip_fee", "ordinal": 3, - "type_info": "Int8" + "type_info": "Numeric" }, { - "name": "error", + "name": "initiator_address", "ordinal": 4, - "type_info": "Varchar" + "type_info": "Bytea" }, { - "name": "effective_gas_price", + "name": "nonce", "ordinal": 5, - "type_info": "Numeric" + "type_info": "Int8" }, { - "name": "initiator_address", + "name": "signature", "ordinal": 6, "type_info": "Bytea" }, { - "name": "transfer_to?", + "name": "input", "ordinal": 7, - "type_info": "Jsonb" + "type_info": "Bytea" }, { - "name": "execute_contract_address?", + "name": "data", "ordinal": 8, "type_info": "Jsonb" }, { - "name": "tx_format?", + "name": "received_at", "ordinal": 9, - "type_info": "Int4" + "type_info": "Timestamp" }, { - "name": "refunded_gas", + "name": "priority_op_id", "ordinal": 10, "type_info": "Int8" }, { - "name": "gas_limit", + "name": "l1_batch_number", "ordinal": 11, - "type_info": "Numeric" + "type_info": "Int8" }, { - "name": "block_hash?", + "name": "index_in_block", "ordinal": 12, - "type_info": "Bytea" + "type_info": "Int4" }, { - "name": "l1_batch_number?", + "name": "error", "ordinal": 13, - "type_info": "Int8" + "type_info": "Varchar" }, { - "name": "contract_address?", + "name": "gas_limit", "ordinal": 14, + "type_info": "Numeric" + }, + { + "name": "gas_per_storage_limit", + "ordinal": 15, + "type_info": "Numeric" + }, + { + "name": "gas_per_pubdata_limit", + "ordinal": 16, + "type_info": "Numeric" + }, + { + "name": "tx_format", + "ordinal": 17, + "type_info": "Int4" + }, + { + "name": "created_at", + "ordinal": 18, + "type_info": "Timestamp" + }, + { + "name": "updated_at", + "ordinal": 19, + "type_info": "Timestamp" + }, + { + "name": "execution_info", + "ordinal": 20, + "type_info": "Jsonb" + }, + { + "name": "contract_address", + "ordinal": 21, + "type_info": "Bytea" + }, + { + "name": "in_mempool", + "ordinal": 22, + "type_info": "Bool" + }, + { + "name": "l1_block_number", + "ordinal": 23, + "type_info": "Int4" + }, + { + "name": "value", + "ordinal": 24, + "type_info": "Numeric" + }, + { + "name": "paymaster", + "ordinal": 25, + "type_info": "Bytea" + }, + { + "name": "paymaster_input", + "ordinal": 26, + "type_info": "Bytea" + }, + { + "name": "max_fee_per_gas", + "ordinal": 27, + "type_info": "Numeric" + }, + { + "name": "max_priority_fee_per_gas", + "ordinal": 28, + "type_info": "Numeric" + }, + { + "name": "effective_gas_price", + "ordinal": 29, + "type_info": "Numeric" + }, + { + "name": "miniblock_number", + "ordinal": 30, + "type_info": "Int8" + }, + { + "name": "l1_batch_tx_index", + "ordinal": 31, + "type_info": "Int4" + }, + { + "name": "refunded_gas", + "ordinal": 32, + "type_info": "Int8" + }, + { + "name": "l1_tx_mint", + "ordinal": 33, + "type_info": "Numeric" + }, + { + "name": "l1_tx_refund_recipient", + "ordinal": 34, "type_info": "Bytea" + }, + { + "name": "upgrade_id", + "ordinal": 35, + "type_info": "Int4" } ], "nullable": [ + false, false, true, true, + false, true, true, true, false, - null, - null, + false, + true, true, + true, + true, + true, + true, + true, + true, + false, + false, false, true, false, true, - false + false, + false, + false, + true, + true, + true, + true, + true, + false, + true, + true, + true ], "parameters": { - "Left": [ - "Bytea", - "Bytea", - "Bytea" - ] + "Left": [] } }, - "query": "\n WITH sl AS (\n SELECT * FROM storage_logs\n WHERE storage_logs.address = $1 AND storage_logs.tx_hash = $2\n ORDER BY storage_logs.miniblock_number DESC, storage_logs.operation_number DESC\n LIMIT 1\n )\n SELECT\n transactions.hash as tx_hash,\n transactions.index_in_block as index_in_block,\n transactions.l1_batch_tx_index as l1_batch_tx_index,\n transactions.miniblock_number as block_number,\n transactions.error as error,\n transactions.effective_gas_price as effective_gas_price,\n transactions.initiator_address as initiator_address,\n transactions.data->'to' as \"transfer_to?\",\n transactions.data->'contractAddress' as \"execute_contract_address?\",\n transactions.tx_format as \"tx_format?\",\n transactions.refunded_gas as refunded_gas,\n transactions.gas_limit as gas_limit,\n miniblocks.hash as \"block_hash?\",\n miniblocks.l1_batch_number as \"l1_batch_number?\",\n sl.key as \"contract_address?\"\n FROM transactions\n LEFT JOIN miniblocks\n ON miniblocks.number = transactions.miniblock_number\n LEFT JOIN sl\n ON sl.value != $3\n WHERE transactions.hash = $2\n " + "query": "\n SELECT\n *\n FROM\n transactions\n WHERE\n miniblock_number IS NOT NULL\n AND l1_batch_number IS NULL\n ORDER BY\n miniblock_number,\n index_in_block\n " }, - "1becc0cdf3dbc9160853bb20c9130417cc6e17f576e9d239f889a1932eda9f4f": { + "1766c0a21ba5918dd08f4babd8dbfdf10fb1cb43781219586c169fb976204331": { "describe": { "columns": [ { - "name": "id", + "name": "l1_batch_number", "ordinal": 0, - "type_info": "Int4" - }, - { - "name": "eth_tx_id", - "ordinal": 1, - "type_info": "Int4" + "type_info": "Int8" } ], "nullable": [ - false, false ], "parameters": { "Left": [ - "Text" + "Bytea" ] } }, - "query": "UPDATE eth_txs_history SET updated_at = now(), confirmed_at = now() WHERE tx_hash = $1 RETURNING id, eth_tx_id" + "query": "\n SELECT\n l1_batch_number\n FROM\n initial_writes\n WHERE\n hashed_key = $1\n " }, - "1c1a4cdf476de4f4cc83a31151fc4c407b93b53e2cd995f8bb5222d0a3c38c47": { + "1862d3a78e4e9068df1b8ce3bbe9f3f0b5d629fdb5c36ea1bfb93ed246be968e": { "describe": { "columns": [ { - "name": "number", + "name": "is_priority", "ordinal": 0, - "type_info": "Int8" + "type_info": "Bool" }, { - "name": "timestamp", + "name": "initiator_address", "ordinal": 1, - "type_info": "Int8" + "type_info": "Bytea" }, { - "name": "l1_tx_count", + "name": "gas_limit", "ordinal": 2, - "type_info": "Int4" + "type_info": "Numeric" }, { - "name": "l2_tx_count", + "name": "gas_per_pubdata_limit", "ordinal": 3, - "type_info": "Int4" + "type_info": "Numeric" }, { - "name": "root_hash?", + "name": "received_at", "ordinal": 4, - "type_info": "Bytea" + "type_info": "Timestamp" }, { - "name": "commit_tx_hash?", + "name": "miniblock_number", "ordinal": 5, - "type_info": "Text" + "type_info": "Int8" }, { - "name": "committed_at?", + "name": "error", "ordinal": 6, - "type_info": "Timestamp" + "type_info": "Varchar" }, { - "name": "prove_tx_hash?", + "name": "effective_gas_price", "ordinal": 7, - "type_info": "Text" + "type_info": "Numeric" }, { - "name": "proven_at?", + "name": "refunded_gas", "ordinal": 8, - "type_info": "Timestamp" + "type_info": "Int8" }, { - "name": "execute_tx_hash?", + "name": "eth_commit_tx_hash?", "ordinal": 9, "type_info": "Text" }, { - "name": "executed_at?", + "name": "eth_prove_tx_hash?", "ordinal": 10, - "type_info": "Timestamp" + "type_info": "Text" }, { - "name": "l1_gas_price", + "name": "eth_execute_tx_hash?", "ordinal": 11, - "type_info": "Int8" - }, - { - "name": "l2_fair_gas_price", - "ordinal": 12, - "type_info": "Int8" - }, - { - "name": "bootloader_code_hash", - "ordinal": 13, - "type_info": "Bytea" - }, - { - "name": "default_aa_code_hash", - "ordinal": 14, - "type_info": "Bytea" + "type_info": "Text" } ], "nullable": [ - false, - false, false, false, true, - false, true, false, true, - false, + true, true, false, false, - true, - true + false, + false ], "parameters": { "Left": [ - "Int8" + "Bytea" + ] + } + }, + "query": "\n SELECT\n transactions.is_priority,\n transactions.initiator_address,\n transactions.gas_limit,\n transactions.gas_per_pubdata_limit,\n transactions.received_at,\n transactions.miniblock_number,\n transactions.error,\n transactions.effective_gas_price,\n transactions.refunded_gas,\n commit_tx.tx_hash AS \"eth_commit_tx_hash?\",\n prove_tx.tx_hash AS \"eth_prove_tx_hash?\",\n execute_tx.tx_hash AS \"eth_execute_tx_hash?\"\n FROM\n transactions\n LEFT JOIN miniblocks ON miniblocks.number = transactions.miniblock_number\n LEFT JOIN l1_batches ON l1_batches.number = miniblocks.l1_batch_number\n LEFT JOIN eth_txs_history AS commit_tx ON (\n l1_batches.eth_commit_tx_id = commit_tx.eth_tx_id\n AND commit_tx.confirmed_at IS NOT NULL\n )\n LEFT JOIN eth_txs_history AS prove_tx ON (\n l1_batches.eth_prove_tx_id = prove_tx.eth_tx_id\n AND prove_tx.confirmed_at IS NOT NULL\n )\n LEFT JOIN eth_txs_history AS execute_tx ON (\n l1_batches.eth_execute_tx_id = execute_tx.eth_tx_id\n AND execute_tx.confirmed_at IS NOT NULL\n )\n WHERE\n transactions.hash = $1\n " + }, + "18820f4ab0c3d2cc9187c5660f9f50e423eb6134659fe52bcc2b27ad16740c96": { + "describe": { + "columns": [], + "nullable": [], + "parameters": { + "Left": [ + "ByteaArray" ] } }, - "query": "\n SELECT l1_batches.number,\n l1_batches.timestamp,\n l1_batches.l1_tx_count,\n l1_batches.l2_tx_count,\n l1_batches.hash as \"root_hash?\",\n commit_tx.tx_hash as \"commit_tx_hash?\",\n commit_tx.confirmed_at as \"committed_at?\",\n prove_tx.tx_hash as \"prove_tx_hash?\",\n prove_tx.confirmed_at as \"proven_at?\",\n execute_tx.tx_hash as \"execute_tx_hash?\",\n execute_tx.confirmed_at as \"executed_at?\",\n l1_batches.l1_gas_price,\n l1_batches.l2_fair_gas_price,\n l1_batches.bootloader_code_hash,\n l1_batches.default_aa_code_hash\n FROM l1_batches\n LEFT JOIN eth_txs_history as commit_tx ON (l1_batches.eth_commit_tx_id = commit_tx.eth_tx_id AND commit_tx.confirmed_at IS NOT NULL)\n LEFT JOIN eth_txs_history as prove_tx ON (l1_batches.eth_prove_tx_id = prove_tx.eth_tx_id AND prove_tx.confirmed_at IS NOT NULL)\n LEFT JOIN eth_txs_history as execute_tx ON (l1_batches.eth_execute_tx_id = execute_tx.eth_tx_id AND execute_tx.confirmed_at IS NOT NULL)\n WHERE l1_batches.number = $1\n " + "query": "\n DELETE FROM transactions\n WHERE\n in_mempool = TRUE\n AND initiator_address = ANY ($1)\n " }, - "1c583696808f93ff009ddf5df0ea36fe2621827fbd425c39ed4c9670ebc6431b": { + "19314d74e94b610e2da6d728ca37ea964610e131d45f720f7a7b2a130fe9ed89": { "describe": { "columns": [], "nullable": [], "parameters": { "Left": [ + "Int8", "Text", - "Int8" + "Jsonb", + "Text" ] } }, - "query": "\n UPDATE witness_inputs_fri SET status =$1, updated_at = now()\n WHERE l1_batch_number = $2\n " + "query": "\n UPDATE contract_verification_requests\n SET\n status = 'failed',\n updated_at = NOW(),\n error = $2,\n compilation_errors = $3,\n panic_message = $4\n WHERE\n id = $1\n " }, - "1d1f5198cbb0b9cd70019a9b386212de294075c00ebac4dbd39fda5397dbb07c": { + "19545806b8f772075096e69f8665d98a3d9f7df162ae22a98c3c7620fcd13bd2": { "describe": { "columns": [ { - "name": "number", + "name": "id", "ordinal": 0, - "type_info": "Int8" + "type_info": "Int4" }, { "name": "timestamp", @@ -1488,189 +1535,49 @@ "type_info": "Int8" }, { - "name": "is_finished", + "name": "recursion_scheduler_level_vk_hash", "ordinal": 2, - "type_info": "Bool" + "type_info": "Bytea" }, { - "name": "l1_tx_count", + "name": "recursion_node_level_vk_hash", "ordinal": 3, - "type_info": "Int4" + "type_info": "Bytea" }, { - "name": "l2_tx_count", + "name": "recursion_leaf_level_vk_hash", "ordinal": 4, - "type_info": "Int4" + "type_info": "Bytea" }, { - "name": "fee_account_address", + "name": "recursion_circuits_set_vks_hash", "ordinal": 5, "type_info": "Bytea" }, { - "name": "bloom", + "name": "bootloader_code_hash", "ordinal": 6, "type_info": "Bytea" }, { - "name": "priority_ops_onchain_data", + "name": "default_account_code_hash", "ordinal": 7, - "type_info": "ByteaArray" + "type_info": "Bytea" }, { - "name": "hash", + "name": "verifier_address", "ordinal": 8, "type_info": "Bytea" }, { - "name": "parent_hash", + "name": "upgrade_tx_hash", "ordinal": 9, "type_info": "Bytea" }, { - "name": "commitment", + "name": "created_at", "ordinal": 10, - "type_info": "Bytea" - }, - { - "name": "compressed_write_logs", - "ordinal": 11, - "type_info": "Bytea" - }, - { - "name": "compressed_contracts", - "ordinal": 12, - "type_info": "Bytea" - }, - { - "name": "eth_prove_tx_id", - "ordinal": 13, - "type_info": "Int4" - }, - { - "name": "eth_commit_tx_id", - "ordinal": 14, - "type_info": "Int4" - }, - { - "name": "eth_execute_tx_id", - "ordinal": 15, - "type_info": "Int4" - }, - { - "name": "merkle_root_hash", - "ordinal": 16, - "type_info": "Bytea" - }, - { - "name": "l2_to_l1_logs", - "ordinal": 17, - "type_info": "ByteaArray" - }, - { - "name": "l2_to_l1_messages", - "ordinal": 18, - "type_info": "ByteaArray" - }, - { - "name": "used_contract_hashes", - "ordinal": 19, - "type_info": "Jsonb" - }, - { - "name": "compressed_initial_writes", - "ordinal": 20, - "type_info": "Bytea" - }, - { - "name": "compressed_repeated_writes", - "ordinal": 21, - "type_info": "Bytea" - }, - { - "name": "l2_l1_compressed_messages", - "ordinal": 22, - "type_info": "Bytea" - }, - { - "name": "l2_l1_merkle_root", - "ordinal": 23, - "type_info": "Bytea" - }, - { - "name": "l1_gas_price", - "ordinal": 24, - "type_info": "Int8" - }, - { - "name": "l2_fair_gas_price", - "ordinal": 25, - "type_info": "Int8" - }, - { - "name": "rollup_last_leaf_index", - "ordinal": 26, - "type_info": "Int8" - }, - { - "name": "zkporter_is_available", - "ordinal": 27, - "type_info": "Bool" - }, - { - "name": "bootloader_code_hash", - "ordinal": 28, - "type_info": "Bytea" - }, - { - "name": "default_aa_code_hash", - "ordinal": 29, - "type_info": "Bytea" - }, - { - "name": "base_fee_per_gas", - "ordinal": 30, - "type_info": "Numeric" - }, - { - "name": "aux_data_hash", - "ordinal": 31, - "type_info": "Bytea" - }, - { - "name": "pass_through_data_hash", - "ordinal": 32, - "type_info": "Bytea" - }, - { - "name": "meta_parameters_hash", - "ordinal": 33, - "type_info": "Bytea" - }, - { - "name": "protocol_version", - "ordinal": 34, - "type_info": "Int4" - }, - { - "name": "compressed_state_diffs", - "ordinal": 35, - "type_info": "Bytea" - }, - { - "name": "system_logs", - "ordinal": 36, - "type_info": "ByteaArray" - }, - { - "name": "events_queue_commitment", - "ordinal": 37, - "type_info": "Bytea" - }, - { - "name": "bootloader_initial_content_commitment", - "ordinal": 38, - "type_info": "Bytea" + "type_info": "Timestamp" } ], "nullable": [ @@ -1682,133 +1589,89 @@ false, false, false, - true, - true, - true, - true, - true, - true, - true, - true, - true, - false, - false, - false, - true, - true, - true, - true, - false, - false, - true, - true, - true, - true, - false, - true, - true, - true, - true, - true, false, true, - true + false ], "parameters": { - "Left": [ - "Int8" - ] + "Left": [] } }, - "query": "SELECT number, timestamp, is_finished, l1_tx_count, l2_tx_count, fee_account_address, bloom, priority_ops_onchain_data, hash, parent_hash, commitment, compressed_write_logs, compressed_contracts, eth_prove_tx_id, eth_commit_tx_id, eth_execute_tx_id, merkle_root_hash, l2_to_l1_logs, l2_to_l1_messages, used_contract_hashes, compressed_initial_writes, compressed_repeated_writes, l2_l1_compressed_messages, l2_l1_merkle_root, l1_gas_price, l2_fair_gas_price, rollup_last_leaf_index, zkporter_is_available, bootloader_code_hash, default_aa_code_hash, base_fee_per_gas, aux_data_hash, pass_through_data_hash, meta_parameters_hash, protocol_version, compressed_state_diffs, system_logs, events_queue_commitment, bootloader_initial_content_commitment FROM l1_batches LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number WHERE eth_commit_tx_id IS NOT NULL AND eth_prove_tx_id IS NULL ORDER BY number LIMIT $1" + "query": "\n SELECT\n *\n FROM\n protocol_versions\n ORDER BY\n id DESC\n LIMIT\n 1\n " }, - "1d3e9cd259fb70a2bc81e8344576c3fb27b47ad6cdb6751d2a9b8c8d342b7a75": { + "19b89495be8aa735db039ccc8a262786c58e54f132588c48f07d9537cf21d3ed": { "describe": { - "columns": [], - "nullable": [], + "columns": [ + { + "name": "sent_at_block", + "ordinal": 0, + "type_info": "Int4" + } + ], + "nullable": [ + true + ], "parameters": { "Left": [ - "Text", - "Int8" + "Int4" ] } }, - "query": "\n UPDATE prover_jobs\n SET status = $1, updated_at = now()\n WHERE id = $2\n " + "query": "SELECT sent_at_block FROM eth_txs_history WHERE eth_tx_id = $1 AND sent_at_block IS NOT NULL ORDER BY created_at ASC LIMIT 1" }, - "1dbe99ed32b361936c2a829a99a92ac792a02c8a304d23b140804844a7b0f857": { + "1ad3bbd791f3ff0d31683bf59187b84c5fd52f0352f0f0e311d054cb9e45b07e": { "describe": { "columns": [ { - "name": "l1_batch_number", + "name": "hashed_key", "ordinal": 0, - "type_info": "Int8" - }, - { - "name": "circuit_id", - "ordinal": 1, - "type_info": "Int2" - }, - { - "name": "depth", - "ordinal": 2, - "type_info": "Int4" + "type_info": "Bytea" } ], "nullable": [ - false, - false, false ], - "parameters": { - "Left": [] - } - }, - "query": "\n UPDATE node_aggregation_witness_jobs_fri\n SET status='queued'\n WHERE (l1_batch_number, circuit_id, depth) IN\n (SELECT prover_jobs_fri.l1_batch_number, prover_jobs_fri.circuit_id, prover_jobs_fri.depth\n FROM prover_jobs_fri\n JOIN node_aggregation_witness_jobs_fri nawj ON\n prover_jobs_fri.l1_batch_number = nawj.l1_batch_number\n AND prover_jobs_fri.circuit_id = nawj.circuit_id\n AND prover_jobs_fri.depth = nawj.depth\n WHERE nawj.status = 'waiting_for_proofs'\n AND prover_jobs_fri.status = 'successful'\n AND prover_jobs_fri.aggregation_round = 1\n AND prover_jobs_fri.depth = 0\n GROUP BY prover_jobs_fri.l1_batch_number, prover_jobs_fri.circuit_id, prover_jobs_fri.depth, nawj.number_of_dependent_jobs\n HAVING COUNT(*) = nawj.number_of_dependent_jobs)\n RETURNING l1_batch_number, circuit_id, depth;\n " - }, - "1ed353a16e8d0abaf426e5c235b20a79c727c08bc23fb1708a833a6930131691": { - "describe": { - "columns": [], - "nullable": [], "parameters": { "Left": [ - "Int8", - "Text" + "Int8" ] } }, - "query": "INSERT INTO proof_compression_jobs_fri(l1_batch_number, status, created_at, updated_at) VALUES ($1, $2, now(), now()) ON CONFLICT (l1_batch_number) DO NOTHING" - }, - "1eede5c2169aee5a767b3b6b829f53721c0c353956ccec31a75226a65325ae46": { - "describe": { - "columns": [], - "nullable": [], - "parameters": { - "Left": [] - } - }, - "query": "UPDATE transactions SET in_mempool = FALSE WHERE in_mempool = TRUE" + "query": "\n SELECT DISTINCT\n ON (hashed_key) hashed_key\n FROM\n (\n SELECT\n *\n FROM\n storage_logs\n WHERE\n miniblock_number > $1\n ) inn\n " }, - "1f84a62da9b5e00dff0353de76b28f22220a5a859a9955afc2ad59135bd25e6c": { + "1b4ebbfc96b4fd66ecbe64a6be80a01a6c7cbe9297cbb55d42533fddc18719b6": { "describe": { "columns": [ { - "name": "l1_batch_number", + "name": "op_id", "ordinal": 0, "type_info": "Int8" } ], "nullable": [ - false + null ], + "parameters": { + "Left": [] + } + }, + "query": "\n SELECT\n MAX(priority_op_id) AS \"op_id\"\n FROM\n transactions\n WHERE\n is_priority = TRUE\n " + }, + "1bc6597117db032b87df33040d61610ffa7f169d560e79e89b99eedf681c6773": { + "describe": { + "columns": [], + "nullable": [], "parameters": { "Left": [ - "Int2" + "Int8", + "Text", + "Int4" ] } }, - "query": "\n SELECT l1_batch_number\n FROM prover_jobs_fri \n WHERE status <> 'skipped'\n AND status <> 'successful'\n AND aggregation_round = $1\n ORDER BY l1_batch_number ASC \n LIMIT 1\n " + "query": "\n INSERT INTO\n scheduler_witness_jobs_fri (\n l1_batch_number,\n scheduler_partial_input_blob_url,\n protocol_version,\n status,\n created_at,\n updated_at\n )\n VALUES\n ($1, $2, $3, 'waiting_for_proofs', NOW(), NOW())\n ON CONFLICT (l1_batch_number) DO\n UPDATE\n SET\n updated_at = NOW()\n " }, - "1faf6552c221c75b7232b55210c0c37be76a57ec9dc94584b6ccb562e8b182f2": { + "1c60010ded4e79886890a745a050fa6d65c05d8144bdfd143480834ead4bd8d5": { "describe": { "columns": [ { @@ -1817,89 +1680,49 @@ "type_info": "Int8" }, { - "name": "l1_batch_number", + "name": "contract_address", "ordinal": 1, - "type_info": "Int8" + "type_info": "Bytea" }, { - "name": "circuit_type", + "name": "source_code", "ordinal": 2, "type_info": "Text" }, { - "name": "prover_input", + "name": "contract_name", "ordinal": 3, - "type_info": "Bytea" + "type_info": "Text" }, { - "name": "status", + "name": "zk_compiler_version", "ordinal": 4, "type_info": "Text" }, { - "name": "error", + "name": "compiler_version", "ordinal": 5, "type_info": "Text" }, { - "name": "processing_started_at", + "name": "optimization_used", "ordinal": 6, - "type_info": "Timestamp" + "type_info": "Bool" }, { - "name": "created_at", + "name": "optimizer_mode", "ordinal": 7, - "type_info": "Timestamp" + "type_info": "Text" }, { - "name": "updated_at", + "name": "constructor_arguments", "ordinal": 8, - "type_info": "Timestamp" - }, - { - "name": "time_taken", - "ordinal": 9, - "type_info": "Time" - }, - { - "name": "aggregation_round", - "ordinal": 10, - "type_info": "Int4" - }, - { - "name": "result", - "ordinal": 11, "type_info": "Bytea" }, { - "name": "sequence_number", - "ordinal": 12, - "type_info": "Int4" - }, - { - "name": "attempts", - "ordinal": 13, - "type_info": "Int4" - }, - { - "name": "circuit_input_blob_url", - "ordinal": 14, - "type_info": "Text" - }, - { - "name": "proccesed_by", - "ordinal": 15, - "type_info": "Text" - }, - { - "name": "is_blob_cleaned", - "ordinal": 16, + "name": "is_system", + "ordinal": 9, "type_info": "Bool" - }, - { - "name": "protocol_version", - "ordinal": 17, - "type_info": "Int4" } ], "nullable": [ @@ -1908,382 +1731,453 @@ false, false, false, - true, - true, - false, - false, - false, - false, - true, false, false, true, - true, false, - true + false ], "parameters": { "Left": [ - "Int8" + "Interval" ] } }, - "query": "SELECT * from prover_jobs where id=$1" + "query": "\n UPDATE contract_verification_requests\n SET\n status = 'in_progress',\n attempts = attempts + 1,\n updated_at = NOW(),\n processing_started_at = NOW()\n WHERE\n id = (\n SELECT\n id\n FROM\n contract_verification_requests\n WHERE\n status = 'queued'\n OR (\n status = 'in_progress'\n AND processing_started_at < NOW() - $1::INTERVAL\n )\n ORDER BY\n created_at\n LIMIT\n 1\n FOR UPDATE\n SKIP LOCKED\n )\n RETURNING\n id,\n contract_address,\n source_code,\n contract_name,\n zk_compiler_version,\n compiler_version,\n optimization_used,\n optimizer_mode,\n constructor_arguments,\n is_system\n " }, - "2044947d6d29f29cda508b2160c39f74a8bfd524afa2ffc20a98ae039bc86ed7": { + "1c994d418ada78586de829fc2d34d26e48e968c79834858c98b7a7f9dfc81910": { "describe": { - "columns": [ - { - "name": "number", - "ordinal": 0, - "type_info": "Int8" - }, - { - "name": "hash", - "ordinal": 1, - "type_info": "Bytea" - } - ], - "nullable": [ - false, - false - ], + "columns": [], + "nullable": [], "parameters": { "Left": [ - "Int8", "Int8" ] } }, - "query": "SELECT number, hash FROM miniblocks WHERE number >= $1 ORDER BY number ASC LIMIT $2" + "query": "\n DELETE FROM l2_to_l1_logs\n WHERE\n miniblock_number > $1\n " }, - "20b22fd457417e9a72f5941887448f9a11b97b449db4759da0b9d368ce93996b": { + "1d2cc4b485536af350089cf7950be3b85419fde77038dd3de6c55aa9c55d375c": { "describe": { "columns": [ { - "name": "recursion_scheduler_level_vk_hash", + "name": "value!", "ordinal": 0, "type_info": "Bytea" }, { - "name": "recursion_node_level_vk_hash", + "name": "l1_address!", "ordinal": 1, "type_info": "Bytea" }, { - "name": "recursion_leaf_level_vk_hash", + "name": "l2_address!", "ordinal": 2, "type_info": "Bytea" }, { - "name": "recursion_circuits_set_vks_hash", + "name": "symbol!", "ordinal": 3, - "type_info": "Bytea" + "type_info": "Varchar" + }, + { + "name": "name!", + "ordinal": 4, + "type_info": "Varchar" + }, + { + "name": "decimals!", + "ordinal": 5, + "type_info": "Int4" + }, + { + "name": "usd_price?", + "ordinal": 6, + "type_info": "Numeric" } ], "nullable": [ false, false, false, - false + false, + false, + false, + true ], "parameters": { "Left": [ - "Int4" - ] - } - }, - "query": "SELECT recursion_scheduler_level_vk_hash, recursion_node_level_vk_hash, recursion_leaf_level_vk_hash, recursion_circuits_set_vks_hash\n FROM protocol_versions\n WHERE id = $1\n " - }, - "21c29846f4253081057b86cc1b7ce4ef3ae618c5561c876502dc7f4e773ee91e": { - "describe": { - "columns": [], - "nullable": [], - "parameters": { - "Left": [ - "Int8", + "ByteaArray", + "Bytea", "Bytea", "Bytea" ] } }, - "query": "INSERT INTO commitments (l1_batch_number, events_queue_commitment, bootloader_initial_content_commitment) VALUES ($1, $2, $3) ON CONFLICT (l1_batch_number) DO NOTHING" + "query": "\n SELECT\n storage.value AS \"value!\",\n tokens.l1_address AS \"l1_address!\",\n tokens.l2_address AS \"l2_address!\",\n tokens.symbol AS \"symbol!\",\n tokens.name AS \"name!\",\n tokens.decimals AS \"decimals!\",\n tokens.usd_price AS \"usd_price?\"\n FROM\n storage\n INNER JOIN tokens ON storage.address = tokens.l2_address\n OR (\n storage.address = $2\n AND tokens.l2_address = $3\n )\n WHERE\n storage.hashed_key = ANY ($1)\n AND storage.value != $4\n " }, - "22b57675a726d9cfeb82a60ba50c36cab1548d197ea56a7658d3f005df07c60b": { + "1d6b698b241cb6c5efd070a98165f6760cfeac185330d1d9c5cdb5b383ed8ed4": { "describe": { "columns": [ { - "name": "op_id", + "name": "id", "ordinal": 0, "type_info": "Int8" } ], "nullable": [ - null + false ], - "parameters": { - "Left": [] - } - }, - "query": "SELECT MAX(priority_op_id) as \"op_id\" from transactions where is_priority = true AND miniblock_number IS NOT NULL" - }, - "22e50b6def0365ddf979b64c3c943e2a3f8e5a1abcf72e61a00a82780d2d364e": { - "describe": { - "columns": [], - "nullable": [], "parameters": { "Left": [ - "Int8", + "Bytea", "Text", - "Text" - ] - } - }, - "query": "INSERT INTO proof_compression_jobs_fri(l1_batch_number, fri_proof_blob_url, status, created_at, updated_at) VALUES ($1, $2, $3, now(), now()) ON CONFLICT (l1_batch_number) DO NOTHING" - }, - "2397c1a050d358b596c9881c379bf823e267c03172f72c42da84cc0c04cc9d93": { - "describe": { - "columns": [ - { - "name": "miniblock_number!", - "ordinal": 0, - "type_info": "Int8" - }, - { - "name": "hash", - "ordinal": 1, - "type_info": "Bytea" - }, - { - "name": "index_in_block!", - "ordinal": 2, - "type_info": "Int4" - }, - { - "name": "l1_batch_tx_index!", - "ordinal": 3, - "type_info": "Int4" - } - ], - "nullable": [ - true, - false, - true, - true - ], - "parameters": { - "Left": [ - "Int8" - ] - } - }, - "query": "\n SELECT miniblock_number as \"miniblock_number!\",\n hash, index_in_block as \"index_in_block!\", l1_batch_tx_index as \"l1_batch_tx_index!\"\n FROM transactions\n WHERE l1_batch_number = $1\n ORDER BY miniblock_number, index_in_block\n " - }, - "23c154c243f27912320ea0d68bc7bb372517010fb8c5737621cadd7b408afe8d": { - "describe": { - "columns": [], - "nullable": [], - "parameters": { - "Left": [ "Text", "Text", - "Int8" - ] - } - }, - "query": "UPDATE proof_compression_jobs_fri SET status =$1, error= $2, updated_at = now() WHERE l1_batch_number = $3" - }, - "2424f0ab2b156e953841107cfc0ccd76519d13c62fdcd5fd6b39e3503d6ec82c": { - "describe": { - "columns": [], - "nullable": [], - "parameters": { - "Left": [ "Text", - "Int8" + "Bool", + "Text", + "Bytea", + "Bool" ] } }, - "query": "\n UPDATE scheduler_witness_jobs_fri\n SET status ='failed', error= $1, updated_at = now()\n WHERE l1_batch_number = $2\n " + "query": "\n INSERT INTO\n contract_verification_requests (\n contract_address,\n source_code,\n contract_name,\n zk_compiler_version,\n compiler_version,\n optimization_used,\n optimizer_mode,\n constructor_arguments,\n is_system,\n status,\n created_at,\n updated_at\n )\n VALUES\n ($1, $2, $3, $4, $5, $6, $7, $8, $9, 'queued', NOW(), NOW())\n RETURNING\n id\n " }, - "269f3ac58705d65f775a6c84a62b9c0726beef51eb633937fa2a75b80c6d7fbc": { + "1dcb3afb0c1947f92981f61d95c099c4591ce3f8d51f3df99db0165e086f96af": { "describe": { "columns": [ { - "name": "hash", + "name": "bytecode", "ordinal": 0, "type_info": "Bytea" - }, - { - "name": "number", - "ordinal": 1, - "type_info": "Int8" - }, - { - "name": "timestamp", - "ordinal": 2, - "type_info": "Int8" } ], "nullable": [ - false, - false, false ], "parameters": { "Left": [ - "Int8" + "Bytea" ] } }, - "query": "SELECT hash, number, timestamp FROM miniblocks WHERE number > $1 ORDER BY number ASC" + "query": "\n SELECT\n bytecode\n FROM\n factory_deps\n WHERE\n bytecode_hash = $1\n " }, - "26ac14152ade97892cd78d37884523187a5619093887b5e6564c3a80741b9d94": { + "1e54aebf94d27244638f04d1d35a5a088ceebfef0228701fcbed8255b74b1050": { "describe": { "columns": [ { - "name": "id", + "name": "hash", "ordinal": 0, - "type_info": "Int4" + "type_info": "Bytea" }, { - "name": "timestamp", + "name": "is_priority", "ordinal": 1, - "type_info": "Int8" + "type_info": "Bool" }, { - "name": "recursion_scheduler_level_vk_hash", + "name": "full_fee", "ordinal": 2, - "type_info": "Bytea" + "type_info": "Numeric" }, { - "name": "recursion_node_level_vk_hash", + "name": "layer_2_tip_fee", "ordinal": 3, - "type_info": "Bytea" + "type_info": "Numeric" }, { - "name": "recursion_leaf_level_vk_hash", + "name": "initiator_address", "ordinal": 4, "type_info": "Bytea" }, { - "name": "recursion_circuits_set_vks_hash", + "name": "nonce", "ordinal": 5, - "type_info": "Bytea" + "type_info": "Int8" }, { - "name": "bootloader_code_hash", + "name": "signature", "ordinal": 6, "type_info": "Bytea" }, { - "name": "default_account_code_hash", + "name": "input", "ordinal": 7, "type_info": "Bytea" }, { - "name": "verifier_address", + "name": "data", "ordinal": 8, - "type_info": "Bytea" + "type_info": "Jsonb" }, { - "name": "upgrade_tx_hash", + "name": "received_at", "ordinal": 9, - "type_info": "Bytea" + "type_info": "Timestamp" }, { - "name": "created_at", + "name": "priority_op_id", "ordinal": 10, + "type_info": "Int8" + }, + { + "name": "l1_batch_number", + "ordinal": 11, + "type_info": "Int8" + }, + { + "name": "index_in_block", + "ordinal": 12, + "type_info": "Int4" + }, + { + "name": "error", + "ordinal": 13, + "type_info": "Varchar" + }, + { + "name": "gas_limit", + "ordinal": 14, + "type_info": "Numeric" + }, + { + "name": "gas_per_storage_limit", + "ordinal": 15, + "type_info": "Numeric" + }, + { + "name": "gas_per_pubdata_limit", + "ordinal": 16, + "type_info": "Numeric" + }, + { + "name": "tx_format", + "ordinal": 17, + "type_info": "Int4" + }, + { + "name": "created_at", + "ordinal": 18, + "type_info": "Timestamp" + }, + { + "name": "updated_at", + "ordinal": 19, "type_info": "Timestamp" + }, + { + "name": "execution_info", + "ordinal": 20, + "type_info": "Jsonb" + }, + { + "name": "contract_address", + "ordinal": 21, + "type_info": "Bytea" + }, + { + "name": "in_mempool", + "ordinal": 22, + "type_info": "Bool" + }, + { + "name": "l1_block_number", + "ordinal": 23, + "type_info": "Int4" + }, + { + "name": "value", + "ordinal": 24, + "type_info": "Numeric" + }, + { + "name": "paymaster", + "ordinal": 25, + "type_info": "Bytea" + }, + { + "name": "paymaster_input", + "ordinal": 26, + "type_info": "Bytea" + }, + { + "name": "max_fee_per_gas", + "ordinal": 27, + "type_info": "Numeric" + }, + { + "name": "max_priority_fee_per_gas", + "ordinal": 28, + "type_info": "Numeric" + }, + { + "name": "effective_gas_price", + "ordinal": 29, + "type_info": "Numeric" + }, + { + "name": "miniblock_number", + "ordinal": 30, + "type_info": "Int8" + }, + { + "name": "l1_batch_tx_index", + "ordinal": 31, + "type_info": "Int4" + }, + { + "name": "refunded_gas", + "ordinal": 32, + "type_info": "Int8" + }, + { + "name": "l1_tx_mint", + "ordinal": 33, + "type_info": "Numeric" + }, + { + "name": "l1_tx_refund_recipient", + "ordinal": 34, + "type_info": "Bytea" + }, + { + "name": "upgrade_id", + "ordinal": 35, + "type_info": "Int4" } ], "nullable": [ false, false, + true, + true, + false, + true, + true, + true, + false, + false, + true, + true, + true, + true, + true, + true, + true, + true, false, false, false, + true, false, + true, false, false, false, true, - false + true, + true, + true, + true, + false, + true, + true, + true ], "parameters": { "Left": [ - "Int4" + "Int8" ] } }, - "query": "SELECT * FROM protocol_versions WHERE id = $1" + "query": "\n SELECT\n *\n FROM\n transactions\n WHERE\n miniblock_number = $1\n ORDER BY\n index_in_block\n " }, - "297d6517ec5f050e8d8fe4878e4ff330b4b10af4d60de86e8a25e2cd70e0363b": { + "1ea37ef1c3df72e5e9c50cfa1675fc7f60618209d0132e7937a1347b7e94b212": { "describe": { "columns": [ { - "name": "verification_info", + "name": "number", "ordinal": 0, - "type_info": "Jsonb" + "type_info": "Int8" } ], "nullable": [ - true + false ], "parameters": { - "Left": [ - "Bytea" - ] + "Left": [] } }, - "query": "SELECT verification_info FROM contracts_verification_info WHERE address = $1" + "query": "\n SELECT\n number\n FROM\n l1_batches\n WHERE\n eth_prove_tx_id IS NOT NULL\n AND eth_execute_tx_id IS NULL\n ORDER BY\n number\n LIMIT\n 1\n " }, - "2985ea2bf34a94573103654c00a49d2a946afe5d552ac1c2a2d055eb9d6f2cf1": { + "1ed2d7e5e98b15420a21650809d710ce910d0c9138d85cb55e16459c757dea03": { "describe": { - "columns": [], - "nullable": [], + "columns": [ + { + "name": "protocol_version", + "ordinal": 0, + "type_info": "Int4" + } + ], + "nullable": [ + true + ], "parameters": { - "Left": [ - "Time", - "Int8" - ] + "Left": [] } }, - "query": "\n UPDATE node_aggregation_witness_jobs_fri\n SET status = 'successful', updated_at = now(), time_taken = $1\n WHERE id = $2\n " + "query": "\n SELECT\n protocol_version\n FROM\n l1_batches\n ORDER BY\n number DESC\n LIMIT\n 1\n " }, - "29c04c63e5df40ef439d467373a848bce74de906548331856222cdb7551ca907": { + "1f25016c41169aa4ab14db2faf7b2d0413d0f89c309de4b31254c309116ea60c": { "describe": { "columns": [], "nullable": [], "parameters": { "Left": [ - "Int8" + "Bytea", + "Varchar", + "Varchar", + "Int4" ] } }, - "query": "UPDATE contract_verification_requests SET status = 'successful', updated_at = now() WHERE id = $1" + "query": "\n UPDATE tokens\n SET\n token_list_name = $2,\n token_list_symbol = $3,\n token_list_decimals = $4,\n well_known = TRUE,\n updated_at = NOW()\n WHERE\n l1_address = $1\n " }, - "29f7f469cd58b256237536463f1e9d58438314fd1fe733a6bb53e6523f78bb49": { + "1f46524410ce0f193dc6547499bde995ddddc621ee2149f08f905af2d8aadd03": { "describe": { - "columns": [ - { - "name": "attempts", - "ordinal": 0, - "type_info": "Int2" - } - ], - "nullable": [ - false - ], + "columns": [], + "nullable": [], "parameters": { "Left": [ + "ByteaArray", + "Int4Array", + "ByteaArray", + "ByteaArray", + "NumericArray", + "NumericArray", + "NumericArray", + "NumericArray", + "Int4Array", + "Int4Array", + "VarcharArray", + "NumericArray", + "JsonbArray", + "ByteaArray", + "JsonbArray", + "Int8Array", + "NumericArray", + "ByteaArray", + "ByteaArray", + "ByteaArray", "Int8" ] } }, - "query": "SELECT attempts FROM prover_jobs_fri WHERE id = $1" + "query": "\n UPDATE transactions\n SET\n hash = data_table.hash,\n signature = data_table.signature,\n gas_limit = data_table.gas_limit,\n max_fee_per_gas = data_table.max_fee_per_gas,\n max_priority_fee_per_gas = data_table.max_priority_fee_per_gas,\n gas_per_pubdata_limit = data_table.gas_per_pubdata_limit,\n input = data_table.input,\n data = data_table.data,\n tx_format = data_table.tx_format,\n miniblock_number = $21,\n index_in_block = data_table.index_in_block,\n error = NULLIF(data_table.error, ''),\n effective_gas_price = data_table.effective_gas_price,\n execution_info = data_table.new_execution_info,\n refunded_gas = data_table.refunded_gas,\n value = data_table.value,\n contract_address = data_table.contract_address,\n paymaster = data_table.paymaster,\n paymaster_input = data_table.paymaster_input,\n in_mempool = FALSE,\n updated_at = NOW()\n FROM\n (\n SELECT\n data_table_temp.*\n FROM\n (\n SELECT\n UNNEST($1::bytea[]) AS initiator_address,\n UNNEST($2::INT[]) AS nonce,\n UNNEST($3::bytea[]) AS hash,\n UNNEST($4::bytea[]) AS signature,\n UNNEST($5::NUMERIC[]) AS gas_limit,\n UNNEST($6::NUMERIC[]) AS max_fee_per_gas,\n UNNEST($7::NUMERIC[]) AS max_priority_fee_per_gas,\n UNNEST($8::NUMERIC[]) AS gas_per_pubdata_limit,\n UNNEST($9::INT[]) AS tx_format,\n UNNEST($10::INTEGER[]) AS index_in_block,\n UNNEST($11::VARCHAR[]) AS error,\n UNNEST($12::NUMERIC[]) AS effective_gas_price,\n UNNEST($13::jsonb[]) AS new_execution_info,\n UNNEST($14::bytea[]) AS input,\n UNNEST($15::jsonb[]) AS data,\n UNNEST($16::BIGINT[]) AS refunded_gas,\n UNNEST($17::NUMERIC[]) AS value,\n UNNEST($18::bytea[]) AS contract_address,\n UNNEST($19::bytea[]) AS paymaster,\n UNNEST($20::bytea[]) AS paymaster_input\n ) AS data_table_temp\n JOIN transactions ON transactions.initiator_address = data_table_temp.initiator_address\n AND transactions.nonce = data_table_temp.nonce\n ORDER BY\n transactions.hash\n ) AS data_table\n WHERE\n transactions.initiator_address = data_table.initiator_address\n AND transactions.nonce = data_table.nonce\n " }, - "2a38561e789af470d6ef1a905143f2d8d102b4ff23cebe97586681da9e4084a9": { + "1f75f2d88c1d2496e48b02f374e492cf2545944291dd0d42b937c0d0c7eefd47": { "describe": { "columns": [ { @@ -2297,54 +2191,69 @@ "type_info": "Int8" }, { - "name": "hash", + "name": "l1_tx_count", "ordinal": 2, - "type_info": "Bytea" + "type_info": "Int4" }, { - "name": "l1_tx_count", + "name": "l2_tx_count", "ordinal": 3, "type_info": "Int4" }, { - "name": "l2_tx_count", + "name": "root_hash?", "ordinal": 4, - "type_info": "Int4" + "type_info": "Bytea" }, { - "name": "base_fee_per_gas", + "name": "commit_tx_hash?", "ordinal": 5, - "type_info": "Numeric" + "type_info": "Text" }, { - "name": "l1_gas_price", + "name": "committed_at?", "ordinal": 6, - "type_info": "Int8" + "type_info": "Timestamp" }, { - "name": "l2_fair_gas_price", + "name": "prove_tx_hash?", "ordinal": 7, - "type_info": "Int8" + "type_info": "Text" }, { - "name": "bootloader_code_hash", + "name": "proven_at?", "ordinal": 8, - "type_info": "Bytea" + "type_info": "Timestamp" }, { - "name": "default_aa_code_hash", + "name": "execute_tx_hash?", "ordinal": 9, - "type_info": "Bytea" + "type_info": "Text" }, { - "name": "protocol_version", + "name": "executed_at?", "ordinal": 10, - "type_info": "Int4" + "type_info": "Timestamp" }, { - "name": "virtual_blocks", + "name": "l1_gas_price", "ordinal": 11, "type_info": "Int8" + }, + { + "name": "l2_fair_gas_price", + "ordinal": 12, + "type_info": "Int8" + }, + { + "name": "bootloader_code_hash", + "ordinal": 13, + "type_info": "Bytea" + }, + { + "name": "default_aa_code_hash", + "ordinal": 14, + "type_info": "Bytea" } ], "nullable": [ @@ -2352,14 +2261,17 @@ false, false, false, + true, false, - false, - false, + true, false, true, + false, true, + false, + false, true, - false + true ], "parameters": { "Left": [ @@ -2367,107 +2279,129 @@ ] } }, - "query": "SELECT number, timestamp, hash, l1_tx_count, l2_tx_count, base_fee_per_gas, l1_gas_price, l2_fair_gas_price, bootloader_code_hash, default_aa_code_hash, protocol_version, virtual_blocks\n FROM miniblocks WHERE number = $1" + "query": "\n SELECT\n l1_batches.number,\n l1_batches.timestamp,\n l1_batches.l1_tx_count,\n l1_batches.l2_tx_count,\n l1_batches.hash AS \"root_hash?\",\n commit_tx.tx_hash AS \"commit_tx_hash?\",\n commit_tx.confirmed_at AS \"committed_at?\",\n prove_tx.tx_hash AS \"prove_tx_hash?\",\n prove_tx.confirmed_at AS \"proven_at?\",\n execute_tx.tx_hash AS \"execute_tx_hash?\",\n execute_tx.confirmed_at AS \"executed_at?\",\n l1_batches.l1_gas_price,\n l1_batches.l2_fair_gas_price,\n l1_batches.bootloader_code_hash,\n l1_batches.default_aa_code_hash\n FROM\n l1_batches\n LEFT JOIN eth_txs_history AS commit_tx ON (\n l1_batches.eth_commit_tx_id = commit_tx.eth_tx_id\n AND commit_tx.confirmed_at IS NOT NULL\n )\n LEFT JOIN eth_txs_history AS prove_tx ON (\n l1_batches.eth_prove_tx_id = prove_tx.eth_tx_id\n AND prove_tx.confirmed_at IS NOT NULL\n )\n LEFT JOIN eth_txs_history AS execute_tx ON (\n l1_batches.eth_execute_tx_id = execute_tx.eth_tx_id\n AND execute_tx.confirmed_at IS NOT NULL\n )\n WHERE\n l1_batches.number = $1\n " }, - "2a98f1b149045f25d2830c0b4ffaaa400b4c572eb3842add22e8540f44943711": { + "2003dcf7bc807c7d345368538accd9b0128f82306e27e4c7258116082a54ab95": { "describe": { "columns": [ { - "name": "id", + "name": "hash", "ordinal": 0, - "type_info": "Int8" + "type_info": "Bytea" + }, + { + "name": "received_at", + "ordinal": 1, + "type_info": "Timestamp" } ], "nullable": [ + false, false ], "parameters": { "Left": [ - "Int8", - "Int2" + "Timestamp", + "Int8" ] } }, - "query": "SELECT id from prover_jobs_fri WHERE l1_batch_number = $1 AND status = 'successful' AND aggregation_round = $2" + "query": "\n SELECT\n transactions.hash,\n transactions.received_at\n FROM\n transactions\n LEFT JOIN miniblocks ON miniblocks.number = miniblock_number\n WHERE\n received_at > $1\n ORDER BY\n received_at ASC\n LIMIT\n $2\n " }, - "2adfdba6fa2b6b967ba03ae6f930e7f3ea851f678d30df699ced27b2dbb01c2a": { + "2028ba507f3ccd474f0261e571eb19a3a7feec950cb3e503588cf55d954a493a": { "describe": { "columns": [ { - "name": "number", + "name": "bytecode", "ordinal": 0, - "type_info": "Int8" + "type_info": "Bytea" } ], "nullable": [ false ], "parameters": { - "Left": [] + "Left": [ + "Int8" + ] } }, - "query": "SELECT number FROM l1_batches LEFT JOIN eth_txs_history as execute_tx ON (l1_batches.eth_execute_tx_id = execute_tx.eth_tx_id) WHERE execute_tx.confirmed_at IS NOT NULL ORDER BY number DESC LIMIT 1" + "query": "\n SELECT\n bytecode\n FROM\n factory_deps\n WHERE\n miniblock_number <= $1\n " }, - "2af0eddab563f0800a4762031e8703dbcac11450daacf3439289641b9b179b1c": { + "20f84f9ec21459d8c7ad53241758eeab159533211d2ddbef41e6ff0ba937d04a": { "describe": { - "columns": [ - { - "name": "id", - "ordinal": 0, - "type_info": "Int8" - }, - { - "name": "status", - "ordinal": 1, - "type_info": "Text" - }, - { - "name": "attempts", - "ordinal": 2, - "type_info": "Int2" - } - ], - "nullable": [ - false, - false, - false - ], + "columns": [], + "nullable": [], "parameters": { "Left": [ - "Interval", - "Int2" + "Int8" ] } }, - "query": "\n UPDATE node_aggregation_witness_jobs_fri\n SET status = 'queued', updated_at = now(), processing_started_at = now()\n WHERE (status = 'in_progress' AND processing_started_at <= now() - $1::interval AND attempts < $2)\n OR (status = 'failed' AND attempts < $2)\n RETURNING id, status, attempts\n " + "query": "\n UPDATE l1_batches\n SET\n skip_proof = TRUE\n WHERE\n number = $1\n " }, - "2b22e7d15adf069c8e68954059b83f71a71350f3325b4280840c4be7e54a319f": { + "23be43bf705d679ca751c89353716065fcad42c6b621efb3a135a16b477dcfd9": { "describe": { "columns": [ { - "name": "l1_address", + "name": "id", "ordinal": 0, - "type_info": "Bytea" + "type_info": "Int4" }, { - "name": "l2_address", + "name": "nonce", "ordinal": 1, - "type_info": "Bytea" + "type_info": "Int8" }, { - "name": "name", + "name": "raw_tx", "ordinal": 2, - "type_info": "Varchar" + "type_info": "Bytea" }, { - "name": "symbol", + "name": "contract_address", "ordinal": 3, - "type_info": "Varchar" + "type_info": "Text" }, { - "name": "decimals", + "name": "tx_type", "ordinal": 4, + "type_info": "Text" + }, + { + "name": "gas_used", + "ordinal": 5, + "type_info": "Int8" + }, + { + "name": "created_at", + "ordinal": 6, + "type_info": "Timestamp" + }, + { + "name": "updated_at", + "ordinal": 7, + "type_info": "Timestamp" + }, + { + "name": "has_failed", + "ordinal": 8, + "type_info": "Bool" + }, + { + "name": "sent_at_block", + "ordinal": 9, + "type_info": "Int4" + }, + { + "name": "confirmed_eth_tx_history_id", + "ordinal": 10, "type_info": "Int4" + }, + { + "name": "predicted_gas_cost", + "ordinal": 11, + "type_info": "Int8" } ], "nullable": [ @@ -2475,26 +2409,47 @@ false, false, false, + false, + true, + false, + false, + false, + true, + true, false ], "parameters": { "Left": [] } }, - "query": "SELECT l1_address, l2_address, name, symbol, decimals FROM tokens\n WHERE well_known = true\n ORDER BY symbol" + "query": "\n SELECT\n *\n FROM\n eth_txs\n WHERE\n confirmed_eth_tx_history_id IS NULL\n AND id <= (\n SELECT\n COALESCE(MAX(eth_tx_id), 0)\n FROM\n eth_txs_history\n WHERE\n sent_at_block IS NOT NULL\n )\n ORDER BY\n id\n " + }, + "245dc5bb82cc82df38e4440a7746ca08324bc86a72e4ea85c9c7962a6c8c9e30": { + "describe": { + "columns": [], + "nullable": [], + "parameters": { + "Left": [ + "Int4", + "Int8", + "Int8" + ] + } + }, + "query": "\n UPDATE l1_batches\n SET\n eth_prove_tx_id = $1,\n updated_at = NOW()\n WHERE\n number BETWEEN $2 AND $3\n " }, - "2b76ca7059810f691a2d7d053e7e62e06de13e7ddb7747e39335bb10c45534e9": { + "24722ee4ced7f03e60b1b5ecaaa5234d536b064951a67d826ac49b7a3a095a1a": { "describe": { "columns": [ { - "name": "l1_batch_number", + "name": "hashed_key", "ordinal": 0, - "type_info": "Int8" + "type_info": "Bytea" }, { - "name": "circuit_id", + "name": "index", "ordinal": 1, - "type_info": "Int2" + "type_info": "Int8" } ], "nullable": [ @@ -2502,18 +2457,20 @@ false ], "parameters": { - "Left": [] + "Left": [ + "Int8" + ] } }, - "query": "\n UPDATE leaf_aggregation_witness_jobs_fri\n SET status='queued'\n WHERE (l1_batch_number, circuit_id) IN\n (SELECT prover_jobs_fri.l1_batch_number, prover_jobs_fri.circuit_id\n FROM prover_jobs_fri\n JOIN leaf_aggregation_witness_jobs_fri lawj ON\n prover_jobs_fri.l1_batch_number = lawj.l1_batch_number\n AND prover_jobs_fri.circuit_id = lawj.circuit_id\n WHERE lawj.status = 'waiting_for_proofs'\n AND prover_jobs_fri.status = 'successful'\n AND prover_jobs_fri.aggregation_round = 0\n GROUP BY prover_jobs_fri.l1_batch_number, prover_jobs_fri.circuit_id, lawj.number_of_basic_circuits\n HAVING COUNT(*) = lawj.number_of_basic_circuits)\n RETURNING l1_batch_number, circuit_id;\n " + "query": "\n SELECT\n hashed_key,\n INDEX\n FROM\n initial_writes\n WHERE\n l1_batch_number = $1\n ORDER BY\n INDEX\n " }, - "2bd9137542076526c245366057f0f3f57c08368f6e0dc86d49293a91875272b8": { + "249cb862d44196cb6dc3945e907717b0dd3cec64b0b29f59b273f1c6952e01da": { "describe": { "columns": [ { - "name": "attempts", + "name": "bytecode_hash", "ordinal": 0, - "type_info": "Int2" + "type_info": "Bytea" } ], "nullable": [ @@ -2525,224 +2482,107 @@ ] } }, - "query": "SELECT attempts FROM witness_inputs_fri WHERE l1_batch_number = $1" - }, - "2c136284610f728ddba3e255d7dc573b10e4baf9151de194b7d8e0dc40c40602": { - "describe": { - "columns": [], - "nullable": [], - "parameters": { - "Left": [ - "Bytea", - "Jsonb" - ] - } - }, - "query": "INSERT INTO transaction_traces (tx_hash, trace, created_at, updated_at) VALUES ($1, $2, now(), now())" + "query": "\n SELECT\n bytecode_hash\n FROM\n factory_deps\n WHERE\n miniblock_number > $1\n " }, - "2c4178a125ddc46a36f7548c840e481e85738502c56566d1eef84feef2161b2e": { + "25aad4298d2459ef5aea7c4ea82eda1da000848ed4abf309b68989da33e1ce5a": { "describe": { "columns": [ { - "name": "hash", + "name": "number", "ordinal": 0, - "type_info": "Bytea" + "type_info": "Int8" }, { - "name": "is_priority", + "name": "l1_batch_number!", "ordinal": 1, - "type_info": "Bool" + "type_info": "Int8" }, { - "name": "full_fee", + "name": "timestamp", "ordinal": 2, - "type_info": "Numeric" + "type_info": "Int8" }, { - "name": "layer_2_tip_fee", + "name": "l1_tx_count", "ordinal": 3, - "type_info": "Numeric" + "type_info": "Int4" }, { - "name": "initiator_address", + "name": "l2_tx_count", "ordinal": 4, - "type_info": "Bytea" + "type_info": "Int4" }, { - "name": "nonce", + "name": "root_hash?", "ordinal": 5, - "type_info": "Int8" + "type_info": "Bytea" }, { - "name": "signature", + "name": "commit_tx_hash?", "ordinal": 6, - "type_info": "Bytea" + "type_info": "Text" }, { - "name": "input", + "name": "committed_at?", "ordinal": 7, - "type_info": "Bytea" + "type_info": "Timestamp" }, { - "name": "data", + "name": "prove_tx_hash?", "ordinal": 8, - "type_info": "Jsonb" + "type_info": "Text" }, { - "name": "received_at", + "name": "proven_at?", "ordinal": 9, "type_info": "Timestamp" }, { - "name": "priority_op_id", + "name": "execute_tx_hash?", "ordinal": 10, - "type_info": "Int8" + "type_info": "Text" }, { - "name": "l1_batch_number", + "name": "executed_at?", "ordinal": 11, - "type_info": "Int8" + "type_info": "Timestamp" }, { - "name": "index_in_block", + "name": "l1_gas_price", "ordinal": 12, - "type_info": "Int4" + "type_info": "Int8" }, { - "name": "error", + "name": "l2_fair_gas_price", "ordinal": 13, - "type_info": "Varchar" + "type_info": "Int8" }, { - "name": "gas_limit", + "name": "bootloader_code_hash", "ordinal": 14, - "type_info": "Numeric" + "type_info": "Bytea" }, { - "name": "gas_per_storage_limit", + "name": "default_aa_code_hash", "ordinal": 15, - "type_info": "Numeric" + "type_info": "Bytea" }, { - "name": "gas_per_pubdata_limit", + "name": "protocol_version", "ordinal": 16, - "type_info": "Numeric" - }, - { - "name": "tx_format", - "ordinal": 17, "type_info": "Int4" }, { - "name": "created_at", - "ordinal": 18, - "type_info": "Timestamp" - }, - { - "name": "updated_at", - "ordinal": 19, - "type_info": "Timestamp" - }, - { - "name": "execution_info", - "ordinal": 20, - "type_info": "Jsonb" - }, - { - "name": "contract_address", - "ordinal": 21, - "type_info": "Bytea" - }, - { - "name": "in_mempool", - "ordinal": 22, - "type_info": "Bool" - }, - { - "name": "l1_block_number", - "ordinal": 23, - "type_info": "Int4" - }, - { - "name": "value", - "ordinal": 24, - "type_info": "Numeric" - }, - { - "name": "paymaster", - "ordinal": 25, - "type_info": "Bytea" - }, - { - "name": "paymaster_input", - "ordinal": 26, - "type_info": "Bytea" - }, - { - "name": "max_fee_per_gas", - "ordinal": 27, - "type_info": "Numeric" - }, - { - "name": "max_priority_fee_per_gas", - "ordinal": 28, - "type_info": "Numeric" - }, - { - "name": "effective_gas_price", - "ordinal": 29, - "type_info": "Numeric" - }, - { - "name": "miniblock_number", - "ordinal": 30, - "type_info": "Int8" - }, - { - "name": "l1_batch_tx_index", - "ordinal": 31, - "type_info": "Int4" - }, - { - "name": "refunded_gas", - "ordinal": 32, - "type_info": "Int8" - }, - { - "name": "l1_tx_mint", - "ordinal": 33, - "type_info": "Numeric" - }, - { - "name": "l1_tx_refund_recipient", - "ordinal": 34, + "name": "fee_account_address?", + "ordinal": 17, "type_info": "Bytea" - }, - { - "name": "upgrade_id", - "ordinal": 35, - "type_info": "Int4" } ], "nullable": [ false, - false, - true, - true, - false, - true, - true, - true, + null, false, false, - true, - true, - true, - true, - true, - true, - true, - true, false, false, false, @@ -2750,135 +2590,385 @@ false, true, false, + true, false, false, true, true, true, - true, + false + ], + "parameters": { + "Left": [ + "Int8" + ] + } + }, + "query": "\n SELECT\n miniblocks.number,\n COALESCE(\n miniblocks.l1_batch_number,\n (\n SELECT\n (MAX(number) + 1)\n FROM\n l1_batches\n )\n ) AS \"l1_batch_number!\",\n miniblocks.timestamp,\n miniblocks.l1_tx_count,\n miniblocks.l2_tx_count,\n miniblocks.hash AS \"root_hash?\",\n commit_tx.tx_hash AS \"commit_tx_hash?\",\n commit_tx.confirmed_at AS \"committed_at?\",\n prove_tx.tx_hash AS \"prove_tx_hash?\",\n prove_tx.confirmed_at AS \"proven_at?\",\n execute_tx.tx_hash AS \"execute_tx_hash?\",\n execute_tx.confirmed_at AS \"executed_at?\",\n miniblocks.l1_gas_price,\n miniblocks.l2_fair_gas_price,\n miniblocks.bootloader_code_hash,\n miniblocks.default_aa_code_hash,\n miniblocks.protocol_version,\n l1_batches.fee_account_address AS \"fee_account_address?\"\n FROM\n miniblocks\n LEFT JOIN l1_batches ON miniblocks.l1_batch_number = l1_batches.number\n LEFT JOIN eth_txs_history AS commit_tx ON (\n l1_batches.eth_commit_tx_id = commit_tx.eth_tx_id\n AND commit_tx.confirmed_at IS NOT NULL\n )\n LEFT JOIN eth_txs_history AS prove_tx ON (\n l1_batches.eth_prove_tx_id = prove_tx.eth_tx_id\n AND prove_tx.confirmed_at IS NOT NULL\n )\n LEFT JOIN eth_txs_history AS execute_tx ON (\n l1_batches.eth_execute_tx_id = execute_tx.eth_tx_id\n AND execute_tx.confirmed_at IS NOT NULL\n )\n WHERE\n miniblocks.number = $1\n " + }, + "26cb272c2a46a267c47681e0f1f07997b7e24682da56f84d812da2b9aeb14ca2": { + "describe": { + "columns": [ + { + "name": "miniblock_number!", + "ordinal": 0, + "type_info": "Int8" + }, + { + "name": "hash", + "ordinal": 1, + "type_info": "Bytea" + }, + { + "name": "index_in_block!", + "ordinal": 2, + "type_info": "Int4" + }, + { + "name": "l1_batch_tx_index!", + "ordinal": 3, + "type_info": "Int4" + } + ], + "nullable": [ true, false, true, - true, true ], "parameters": { "Left": [ - "Int8", - "Numeric", - "Numeric", - "Int4" + "Int8" ] } }, - "query": "UPDATE transactions\n SET in_mempool = TRUE\n FROM (\n SELECT hash FROM (\n SELECT hash\n FROM transactions\n WHERE miniblock_number IS NULL AND in_mempool = FALSE AND error IS NULL\n AND (is_priority = TRUE OR (max_fee_per_gas >= $2 and gas_per_pubdata_limit >= $3))\n AND tx_format != $4\n ORDER BY is_priority DESC, priority_op_id, received_at\n LIMIT $1\n ) as subquery1\n ORDER BY hash\n ) as subquery2\n WHERE transactions.hash = subquery2.hash\n RETURNING transactions.*" + "query": "\n SELECT\n miniblock_number AS \"miniblock_number!\",\n hash,\n index_in_block AS \"index_in_block!\",\n l1_batch_tx_index AS \"l1_batch_tx_index!\"\n FROM\n transactions\n WHERE\n l1_batch_number = $1\n ORDER BY\n miniblock_number,\n index_in_block\n " }, - "2e3f116ca05ae70b7c83ac550302194c91f57b69902ff8e42140fde732ae5e6a": { + "26e0b7eb1871d94ddc98254fece6381a9c4165e2727542eaeef3bbedd13a4f20": { "describe": { "columns": [], "nullable": [], "parameters": { "Left": [ - "Int8", - "Int4Array" + "Text", + "Int8" ] } }, - "query": "DELETE FROM storage_logs WHERE miniblock_number = $1 AND operation_number != ALL($2)" + "query": "\n UPDATE proof_generation_details\n SET\n status = $1,\n updated_at = NOW()\n WHERE\n l1_batch_number = $2\n " }, - "2e543dc0013150040bb86e278bbe86765ce1ebad72a32bb931fe02a9c516a11c": { + "2737fea02599cdc163854b1395c42d4ef93ca238fd2fbc9155e6d012d0d1e113": { "describe": { "columns": [], "nullable": [], "parameters": { "Left": [ - "Bytea", - "Int8" + "Varchar", + "Bytea" ] } }, - "query": "UPDATE l1_batches SET hash = $1 WHERE number = $2" + "query": "\n UPDATE transactions\n SET\n error = $1,\n updated_at = NOW()\n WHERE\n hash = $2\n " }, - "2ff4a13a75537cc30b2c3d52d3ef6237850150e4a4569adeaa4da4a9ac5bc689": { + "2757b30c4641a346eb0226c706223efc18e51e6d4092188e081f4fafe92fe0ef": { "describe": { "columns": [ { - "name": "bytecode", + "name": "bootloader_code_hash", "ordinal": 0, "type_info": "Bytea" + }, + { + "name": "default_account_code_hash", + "ordinal": 1, + "type_info": "Bytea" + }, + { + "name": "id", + "ordinal": 2, + "type_info": "Int4" } ], "nullable": [ + false, + false, false ], "parameters": { "Left": [ - "Bytea", "Int8" ] } }, - "query": "SELECT bytecode FROM factory_deps WHERE bytecode_hash = $1 AND miniblock_number <= $2" + "query": "\n SELECT\n bootloader_code_hash,\n default_account_code_hash,\n id\n FROM\n protocol_versions\n WHERE\n timestamp <= $1\n ORDER BY\n id DESC\n LIMIT\n 1\n " }, - "300e5d4fa6d2481a10cb6d857f66a81b6c3760906c6c2ab02f126d52efc0d4d1": { + "280cf015e40353e2833c0a70b77095596297be0d728a0aa2d9b180fb72de222b": { "describe": { "columns": [ { - "name": "hash", + "name": "attempts", "ordinal": 0, - "type_info": "Bytea" - }, - { - "name": "is_priority", - "ordinal": 1, - "type_info": "Bool" - }, - { - "name": "full_fee", - "ordinal": 2, - "type_info": "Numeric" - }, - { - "name": "layer_2_tip_fee", - "ordinal": 3, - "type_info": "Numeric" - }, - { - "name": "initiator_address", - "ordinal": 4, - "type_info": "Bytea" - }, + "type_info": "Int2" + } + ], + "nullable": [ + false + ], + "parameters": { + "Left": [ + "Int8" + ] + } + }, + "query": "\n SELECT\n attempts\n FROM\n basic_witness_input_producer_jobs\n WHERE\n l1_batch_number = $1\n " + }, + "293258ecb299be5f5e81696d14883f115cd97586bd795ee31f58fc14e56d58cb": { + "describe": { + "columns": [], + "nullable": [], + "parameters": { + "Left": [ + "Int8" + ] + } + }, + "query": "\n DELETE FROM events\n WHERE\n miniblock_number > $1\n " + }, + "2955e976281f9cbd98b7378c5ab52964b268b93c32fd280c49bf9f932884300d": { + "describe": { + "columns": [ { - "name": "nonce", - "ordinal": 5, + "name": "timestamp", + "ordinal": 0, "type_info": "Int8" - }, - { - "name": "signature", - "ordinal": 6, - "type_info": "Bytea" - }, - { - "name": "input", - "ordinal": 7, - "type_info": "Bytea" - }, - { - "name": "data", - "ordinal": 8, - "type_info": "Jsonb" - }, - { - "name": "received_at", - "ordinal": 9, - "type_info": "Timestamp" - }, + } + ], + "nullable": [ + false + ], + "parameters": { + "Left": [] + } + }, + "query": "\n SELECT\n timestamp\n FROM\n l1_batches\n WHERE\n eth_prove_tx_id IS NULL\n AND number > 0\n ORDER BY\n number\n LIMIT\n 1\n " + }, + "2a2469109033ba08591db3647b73595fe783b7b894748d07fed9735c58fb28fb": { + "describe": { + "columns": [ { - "name": "priority_op_id", - "ordinal": 10, + "name": "number", + "ordinal": 0, "type_info": "Int8" - }, - { + } + ], + "nullable": [ + false + ], + "parameters": { + "Left": [] + } + }, + "query": "\n SELECT\n number\n FROM\n miniblocks\n WHERE\n consensus IS NOT NULL\n ORDER BY\n number DESC\n LIMIT\n 1\n " + }, + "2b626262c8003817ee02978f77452554ccfb5b83f00efdc12bed0f60ef439785": { + "describe": { + "columns": [ + { + "name": "id", + "ordinal": 0, + "type_info": "Int8" + } + ], + "nullable": [ + false + ], + "parameters": { + "Left": [ + "Int8", + "Int2", + "Int2", + "Int4" + ] + } + }, + "query": "\n SELECT\n id\n FROM\n prover_jobs_fri\n WHERE\n l1_batch_number = $1\n AND circuit_id = $2\n AND aggregation_round = $3\n AND depth = $4\n AND status = 'successful'\n ORDER BY\n sequence_number ASC;\n " + }, + "2c827c1c3cfa3552b90d4746c5df45d57f1f8b2558fdb374bf02e84d3c825a23": { + "describe": { + "columns": [ + { + "name": "number", + "ordinal": 0, + "type_info": "Int8" + } + ], + "nullable": [ + null + ], + "parameters": { + "Left": [] + } + }, + "query": "\n SELECT\n MAX(number) AS \"number\"\n FROM\n miniblocks\n " + }, + "2d0c2e9ec4187641baef8a33229bffc78d92adb3c1e3ca60b12163e38c67047e": { + "describe": { + "columns": [ + { + "name": "count!", + "ordinal": 0, + "type_info": "Int8" + } + ], + "nullable": [ + null + ], + "parameters": { + "Left": [ + "Bytea" + ] + } + }, + "query": "\n SELECT\n COUNT(*) AS \"count!\"\n FROM\n contracts_verification_info\n WHERE\n address = $1\n " + }, + "2d1e0f2e043c193052c9cc20f9efeb5f094160627bc09db4bda2dda9a8c11c44": { + "describe": { + "columns": [], + "nullable": [], + "parameters": { + "Left": [ + "Bytea", + "Jsonb" + ] + } + }, + "query": "\n INSERT INTO\n contracts_verification_info (address, verification_info)\n VALUES\n ($1, $2)\n ON CONFLICT (address) DO\n UPDATE\n SET\n verification_info = $2\n " + }, + "2d31fcce581975a82d6156b52e35fb7a093b73727f75e0cb7db9cea480c95f5c": { + "describe": { + "columns": [ + { + "name": "id", + "ordinal": 0, + "type_info": "Int8" + }, + { + "name": "status", + "ordinal": 1, + "type_info": "Text" + }, + { + "name": "attempts", + "ordinal": 2, + "type_info": "Int2" + } + ], + "nullable": [ + false, + false, + false + ], + "parameters": { + "Left": [ + "Interval", + "Int2" + ] + } + }, + "query": "\n UPDATE prover_jobs_fri\n SET\n status = 'queued',\n updated_at = NOW(),\n processing_started_at = NOW()\n WHERE\n id IN (\n SELECT\n id\n FROM\n prover_jobs_fri\n WHERE\n (\n status = 'in_progress'\n AND processing_started_at <= NOW() - $1::INTERVAL\n AND attempts < $2\n )\n OR (\n status = 'in_gpu_proof'\n AND processing_started_at <= NOW() - $1::INTERVAL\n AND attempts < $2\n )\n OR (\n status = 'failed'\n AND attempts < $2\n )\n FOR UPDATE\n SKIP LOCKED\n )\n RETURNING\n id,\n status,\n attempts\n " + }, + "2d862097cfae49a1fb28ec0a05176085385c3a79d72f49669b4215a9454323c2": { + "describe": { + "columns": [ + { + "name": "index", + "ordinal": 0, + "type_info": "Int8" + } + ], + "nullable": [ + false + ], + "parameters": { + "Left": [ + "Int8" + ] + } + }, + "query": "\n SELECT\n INDEX\n FROM\n initial_writes\n WHERE\n l1_batch_number <= $1\n ORDER BY\n l1_batch_number DESC,\n INDEX DESC\n LIMIT\n 1;\n " + }, + "2d87b294817859e42258136b1cb78f42a877039094c3d6354928a03dad29451a": { + "describe": { + "columns": [], + "nullable": [], + "parameters": { + "Left": [ + "Int8", + "Int4Array" + ] + } + }, + "query": "\n DELETE FROM storage_logs\n WHERE\n miniblock_number = $1\n AND operation_number != ALL ($2)\n " + }, + "2dd7dbaeb2572404451e78a96f540e73a2778633bbf9d8e591ec912634639af9": { + "describe": { + "columns": [ + { + "name": "hash", + "ordinal": 0, + "type_info": "Bytea" + }, + { + "name": "is_priority", + "ordinal": 1, + "type_info": "Bool" + }, + { + "name": "full_fee", + "ordinal": 2, + "type_info": "Numeric" + }, + { + "name": "layer_2_tip_fee", + "ordinal": 3, + "type_info": "Numeric" + }, + { + "name": "initiator_address", + "ordinal": 4, + "type_info": "Bytea" + }, + { + "name": "nonce", + "ordinal": 5, + "type_info": "Int8" + }, + { + "name": "signature", + "ordinal": 6, + "type_info": "Bytea" + }, + { + "name": "input", + "ordinal": 7, + "type_info": "Bytea" + }, + { + "name": "data", + "ordinal": 8, + "type_info": "Jsonb" + }, + { + "name": "received_at", + "ordinal": 9, + "type_info": "Timestamp" + }, + { + "name": "priority_op_id", + "ordinal": 10, + "type_info": "Int8" + }, + { "name": "l1_batch_number", "ordinal": 11, "type_info": "Int8" @@ -3043,42 +3133,348 @@ true ], "parameters": { - "Left": [] + "Left": [ + "Int8" + ] } }, - "query": "SELECT * FROM transactions WHERE miniblock_number IS NOT NULL AND l1_batch_number IS NULL ORDER BY miniblock_number, index_in_block" + "query": "\n SELECT\n *\n FROM\n transactions\n WHERE\n miniblock_number = $1\n ORDER BY\n index_in_block\n " }, - "3055b9f38a04f26dac9adbba978679e6877f44c758fd03461e940a8f9a4e5af1": { + "2ddba807ac8ec5260bf92c77073eb89c728357c0744f209090824695a5d35fa3": { "describe": { - "columns": [], - "nullable": [], + "columns": [ + { + "name": "hash", + "ordinal": 0, + "type_info": "Bytea" + } + ], + "nullable": [ + false + ], + "parameters": { + "Left": [ + "Int8" + ] + } + }, + "query": "\n UPDATE transactions\n SET\n l1_batch_number = NULL,\n miniblock_number = NULL,\n error = NULL,\n index_in_block = NULL,\n execution_info = '{}'\n WHERE\n miniblock_number > $1\n RETURNING\n hash\n " + }, + "2e0ea9434195270cc65cdca1f674d6b3b1d15b818974e4e403f4ac418ed40c2c": { + "describe": { + "columns": [ + { + "name": "id", + "ordinal": 0, + "type_info": "Int4" + } + ], + "nullable": [ + false + ], "parameters": { "Left": [ - "Int8", - "Int2", "Int4", + "Int8", + "Int8", "Text", - "Int4", - "Int4" + "Bytea" + ] + } + }, + "query": "\n INSERT INTO\n eth_txs_history (\n eth_tx_id,\n base_fee_per_gas,\n priority_fee_per_gas,\n tx_hash,\n signed_raw_tx,\n created_at,\n updated_at\n )\n VALUES\n ($1, $2, $3, $4, $5, NOW(), NOW())\n ON CONFLICT (tx_hash) DO NOTHING\n RETURNING\n id\n " + }, + "2e5b9ae1b81b0abfe7a962c93b3119a0a60dc9804175b2baf8b45939c74bd583": { + "describe": { + "columns": [], + "nullable": [], + "parameters": { + "Left": [ + "TextArray", + "Text" ] } }, - "query": "INSERT INTO node_aggregation_witness_jobs_fri (l1_batch_number, circuit_id, depth, aggregations_url, number_of_dependent_jobs, protocol_version, status, created_at, updated_at)\n VALUES ($1, $2, $3, $4, $5, $6, 'waiting_for_proofs', now(), now())\n ON CONFLICT(l1_batch_number, circuit_id, depth)\n DO UPDATE SET updated_at=now()" + "query": "\n INSERT INTO\n compiler_versions (VERSION, compiler, created_at, updated_at)\n SELECT\n u.version,\n $2,\n NOW(),\n NOW()\n FROM\n UNNEST($1::TEXT[]) AS u (VERSION)\n ON CONFLICT (VERSION, compiler) DO NOTHING\n " }, - "3167c62f6da5171081f6c003e64a3096829d4da94c3af48867d12d2c135f1a29": { + "2eb25bfcfc1114de825dc4eeb0605d7d1c9e649663f6e9444c4425821d0a5b71": { "describe": { "columns": [ { - "name": "number", + "name": "eth_commit_tx_id", "ordinal": 0, - "type_info": "Int8" - }, - { - "name": "timestamp", - "ordinal": 1, - "type_info": "Int8" - }, - { + "type_info": "Int4" + } + ], + "nullable": [ + true + ], + "parameters": { + "Left": [ + "Int8" + ] + } + }, + "query": "\n SELECT\n eth_commit_tx_id\n FROM\n l1_batches\n WHERE\n number = $1\n " + }, + "2eb617f3e34ac5b21f925053a45da2b4afc314a3b3e78b041b44c8a020a0ee12": { + "describe": { + "columns": [], + "nullable": [], + "parameters": { + "Left": [ + "ByteaArray" + ] + } + }, + "query": "\n UPDATE transactions\n SET\n in_mempool = FALSE\n FROM\n UNNEST($1::bytea[]) AS s (address)\n WHERE\n transactions.in_mempool = TRUE\n AND transactions.initiator_address = s.address\n " + }, + "314f7e619a34efa89255a58c89f85d4402ff6005446bbded68c8d3dbca510f37": { + "describe": { + "columns": [], + "nullable": [], + "parameters": { + "Left": [ + "Int8", + "Int8", + "Bytea", + "Int4", + "Int4", + "Numeric", + "Int8", + "Int8", + "Int8", + "Bytea", + "Bytea", + "Int4", + "Int8" + ] + } + }, + "query": "\n INSERT INTO\n miniblocks (\n number,\n timestamp,\n hash,\n l1_tx_count,\n l2_tx_count,\n base_fee_per_gas,\n l1_gas_price,\n l2_fair_gas_price,\n gas_per_pubdata_limit,\n bootloader_code_hash,\n default_aa_code_hash,\n protocol_version,\n virtual_blocks,\n created_at,\n updated_at\n )\n VALUES\n ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, NOW(), NOW())\n " + }, + "31f12a8c44124bb2ce31889ac5295f3823926f69cb1d54874878e6d6c301bfd8": { + "describe": { + "columns": [ + { + "name": "count!", + "ordinal": 0, + "type_info": "Int8" + } + ], + "nullable": [ + null + ], + "parameters": { + "Left": [] + } + }, + "query": "\n SELECT\n COUNT(*) AS \"count!\"\n FROM\n l1_batches\n " + }, + "322d919ff1ef4675623a58af2b0e9ebdda648667d48d6b27ddf155f2fe01d77a": { + "describe": { + "columns": [], + "nullable": [], + "parameters": { + "Left": [ + "Int8", + "Bytea", + "Bytea" + ] + } + }, + "query": "\n UPDATE l1_batches\n SET\n commitment = $2,\n aux_data_hash = $3,\n updated_at = NOW()\n WHERE\n number = $1\n " + }, + "3263423b6097fac01eadd978b826b831321c10f91b87cea38dc8a7377da9385e": { + "describe": { + "columns": [ + { + "name": "id", + "ordinal": 0, + "type_info": "Int8" + }, + { + "name": "circuit_input_blob_url", + "ordinal": 1, + "type_info": "Text" + } + ], + "nullable": [ + false, + true + ], + "parameters": { + "Left": [ + "Int8" + ] + } + }, + "query": "\n SELECT\n id,\n circuit_input_blob_url\n FROM\n prover_jobs\n WHERE\n status = 'successful'\n AND circuit_input_blob_url IS NOT NULL\n AND updated_at < NOW() - INTERVAL '30 days'\n LIMIT\n $1;\n " + }, + "32792c6aee69cb8c8b928a209a3b04ba5868d1897553df85aac15b169ebb0732": { + "describe": { + "columns": [], + "nullable": [], + "parameters": { + "Left": [ + "Int8", + { + "Custom": { + "kind": { + "Enum": [ + "Queued", + "ManuallySkipped", + "InProgress", + "Successful", + "Failed" + ] + }, + "name": "basic_witness_input_producer_job_status" + } + } + ] + } + }, + "query": "\n INSERT INTO\n basic_witness_input_producer_jobs (l1_batch_number, status, created_at, updated_at)\n VALUES\n ($1, $2, NOW(), NOW())\n ON CONFLICT (l1_batch_number) DO NOTHING\n " + }, + "33d6be45b246523ad76f9ae512322ff6372f63ecadb504a329499b02e7d3550e": { + "describe": { + "columns": [ + { + "name": "l1_batch_number", + "ordinal": 0, + "type_info": "Int8" + }, + { + "name": "circuit_id", + "ordinal": 1, + "type_info": "Int2" + } + ], + "nullable": [ + false, + false + ], + "parameters": { + "Left": [] + } + }, + "query": "\n UPDATE leaf_aggregation_witness_jobs_fri\n SET\n status = 'queued'\n WHERE\n (l1_batch_number, circuit_id) IN (\n SELECT\n prover_jobs_fri.l1_batch_number,\n prover_jobs_fri.circuit_id\n FROM\n prover_jobs_fri\n JOIN leaf_aggregation_witness_jobs_fri lawj ON prover_jobs_fri.l1_batch_number = lawj.l1_batch_number\n AND prover_jobs_fri.circuit_id = lawj.circuit_id\n WHERE\n lawj.status = 'waiting_for_proofs'\n AND prover_jobs_fri.status = 'successful'\n AND prover_jobs_fri.aggregation_round = 0\n GROUP BY\n prover_jobs_fri.l1_batch_number,\n prover_jobs_fri.circuit_id,\n lawj.number_of_basic_circuits\n HAVING\n COUNT(*) = lawj.number_of_basic_circuits\n )\n RETURNING\n l1_batch_number,\n circuit_id;\n " + }, + "3490fe0b778a03c73111bf8cbf426b0b3185a231bbf0b8b132a1a95bc157e827": { + "describe": { + "columns": [ + { + "name": "hashed_key", + "ordinal": 0, + "type_info": "Bytea" + }, + { + "name": "l1_batch_number", + "ordinal": 1, + "type_info": "Int8" + }, + { + "name": "index", + "ordinal": 2, + "type_info": "Int8" + } + ], + "nullable": [ + false, + false, + false + ], + "parameters": { + "Left": [ + "ByteaArray" + ] + } + }, + "query": "\n SELECT\n hashed_key,\n l1_batch_number,\n INDEX\n FROM\n initial_writes\n WHERE\n hashed_key = ANY ($1::bytea[])\n " + }, + "3502a673e04b57bfde096303d7643092702c835069cc055e01f382bc56681401": { + "describe": { + "columns": [], + "nullable": [], + "parameters": { + "Left": [ + "Time", + "Bytea", + "Text", + "Int8" + ] + } + }, + "query": "\n UPDATE prover_jobs\n SET\n status = 'successful',\n updated_at = NOW(),\n time_taken = $1,\n result = $2,\n proccesed_by = $3\n WHERE\n id = $4\n " + }, + "35b87a3b7db0af87c6a95e9fe7ef9044ae85b579c7051301b40bd5f94df1f530": { + "describe": { + "columns": [], + "nullable": [], + "parameters": { + "Left": [ + "Text", + "Int8" + ] + } + }, + "query": "\n UPDATE prover_jobs_fri\n SET\n status = 'failed',\n error = $1,\n updated_at = NOW()\n WHERE\n id = $2\n " + }, + "367ca58514762ffc26fd906c4c441a21691357494c2f9919bfcbcbb0e42315c2": { + "describe": { + "columns": [ + { + "name": "count!", + "ordinal": 0, + "type_info": "Int8" + } + ], + "nullable": [ + null + ], + "parameters": { + "Left": [ + "Int8" + ] + } + }, + "query": "\n SELECT\n COUNT(*) AS \"count!\"\n FROM\n miniblocks\n WHERE\n number = $1\n AND consensus IS NOT NULL\n " + }, + "373f6339a61c6ac74080f855fcc25dab33355eefdce69255bc7106675b0e5641": { + "describe": { + "columns": [ + { + "name": "count!", + "ordinal": 0, + "type_info": "Int8" + } + ], + "nullable": [ + null + ], + "parameters": { + "Left": [ + "Int4" + ] + } + }, + "query": "\n SELECT\n COUNT(*) AS \"count!\"\n FROM\n prover_protocol_versions\n WHERE\n id = $1\n " + }, + "3767abe810cebfc0ea1992948274c3c20ebc23e30b30eb1358fade7b23318414": { + "describe": { + "columns": [ + { + "name": "number", + "ordinal": 0, + "type_info": "Int8" + }, + { + "name": "timestamp", + "ordinal": 1, + "type_info": "Int8" + }, + { "name": "is_finished", "ordinal": 2, "type_info": "Bool" @@ -3307,142 +3703,121 @@ ], "parameters": { "Left": [ - "Bytea", - "Bytea", - "Int4", + "Int8", + "Int8", "Int8" ] } }, - "query": "SELECT number, l1_batches.timestamp, is_finished, l1_tx_count, l2_tx_count, fee_account_address, bloom, priority_ops_onchain_data, hash, parent_hash, commitment, compressed_write_logs, compressed_contracts, eth_prove_tx_id, eth_commit_tx_id, eth_execute_tx_id, merkle_root_hash, l2_to_l1_logs, l2_to_l1_messages, used_contract_hashes, compressed_initial_writes, compressed_repeated_writes, l2_l1_compressed_messages, l2_l1_merkle_root, l1_gas_price, l2_fair_gas_price, rollup_last_leaf_index, zkporter_is_available, l1_batches.bootloader_code_hash, l1_batches.default_aa_code_hash, base_fee_per_gas, aux_data_hash, pass_through_data_hash, meta_parameters_hash, protocol_version, compressed_state_diffs, system_logs, events_queue_commitment, bootloader_initial_content_commitment FROM l1_batches LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number JOIN protocol_versions ON protocol_versions.id = l1_batches.protocol_version WHERE eth_commit_tx_id IS NULL AND number != 0 AND protocol_versions.bootloader_code_hash = $1 AND protocol_versions.default_account_code_hash = $2 AND commitment IS NOT NULL AND (protocol_versions.id = $3 OR protocol_versions.upgrade_tx_hash IS NULL) ORDER BY number LIMIT $4" + "query": "\n SELECT\n number,\n timestamp,\n is_finished,\n l1_tx_count,\n l2_tx_count,\n fee_account_address,\n bloom,\n priority_ops_onchain_data,\n hash,\n parent_hash,\n commitment,\n compressed_write_logs,\n compressed_contracts,\n eth_prove_tx_id,\n eth_commit_tx_id,\n eth_execute_tx_id,\n merkle_root_hash,\n l2_to_l1_logs,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_compressed_messages,\n l2_l1_merkle_root,\n l1_gas_price,\n l2_fair_gas_price,\n rollup_last_leaf_index,\n zkporter_is_available,\n bootloader_code_hash,\n default_aa_code_hash,\n base_fee_per_gas,\n aux_data_hash,\n pass_through_data_hash,\n meta_parameters_hash,\n protocol_version,\n compressed_state_diffs,\n system_logs,\n events_queue_commitment,\n bootloader_initial_content_commitment\n FROM\n l1_batches\n LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number\n WHERE\n number BETWEEN $1 AND $2\n ORDER BY\n number\n LIMIT\n $3\n " }, - "334197fef9eeca55790d366ae67bbe95d77181bdfd2ad3208a32bd50585aef2d": { + "38a8b00e320b16e99f6ea0e5954e2f7e49cd6600bd3d56cf41795c2c9e082e4c": { "describe": { "columns": [ { - "name": "hashed_key", + "name": "number", "ordinal": 0, - "type_info": "Bytea" + "type_info": "Int8" } ], "nullable": [ - false + null ], "parameters": { - "Left": [ - "ByteaArray" - ] + "Left": [] } }, - "query": "SELECT hashed_key FROM initial_writes WHERE hashed_key = ANY($1)" + "query": "\n SELECT\n MAX(number) AS \"number\"\n FROM\n l1_batches\n " }, - "335826f54feadf6aa30a4e7668ad3f17a2afc6bd67d4f863e3ad61fefd1bd8d2": { + "3b0af308b0ce95a13a4eed40834279601234a489f73d843f2f314252ed4cb8b0": { "describe": { "columns": [ { - "name": "number", + "name": "hashed_key", "ordinal": 0, - "type_info": "Int8" + "type_info": "Bytea" + }, + { + "name": "value!", + "ordinal": 1, + "type_info": "Bytea" } ], "nullable": [ - null + false, + false ], "parameters": { - "Left": [] + "Left": [ + "ByteaArray" + ] + } + }, + "query": "\n SELECT\n hashed_key,\n value AS \"value!\"\n FROM\n storage\n WHERE\n hashed_key = ANY ($1)\n " + }, + "3b3fbcffd2702047045c2f358e8ac77b63879ab97a32eed8392b48cc46116a28": { + "describe": { + "columns": [], + "nullable": [], + "parameters": { + "Left": [ + "ByteaArray" + ] + } + }, + "query": "\n DELETE FROM call_traces\n WHERE\n tx_hash = ANY ($1)\n " + }, + "3b4d5009ec22f54cc7d305aa11d96ec397767a063dc21aa3add974cb9b070361": { + "describe": { + "columns": [], + "nullable": [], + "parameters": { + "Left": [ + "ByteaArray", + "ByteaArray", + "Int8" + ] } }, - "query": "SELECT MAX(number) as \"number\" FROM miniblocks" + "query": "\n INSERT INTO\n factory_deps (bytecode_hash, bytecode, miniblock_number, created_at, updated_at)\n SELECT\n u.bytecode_hash,\n u.bytecode,\n $3,\n NOW(),\n NOW()\n FROM\n UNNEST($1::bytea[], $2::bytea[]) AS u (bytecode_hash, bytecode)\n ON CONFLICT (bytecode_hash) DO NOTHING\n " }, - "34087096293cd8fc1c5bfcb412291c228afa1ce5dc8889a8535a2b2ecf569e03": { + "3c1d5f985be7e378211aa339c2c6387f2f3eda07a630503324bd6576dbdf8231": { "describe": { "columns": [ { - "name": "id", + "name": "trace", "ordinal": 0, - "type_info": "Int8" - }, - { - "name": "contract_address", - "ordinal": 1, - "type_info": "Bytea" - }, - { - "name": "source_code", - "ordinal": 2, - "type_info": "Text" - }, - { - "name": "contract_name", - "ordinal": 3, - "type_info": "Text" - }, - { - "name": "zk_compiler_version", - "ordinal": 4, - "type_info": "Text" - }, - { - "name": "compiler_version", - "ordinal": 5, - "type_info": "Text" - }, - { - "name": "optimization_used", - "ordinal": 6, - "type_info": "Bool" - }, - { - "name": "optimizer_mode", - "ordinal": 7, - "type_info": "Text" - }, - { - "name": "constructor_arguments", - "ordinal": 8, - "type_info": "Bytea" - }, - { - "name": "is_system", - "ordinal": 9, - "type_info": "Bool" + "type_info": "Jsonb" } ], "nullable": [ - false, - false, - false, - false, - false, - false, - false, - true, - false, false ], "parameters": { - "Left": [] + "Left": [ + "Bytea" + ] } }, - "query": "SELECT id, contract_address, source_code, contract_name, zk_compiler_version, compiler_version, optimization_used, optimizer_mode, constructor_arguments, is_system FROM contract_verification_requests WHERE status = 'successful' ORDER BY id" + "query": "\n SELECT\n trace\n FROM\n transaction_traces\n WHERE\n tx_hash = $1\n " }, - "34d78a04a9aa834e1846083c991138cef1e81b57c874a27ec65de5793e5681cc": { + "3c3abbf689fa64c6da7de69fd916769dbb04d3a61cf232892236c974660ffe64": { "describe": { "columns": [ { - "name": "hashed_key", + "name": "l1_batch_number", "ordinal": 0, - "type_info": "Bytea" + "type_info": "Int8" }, { - "name": "value", + "name": "status", "ordinal": 1, - "type_info": "Bytea" + "type_info": "Text" }, { - "name": "index", + "name": "attempts", "ordinal": 2, - "type_info": "Int8" + "type_info": "Int2" } ], "nullable": [ @@ -3452,15 +3827,92 @@ ], "parameters": { "Left": [ + "Interval", + "Int2" + ] + } + }, + "query": "\n UPDATE scheduler_witness_jobs_fri\n SET\n status = 'queued',\n updated_at = NOW(),\n processing_started_at = NOW()\n WHERE\n (\n status = 'in_progress'\n AND processing_started_at <= NOW() - $1::INTERVAL\n AND attempts < $2\n )\n OR (\n status = 'failed'\n AND attempts < $2\n )\n RETURNING\n l1_batch_number,\n status,\n attempts\n " + }, + "3e170eea3a5ea5c7389c15f76c6489745438eae73a07b577aa25bd08adf95354": { + "describe": { + "columns": [], + "nullable": [], + "parameters": { + "Left": [ + "Bytea", + "Int8", + "Bytea" + ] + } + }, + "query": "\n DELETE FROM tokens\n WHERE\n l2_address IN (\n SELECT\n SUBSTRING(key, 12, 20)\n FROM\n storage_logs\n WHERE\n storage_logs.address = $1\n AND miniblock_number > $2\n AND NOT EXISTS (\n SELECT\n 1\n FROM\n storage_logs AS s\n WHERE\n s.hashed_key = storage_logs.hashed_key\n AND (s.miniblock_number, s.operation_number) >= (storage_logs.miniblock_number, storage_logs.operation_number)\n AND s.value = $3\n )\n )\n " + }, + "3ec365c5c81f4678a905ae5bbd48b87ead36f593488437c6f67da629ca81e4fa": { + "describe": { + "columns": [], + "nullable": [], + "parameters": { + "Left": [ + "Int8" + ] + } + }, + "query": "\n UPDATE scheduler_witness_jobs_fri\n SET\n status = 'queued'\n WHERE\n l1_batch_number = $1\n AND status != 'successful'\n AND status != 'in_progress'\n " + }, + "40741973e34329d4924bce8d1af8d9b4ce7e457ed05e0973c18405a25d5ab025": { + "describe": { + "columns": [], + "nullable": [], + "parameters": { + "Left": [ + "Int8", + "Int4", + "Int4", + "Int8", + "Bool", + "Bytea", + "ByteaArray", + "ByteaArray", + "Bytea", + "ByteaArray", "Int8", + "Int8", + "Int8", + "Jsonb", + "Jsonb", + "Numeric", + "Int8", + "Int8", + "Bytea", + "Bytea", + "Int4", + "ByteaArray", + "Int8Array" + ] + } + }, + "query": "\n INSERT INTO\n l1_batches (\n number,\n l1_tx_count,\n l2_tx_count,\n timestamp,\n is_finished,\n fee_account_address,\n l2_to_l1_logs,\n l2_to_l1_messages,\n bloom,\n priority_ops_onchain_data,\n predicted_commit_gas_cost,\n predicted_prove_gas_cost,\n predicted_execute_gas_cost,\n initial_bootloader_heap_content,\n used_contract_hashes,\n base_fee_per_gas,\n l1_gas_price,\n l2_fair_gas_price,\n bootloader_code_hash,\n default_aa_code_hash,\n protocol_version,\n system_logs,\n storage_refunds,\n created_at,\n updated_at\n )\n VALUES\n (\n $1,\n $2,\n $3,\n $4,\n $5,\n $6,\n $7,\n $8,\n $9,\n $10,\n $11,\n $12,\n $13,\n $14,\n $15,\n $16,\n $17,\n $18,\n $19,\n $20,\n $21,\n $22,\n $23,\n NOW(),\n NOW()\n )\n " + }, + "40c82325e05572db9c3a4ca8cc347617ed18495ef147b3ecfacdd89f54957b6a": { + "describe": { + "columns": [], + "nullable": [], + "parameters": { + "Left": [ + "Int4", + "Int8", + "Bytea", + "Bytea", + "Bytea", "Bytea", "Bytea" ] } }, - "query": "SELECT storage_logs.hashed_key, storage_logs.value, initial_writes.index FROM storage_logs INNER JOIN initial_writes ON storage_logs.hashed_key = initial_writes.hashed_key WHERE storage_logs.miniblock_number = $1 AND storage_logs.hashed_key >= $2::bytea AND storage_logs.hashed_key <= $3::bytea ORDER BY storage_logs.hashed_key" + "query": "\n INSERT INTO\n prover_protocol_versions (\n id,\n timestamp,\n recursion_scheduler_level_vk_hash,\n recursion_node_level_vk_hash,\n recursion_leaf_level_vk_hash,\n recursion_circuits_set_vks_hash,\n verifier_address,\n created_at\n )\n VALUES\n ($1, $2, $3, $4, $5, $6, $7, NOW())\n " }, - "357347157ed8ff19d223c54533c3a85bd7e64a37514d657f8d49bd6eb5be1806": { + "41c9f45d6eb727aafad0d8c18024cee5c602d275bb812022cc8fdabf0a60e151": { "describe": { "columns": [ { @@ -3469,61 +3921,37 @@ "type_info": "Int4" }, { - "name": "timestamp", + "name": "eth_tx_id", "ordinal": 1, - "type_info": "Int8" + "type_info": "Int4" }, { - "name": "recursion_scheduler_level_vk_hash", + "name": "tx_hash", "ordinal": 2, - "type_info": "Bytea" + "type_info": "Text" }, { - "name": "recursion_node_level_vk_hash", + "name": "base_fee_per_gas", "ordinal": 3, - "type_info": "Bytea" + "type_info": "Int8" }, { - "name": "recursion_leaf_level_vk_hash", + "name": "priority_fee_per_gas", "ordinal": 4, - "type_info": "Bytea" + "type_info": "Int8" }, { - "name": "recursion_circuits_set_vks_hash", + "name": "signed_raw_tx", "ordinal": 5, "type_info": "Bytea" }, { - "name": "bootloader_code_hash", + "name": "nonce", "ordinal": 6, - "type_info": "Bytea" - }, - { - "name": "default_account_code_hash", - "ordinal": 7, - "type_info": "Bytea" - }, - { - "name": "verifier_address", - "ordinal": 8, - "type_info": "Bytea" - }, - { - "name": "upgrade_tx_hash", - "ordinal": 9, - "type_info": "Bytea" - }, - { - "name": "created_at", - "ordinal": 10, - "type_info": "Timestamp" + "type_info": "Int8" } ], "nullable": [ - false, - false, - false, - false, false, false, false, @@ -3536,121 +3964,231 @@ "Left": [] } }, - "query": "SELECT * FROM protocol_versions ORDER BY id DESC LIMIT 1" + "query": "\n SELECT\n eth_txs_history.id,\n eth_txs_history.eth_tx_id,\n eth_txs_history.tx_hash,\n eth_txs_history.base_fee_per_gas,\n eth_txs_history.priority_fee_per_gas,\n eth_txs_history.signed_raw_tx,\n eth_txs.nonce\n FROM\n eth_txs_history\n JOIN eth_txs ON eth_txs.id = eth_txs_history.eth_tx_id\n WHERE\n eth_txs_history.sent_at_block IS NULL\n AND eth_txs.confirmed_eth_tx_history_id IS NULL\n ORDER BY\n eth_txs_history.id DESC\n " }, - "37e4a0eea7b72bd3b75c26e003f3fa62039d9b614f0f2fa3d61e8c5e95f002fd": { + "45b5825c82d33c9494ceef0fdc77675b89128d56559b8c89465844a914f5245e": { "describe": { "columns": [ { - "name": "max?", + "name": "number", "ordinal": 0, "type_info": "Int8" - } - ], - "nullable": [ - null - ], - "parameters": { - "Left": [] - } - }, - "query": "SELECT MAX(index) as \"max?\" FROM initial_writes" - }, - "394bbd64939d47fda4e1545e2752b208901e872b7234a5c3af456bdf429a6074": { - "describe": { - "columns": [ - { - "name": "tx_hash", - "ordinal": 0, - "type_info": "Bytea" }, { - "name": "call_trace", + "name": "timestamp", "ordinal": 1, - "type_info": "Bytea" - } - ], - "nullable": [ - false, - false - ], - "parameters": { - "Left": [ - "Bytea" - ] - } - }, - "query": "\n SELECT * FROM call_traces\n WHERE tx_hash = $1\n " - }, - "3a18d0d1e236d8f57e8b3b1218a24414639a7c8235ba6a514c3d03b8a1790f17": { - "describe": { - "columns": [ - { - "name": "l1_batch_number", - "ordinal": 0, "type_info": "Int8" }, { - "name": "merkle_tree_paths_blob_url", - "ordinal": 1, - "type_info": "Text" - }, - { - "name": "attempts", + "name": "is_finished", "ordinal": 2, - "type_info": "Int2" + "type_info": "Bool" }, { - "name": "status", + "name": "l1_tx_count", "ordinal": 3, - "type_info": "Text" + "type_info": "Int4" }, { - "name": "error", + "name": "l2_tx_count", "ordinal": 4, - "type_info": "Text" + "type_info": "Int4" }, { - "name": "created_at", + "name": "fee_account_address", "ordinal": 5, - "type_info": "Timestamp" + "type_info": "Bytea" }, { - "name": "updated_at", + "name": "bloom", "ordinal": 6, - "type_info": "Timestamp" + "type_info": "Bytea" }, { - "name": "processing_started_at", + "name": "priority_ops_onchain_data", "ordinal": 7, - "type_info": "Timestamp" + "type_info": "ByteaArray" }, { - "name": "time_taken", + "name": "hash", "ordinal": 8, - "type_info": "Time" + "type_info": "Bytea" }, { - "name": "is_blob_cleaned", + "name": "parent_hash", "ordinal": 9, + "type_info": "Bytea" + }, + { + "name": "commitment", + "ordinal": 10, + "type_info": "Bytea" + }, + { + "name": "compressed_write_logs", + "ordinal": 11, + "type_info": "Bytea" + }, + { + "name": "compressed_contracts", + "ordinal": 12, + "type_info": "Bytea" + }, + { + "name": "eth_prove_tx_id", + "ordinal": 13, + "type_info": "Int4" + }, + { + "name": "eth_commit_tx_id", + "ordinal": 14, + "type_info": "Int4" + }, + { + "name": "eth_execute_tx_id", + "ordinal": 15, + "type_info": "Int4" + }, + { + "name": "merkle_root_hash", + "ordinal": 16, + "type_info": "Bytea" + }, + { + "name": "l2_to_l1_logs", + "ordinal": 17, + "type_info": "ByteaArray" + }, + { + "name": "l2_to_l1_messages", + "ordinal": 18, + "type_info": "ByteaArray" + }, + { + "name": "used_contract_hashes", + "ordinal": 19, + "type_info": "Jsonb" + }, + { + "name": "compressed_initial_writes", + "ordinal": 20, + "type_info": "Bytea" + }, + { + "name": "compressed_repeated_writes", + "ordinal": 21, + "type_info": "Bytea" + }, + { + "name": "l2_l1_compressed_messages", + "ordinal": 22, + "type_info": "Bytea" + }, + { + "name": "l2_l1_merkle_root", + "ordinal": 23, + "type_info": "Bytea" + }, + { + "name": "l1_gas_price", + "ordinal": 24, + "type_info": "Int8" + }, + { + "name": "l2_fair_gas_price", + "ordinal": 25, + "type_info": "Int8" + }, + { + "name": "rollup_last_leaf_index", + "ordinal": 26, + "type_info": "Int8" + }, + { + "name": "zkporter_is_available", + "ordinal": 27, "type_info": "Bool" }, + { + "name": "bootloader_code_hash", + "ordinal": 28, + "type_info": "Bytea" + }, + { + "name": "default_aa_code_hash", + "ordinal": 29, + "type_info": "Bytea" + }, + { + "name": "base_fee_per_gas", + "ordinal": 30, + "type_info": "Numeric" + }, + { + "name": "aux_data_hash", + "ordinal": 31, + "type_info": "Bytea" + }, + { + "name": "pass_through_data_hash", + "ordinal": 32, + "type_info": "Bytea" + }, + { + "name": "meta_parameters_hash", + "ordinal": 33, + "type_info": "Bytea" + }, { "name": "protocol_version", - "ordinal": 10, + "ordinal": 34, "type_info": "Int4" }, { - "name": "picked_by", - "ordinal": 11, - "type_info": "Text" + "name": "compressed_state_diffs", + "ordinal": 35, + "type_info": "Bytea" + }, + { + "name": "system_logs", + "ordinal": 36, + "type_info": "ByteaArray" + }, + { + "name": "events_queue_commitment", + "ordinal": 37, + "type_info": "Bytea" + }, + { + "name": "bootloader_initial_content_commitment", + "ordinal": 38, + "type_info": "Bytea" } ], "nullable": [ false, + false, + false, + false, + false, + false, + false, + false, + true, + true, + true, + true, + true, + true, + true, + true, true, false, false, + false, + true, + true, + true, true, false, false, @@ -3658,180 +4196,227 @@ true, true, true, + false, + true, + true, + true, + true, + true, + false, + true, true ], "parameters": { - "Left": [ - "Int8", - "Int4Array", - "Text" - ] - } - }, - "query": "\n UPDATE witness_inputs_fri\n SET status = 'in_progress', attempts = attempts + 1,\n updated_at = now(), processing_started_at = now(),\n picked_by = $3\n WHERE l1_batch_number = (\n SELECT l1_batch_number\n FROM witness_inputs_fri\n WHERE l1_batch_number <= $1\n AND status = 'queued'\n AND protocol_version = ANY($2)\n ORDER BY l1_batch_number ASC\n LIMIT 1\n FOR UPDATE\n SKIP LOCKED\n )\n RETURNING witness_inputs_fri.*\n " - }, - "3a6bb31237b29755a0031dbb4a47e51e474fe8d4d12bb1ead6f991905cfbe6a4": { - "describe": { - "columns": [ - { - "name": "id", - "ordinal": 0, - "type_info": "Int4" - } - ], - "nullable": [ - false - ], - "parameters": { - "Left": [ - "Int4", - "Int8", - "Int8", - "Text", - "Bytea" - ] + "Left": [] } }, - "query": "INSERT INTO eth_txs_history (eth_tx_id, base_fee_per_gas, priority_fee_per_gas, tx_hash, signed_raw_tx, created_at, updated_at) VALUES ($1, $2, $3, $4, $5, now(), now()) ON CONFLICT (tx_hash) DO NOTHING RETURNING id" + "query": "\n SELECT\n number,\n timestamp,\n is_finished,\n l1_tx_count,\n l2_tx_count,\n fee_account_address,\n bloom,\n priority_ops_onchain_data,\n hash,\n parent_hash,\n commitment,\n compressed_write_logs,\n compressed_contracts,\n eth_prove_tx_id,\n eth_commit_tx_id,\n eth_execute_tx_id,\n merkle_root_hash,\n l2_to_l1_logs,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_compressed_messages,\n l2_l1_merkle_root,\n l1_gas_price,\n l2_fair_gas_price,\n rollup_last_leaf_index,\n zkporter_is_available,\n bootloader_code_hash,\n default_aa_code_hash,\n base_fee_per_gas,\n aux_data_hash,\n pass_through_data_hash,\n meta_parameters_hash,\n protocol_version,\n compressed_state_diffs,\n system_logs,\n events_queue_commitment,\n bootloader_initial_content_commitment\n FROM\n l1_batches\n LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number\n WHERE\n number = 0\n OR eth_commit_tx_id IS NOT NULL\n AND commitment IS NOT NULL\n ORDER BY\n number DESC\n LIMIT\n 1\n " }, - "3ac1fe562e9664bbf8c02ba3090cf97a37663e228eff48fec326f74b2313daa9": { + "46c4696fff5a4b8cc5cb46b05645da82065836fe17687ffad04126a6a8b2b27c": { "describe": { "columns": [], "nullable": [], "parameters": { "Left": [ - "ByteaArray" + "Time", + "Int8" ] } }, - "query": "DELETE FROM call_traces\n WHERE tx_hash = ANY($1)" + "query": "\n UPDATE leaf_aggregation_witness_jobs_fri\n SET\n status = 'successful',\n updated_at = NOW(),\n time_taken = $1\n WHERE\n id = $2\n " }, - "3be0d3fd7a1ff997edb1eaff3fac59324a5b33663e7862cfddd4a5db8015f13c": { + "481d3cdb6c9a90843b240dba84377cb8f1340b483faedbbc2b71055aa5451cae": { "describe": { "columns": [ { - "name": "attempts", + "name": "number", "ordinal": 0, - "type_info": "Int2" + "type_info": "Int8" } ], "nullable": [ - false + null ], "parameters": { - "Left": [ - "Int8" - ] - } - }, - "query": "SELECT attempts FROM leaf_aggregation_witness_jobs_fri WHERE id = $1" - }, - "3c582aeed32235ef175707de412a9f9129fad6ea5e87ebb85f68e20664b0da46": { - "describe": { - "columns": [], - "nullable": [], - "parameters": { - "Left": [ - "Int4Array", - "ByteaArray", - "Int8" - ] - } - }, - "query": "\n UPDATE transactions\n SET \n l1_batch_number = $3,\n l1_batch_tx_index = data_table.l1_batch_tx_index,\n updated_at = now()\n FROM\n (SELECT\n UNNEST($1::int[]) AS l1_batch_tx_index,\n UNNEST($2::bytea[]) AS hash\n ) AS data_table\n WHERE transactions.hash=data_table.hash \n " - }, - "3d41f05e1d5c5a74e0605e66fe08e09f14b8bf0269e5dcde518aa08db92a3ea0": { - "describe": { - "columns": [], - "nullable": [], - "parameters": { - "Left": [ - "Int8" - ] + "Left": [] } }, - "query": "DELETE FROM events WHERE miniblock_number > $1" + "query": "\n SELECT\n MAX(number) AS \"number\"\n FROM\n l1_batches\n WHERE\n is_finished = TRUE\n " }, - "3e982e4863eef38069e755e3f20602ef9eaae859d23d86c3f230ddea8805aea7": { + "4d263992ed6d5abbd7d3ca43af9d772d8801b0ae673b7173ae08a1fa6cbf67b2": { "describe": { "columns": [ { - "name": "index", + "name": "id", "ordinal": 0, "type_info": "Int8" + }, + { + "name": "l1_batch_number", + "ordinal": 1, + "type_info": "Int8" + }, + { + "name": "circuit_id", + "ordinal": 2, + "type_info": "Int2" + }, + { + "name": "aggregation_round", + "ordinal": 3, + "type_info": "Int2" + }, + { + "name": "sequence_number", + "ordinal": 4, + "type_info": "Int4" + }, + { + "name": "depth", + "ordinal": 5, + "type_info": "Int4" + }, + { + "name": "is_node_final_proof", + "ordinal": 6, + "type_info": "Bool" } ], "nullable": [ + false, + false, + false, + false, + false, + false, false ], "parameters": { "Left": [ - "Bytea" + "Int4Array", + "Text" ] } }, - "query": "SELECT index FROM initial_writes WHERE hashed_key = $1" + "query": "\n UPDATE prover_jobs_fri\n SET\n status = 'in_progress',\n attempts = attempts + 1,\n updated_at = NOW(),\n processing_started_at = NOW(),\n picked_by = $2\n WHERE\n id = (\n SELECT\n id\n FROM\n prover_jobs_fri\n WHERE\n status = 'queued'\n AND protocol_version = ANY ($1)\n ORDER BY\n aggregation_round DESC,\n l1_batch_number ASC,\n id ASC\n LIMIT\n 1\n FOR UPDATE\n SKIP LOCKED\n )\n RETURNING\n prover_jobs_fri.id,\n prover_jobs_fri.l1_batch_number,\n prover_jobs_fri.circuit_id,\n prover_jobs_fri.aggregation_round,\n prover_jobs_fri.sequence_number,\n prover_jobs_fri.depth,\n prover_jobs_fri.is_node_final_proof\n " }, - "3f6332706376ef4cadda96498872429b6ed28eca5402b03b1aa3b77b8262bccd": { + "4d50dabc25d392e6b9d0dbe0e386ea7ef2c1178b1b0394a17442185b79f2d77d": { "describe": { - "columns": [], - "nullable": [], + "columns": [ + { + "name": "id", + "ordinal": 0, + "type_info": "Int4" + } + ], + "nullable": [ + false + ], "parameters": { "Left": [ "Text" ] } }, - "query": "DELETE FROM compiler_versions WHERE compiler = $1" + "query": "SELECT eth_txs.id FROM eth_txs_history JOIN eth_txs ON eth_txs.confirmed_eth_tx_history_id = eth_txs_history.id WHERE eth_txs_history.tx_hash = $1" }, - "3f671298a05f3f69a8ffb2e36d5ae79c544145fc1c289dd9e0c060dca3ec6e21": { + "4d84bb4e180b7267bee5e3c1f83c6d47e8e1b4b5124c82c1f35d405204fcf783": { "describe": { - "columns": [], - "nullable": [], + "columns": [ + { + "name": "id", + "ordinal": 0, + "type_info": "Int4" + }, + { + "name": "eth_tx_id", + "ordinal": 1, + "type_info": "Int4" + }, + { + "name": "tx_hash", + "ordinal": 2, + "type_info": "Text" + }, + { + "name": "created_at", + "ordinal": 3, + "type_info": "Timestamp" + }, + { + "name": "updated_at", + "ordinal": 4, + "type_info": "Timestamp" + }, + { + "name": "base_fee_per_gas", + "ordinal": 5, + "type_info": "Int8" + }, + { + "name": "priority_fee_per_gas", + "ordinal": 6, + "type_info": "Int8" + }, + { + "name": "confirmed_at", + "ordinal": 7, + "type_info": "Timestamp" + }, + { + "name": "signed_raw_tx", + "ordinal": 8, + "type_info": "Bytea" + }, + { + "name": "sent_at_block", + "ordinal": 9, + "type_info": "Int4" + }, + { + "name": "sent_at", + "ordinal": 10, + "type_info": "Timestamp" + } + ], + "nullable": [ + false, + false, + false, + false, + false, + false, + false, + true, + true, + true, + true + ], "parameters": { "Left": [ - "ByteaArray", - "ByteaArray" + "Int4" ] } }, - "query": "UPDATE storage SET value = u.value FROM UNNEST($1::bytea[], $2::bytea[]) AS u(key, value) WHERE u.key = hashed_key" + "query": "\n SELECT\n *\n FROM\n eth_txs_history\n WHERE\n eth_tx_id = $1\n ORDER BY\n created_at DESC\n " }, - "4029dd84cde963ed8541426a659b10ccdbacbf4392664e34bfc29737aa630b28": { + "4d92a133a36afd682a84fbfd75aafca34d61347e0e2e29fb07ca3d1b8b1f309c": { "describe": { "columns": [], "nullable": [], "parameters": { "Left": [ - "Int8", "Int4", - "Int4", - "Int8", - "Bool", - "Bytea", - "ByteaArray", - "ByteaArray", "Bytea", - "ByteaArray", - "Int8", - "Int8", - "Int8", - "Jsonb", - "Jsonb", - "Numeric", - "Int8", - "Int8", "Bytea", "Bytea", - "Int4", - "ByteaArray", - "Int8Array" + "Bytea" ] } }, - "query": "INSERT INTO l1_batches (number, l1_tx_count, l2_tx_count, timestamp, is_finished, fee_account_address, l2_to_l1_logs, l2_to_l1_messages, bloom, priority_ops_onchain_data, predicted_commit_gas_cost, predicted_prove_gas_cost, predicted_execute_gas_cost, initial_bootloader_heap_content, used_contract_hashes, base_fee_per_gas, l1_gas_price, l2_fair_gas_price, bootloader_code_hash, default_aa_code_hash, protocol_version, system_logs, storage_refunds, created_at, updated_at ) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, now(), now())" + "query": "\n INSERT INTO\n prover_fri_protocol_versions (\n id,\n recursion_scheduler_level_vk_hash,\n recursion_node_level_vk_hash,\n recursion_leaf_level_vk_hash,\n recursion_circuits_set_vks_hash,\n created_at\n )\n VALUES\n ($1, $2, $3, $4, $5, NOW())\n ON CONFLICT (id) DO NOTHING\n " }, - "42762c079948860eb59ba807eb9ae5a53b94c93e6b5635471d0018dde1d4c9d9": { + "4e2cb66131a524d1bd628424d0c0735d7f9b0b5820ae3a07467d2e76cd6280f9": { "describe": { "columns": [ { @@ -3840,24 +4425,52 @@ "type_info": "Int8" }, { - "name": "merkel_tree_paths_blob_url", + "name": "factory_deps_filepath", "ordinal": 1, "type_info": "Text" + }, + { + "name": "storage_logs_filepaths", + "ordinal": 2, + "type_info": "TextArray" } ], "nullable": [ false, - true + false, + false ], "parameters": { - "Left": [ - "Int8" - ] + "Left": [] + } + }, + "query": "\n SELECT\n l1_batch_number,\n factory_deps_filepath,\n storage_logs_filepaths\n FROM\n snapshots\n " + }, + "4f9b84e4ee54902edb3738ec111268d1266a05f4d931dd874baceedf5444efa4": { + "describe": { + "columns": [ + { + "name": "l1_batch_number!", + "ordinal": 0, + "type_info": "Int8" + }, + { + "name": "aggregation_round", + "ordinal": 1, + "type_info": "Int4" + } + ], + "nullable": [ + null, + false + ], + "parameters": { + "Left": [] } }, - "query": "SELECT l1_batch_number, merkel_tree_paths_blob_url FROM witness_inputs WHERE status = 'successful' AND merkel_tree_paths_blob_url is NOT NULL AND updated_at < NOW() - INTERVAL '30 days' LIMIT $1" + "query": "\n SELECT\n MAX(l1_batch_number) AS \"l1_batch_number!\",\n aggregation_round\n FROM\n prover_jobs\n WHERE\n status = 'successful'\n GROUP BY\n aggregation_round\n " }, - "43b5082ff7673ee3a8e8f3fafa64667fac4f7f5c8bd26a21ead6b4ba0f8fd17b": { + "525123d4ec2b427f1c171f30d0937d8d542b4f14cf560972c005ab3cc13d1f63": { "describe": { "columns": [ { @@ -3871,59 +4484,66 @@ ], "parameters": { "Left": [ + "Int8", "Int8" ] } }, - "query": "SELECT hash FROM miniblocks WHERE number = $1" + "query": "\n SELECT\n hash\n FROM\n miniblocks\n WHERE\n number BETWEEN $1 AND $2\n ORDER BY\n number\n " }, - "448d283cab6ae334de9676f69416974656d11563b58e0188d53ca9e0995dd287": { + "532a80b0873871896dd318beba5ec427a099492905a1feee512dc43f39d10047": { "describe": { "columns": [], "nullable": [], "parameters": { "Left": [ - "Int8Array" + "Int4", + "Int4" ] } }, - "query": "\n UPDATE scheduler_dependency_tracker_fri\n SET status='queued'\n WHERE l1_batch_number = ANY($1)\n " + "query": "\n UPDATE eth_txs_history\n SET\n sent_at_block = $2,\n sent_at = NOW()\n WHERE\n id = $1\n AND sent_at_block IS NULL\n " }, - "4588d998b3454d8210190c6b16116b5885f6f3e74606aec8250e6c1e8f55d242": { + "534822a226068cde83ad8c30b569a8f447824a5ab466bb6eea1710e8aeaa2c56": { "describe": { "columns": [], "nullable": [], "parameters": { - "Left": [] + "Left": [ + "Text", + "Int8" + ] } }, - "query": "VACUUM storage_logs" + "query": "\n UPDATE proof_compression_jobs_fri\n SET\n status = $1,\n updated_at = NOW()\n WHERE\n l1_batch_number = $2\n " }, - "4860c1118485da8673963a260ded76eb8e13989936f9ab17e23687a1103132cb": { + "53c04fd528752c0e0ef7ffa1f68a7ea81d8d10c76bbae540013667e13230e2ea": { "describe": { "columns": [ { - "name": "l1_batch_number", + "name": "fee_account_address", "ordinal": 0, - "type_info": "Int8" + "type_info": "Bytea" } ], "nullable": [ false ], "parameters": { - "Left": [] + "Left": [ + "Int8" + ] } }, - "query": "SELECT l1_batch_number FROM proof_generation_details WHERE status = 'ready_to_be_proven' ORDER BY l1_batch_number ASC LIMIT 1" + "query": "\n SELECT\n fee_account_address\n FROM\n l1_batches\n WHERE\n number = $1\n " }, - "4ab8a25620b5400d836e1b847320d4e176629a27e1a6cb0666ab02bb55371769": { + "53f78fdee39b113d2f55f6f951bd94f28b7b2b60d551d552a9b0bab1f1791e39": { "describe": { "columns": [ { - "name": "hash", + "name": "attempts", "ordinal": 0, - "type_info": "Bytea" + "type_info": "Int2" } ], "nullable": [ @@ -3931,73 +4551,58 @@ ], "parameters": { "Left": [ - "Interval" + "Int8" ] } }, - "query": "DELETE FROM transactions WHERE miniblock_number IS NULL AND received_at < now() - $1::interval AND is_priority=false AND error IS NULL RETURNING hash" + "query": "\n SELECT\n attempts\n FROM\n leaf_aggregation_witness_jobs_fri\n WHERE\n id = $1\n " }, - "4ac212a08324b9d4c3febc585109f19105b4d20aa3e290352e3c63d7ec58c5b2": { + "5503575d9377785894de6cf6139a8d4768c6a803a1a90889e5a1b8254c315231": { "describe": { "columns": [ { - "name": "l2_address", + "name": "id", "ordinal": 0, - "type_info": "Bytea" + "type_info": "Int4" } ], "nullable": [ false ], "parameters": { - "Left": [] + "Left": [ + "Text" + ] } }, - "query": "SELECT l2_address FROM tokens" + "query": "INSERT INTO eth_txs (raw_tx, nonce, tx_type, contract_address, predicted_gas_cost, created_at, updated_at) VALUES ('\\x00', 0, $1, '', 0, now(), now()) RETURNING id" }, - "4ac92a8436108097a32e94e53f7fe99261c7c3a40dbc433c20ccea3a7d06650c": { + "556f9b9e82d3a9399660dfa4bbf252f26335699a4e7f0347d7e894320245271d": { "describe": { - "columns": [ - { - "name": "hashed_key", - "ordinal": 0, - "type_info": "Bytea" - }, - { - "name": "value!", - "ordinal": 1, - "type_info": "Bytea" - } - ], - "nullable": [ - false, - false - ], + "columns": [], + "nullable": [], "parameters": { "Left": [ - "ByteaArray" + "Int8", + "Jsonb" ] } }, - "query": "SELECT hashed_key, value as \"value!\" FROM storage WHERE hashed_key = ANY($1)" + "query": "\n INSERT INTO\n events_queue (l1_batch_number, serialized_events_queue)\n VALUES\n ($1, $2)\n " }, - "4aef34fb19a07dbfe2be09024d6c7fc2033a8e1570cc7f002a5c78317ff8ff3f": { + "55b0b4c569c0aaf9741afc85400ecd50a04799ffd36be0e17c56f47fcdbc8f60": { "describe": { "columns": [], "nullable": [], "parameters": { "Left": [ - "Int8", - "Int2", - "Text", - "Int4", - "Int4" + "Int8" ] } }, - "query": "\n INSERT INTO leaf_aggregation_witness_jobs_fri\n (l1_batch_number, circuit_id, closed_form_inputs_blob_url, number_of_basic_circuits, protocol_version, status, created_at, updated_at)\n VALUES ($1, $2, $3, $4, $5, 'waiting_for_proofs', now(), now())\n ON CONFLICT(l1_batch_number, circuit_id)\n DO UPDATE SET updated_at=now()\n " + "query": "\n DELETE FROM l1_batches\n WHERE\n number > $1\n " }, - "4b8597a47c0724155ad9592dc32134523bcbca11c9d82763d1bebbe17479c7b4": { + "5659480e5d79dab3399e35539b240e7eb9f598999c28015a504605f88bf84b33": { "describe": { "columns": [ { @@ -4006,54 +4611,59 @@ "type_info": "Int4" }, { - "name": "timestamp", + "name": "nonce", "ordinal": 1, "type_info": "Int8" }, { - "name": "recursion_scheduler_level_vk_hash", + "name": "raw_tx", "ordinal": 2, "type_info": "Bytea" }, { - "name": "recursion_node_level_vk_hash", + "name": "contract_address", "ordinal": 3, - "type_info": "Bytea" + "type_info": "Text" }, { - "name": "recursion_leaf_level_vk_hash", + "name": "tx_type", "ordinal": 4, - "type_info": "Bytea" + "type_info": "Text" }, { - "name": "recursion_circuits_set_vks_hash", + "name": "gas_used", "ordinal": 5, - "type_info": "Bytea" + "type_info": "Int8" }, { - "name": "bootloader_code_hash", + "name": "created_at", "ordinal": 6, - "type_info": "Bytea" + "type_info": "Timestamp" }, { - "name": "default_account_code_hash", + "name": "updated_at", "ordinal": 7, - "type_info": "Bytea" + "type_info": "Timestamp" }, { - "name": "verifier_address", + "name": "has_failed", "ordinal": 8, - "type_info": "Bytea" + "type_info": "Bool" }, { - "name": "upgrade_tx_hash", + "name": "sent_at_block", "ordinal": 9, - "type_info": "Bytea" + "type_info": "Int4" }, { - "name": "created_at", + "name": "confirmed_eth_tx_history_id", "ordinal": 10, - "type_info": "Timestamp" + "type_info": "Int4" + }, + { + "name": "predicted_gas_cost", + "ordinal": 11, + "type_info": "Int8" } ], "nullable": [ @@ -4062,98 +4672,40 @@ false, false, false, + true, false, false, false, - false, + true, true, false ], "parameters": { "Left": [ - "Int4" + "Int8" ] } }, - "query": "SELECT * FROM protocol_versions\n WHERE id = $1\n " - }, - "4bab972cbbd8b53237a840ba9307079705bd4b5270428d2b41f05ee3d2aa42af": { - "describe": { - "columns": [ - { - "name": "l1_batch_number!", - "ordinal": 0, - "type_info": "Int8" - }, - { - "name": "circuit_type", - "ordinal": 1, - "type_info": "Text" - } - ], - "nullable": [ - null, - false - ], - "parameters": { - "Left": [] - } - }, - "query": "\n SELECT MIN(l1_batch_number) as \"l1_batch_number!\", circuit_type\n FROM prover_jobs\n WHERE aggregation_round = 0 AND (status = 'queued' OR status = 'in_progress'\n OR status = 'in_gpu_proof'\n OR status = 'failed')\n GROUP BY circuit_type\n " + "query": "\n SELECT\n *\n FROM\n eth_txs\n WHERE\n id > (\n SELECT\n COALESCE(MAX(eth_tx_id), 0)\n FROM\n eth_txs_history\n )\n ORDER BY\n id\n LIMIT\n $1\n " }, - "4c0d2aa6e08f3b4748b88cad5cf7b3a9eb9c051e8e8e747a3c38c1b37ce3a6b7": { + "5821f1446983260168cec366af26009503182c300877e74a8539f231050e6f85": { "describe": { "columns": [], "nullable": [], "parameters": { "Left": [ + "Text", "Int8" ] } }, - "query": "DELETE FROM l2_to_l1_logs WHERE miniblock_number > $1" - }, - "4c83881635e957872a435737392bfed829de58780887c9a0fa7921ea648296fb": { - "describe": { - "columns": [ - { - "name": "number", - "ordinal": 0, - "type_info": "Int8" - } - ], - "nullable": [ - false - ], - "parameters": { - "Left": [] - } - }, - "query": "SELECT number FROM l1_batches WHERE eth_prove_tx_id IS NOT NULL AND eth_execute_tx_id IS NULL ORDER BY number LIMIT 1" - }, - "4d2e106c809a48ace74952df2b883a5e747aaa1bc6bee28e986dccee7fa130b6": { - "describe": { - "columns": [ - { - "name": "nonce", - "ordinal": 0, - "type_info": "Int8" - } - ], - "nullable": [ - false - ], - "parameters": { - "Left": [] - } - }, - "query": "SELECT nonce FROM eth_txs ORDER BY id DESC LIMIT 1" + "query": "\n UPDATE witness_inputs_fri\n SET\n status = $1,\n updated_at = NOW()\n WHERE\n l1_batch_number = $2\n " }, - "4d36aff2bdeb0b659b8c4cd031f7c3fc204d92bb500a4efe8b6beb9255a232f6": { + "58aed39245c72d231b268ce83105bb2036d21f60d4c6934f9145730ac35c04de": { "describe": { "columns": [ { - "name": "timestamp", + "name": "l1_batch_number", "ordinal": 0, "type_info": "Int8" } @@ -4165,95 +4717,84 @@ "Left": [] } }, - "query": "SELECT timestamp FROM l1_batches WHERE eth_execute_tx_id IS NULL AND number > 0 ORDER BY number LIMIT 1" + "query": "\n SELECT\n l1_batch_number\n FROM\n proof_generation_details\n WHERE\n status = 'ready_to_be_proven'\n ORDER BY\n l1_batch_number ASC\n LIMIT\n 1\n " }, - "4d50dabc25d392e6b9d0dbe0e386ea7ef2c1178b1b0394a17442185b79f2d77d": { + "59cb0dd78fadc121e2b1ebbc8a063f089c91aead2bc9abb284697e65840f1e8f": { "describe": { - "columns": [ - { - "name": "id", - "ordinal": 0, - "type_info": "Int4" - } - ], - "nullable": [ - false - ], + "columns": [], + "nullable": [], "parameters": { "Left": [ - "Text" + "Bytea", + "Numeric", + "Timestamp" ] } }, - "query": "SELECT eth_txs.id FROM eth_txs_history JOIN eth_txs ON eth_txs.confirmed_eth_tx_history_id = eth_txs_history.id WHERE eth_txs_history.tx_hash = $1" + "query": "\n UPDATE tokens\n SET\n usd_price = $2,\n usd_price_updated_at = $3,\n updated_at = NOW()\n WHERE\n l1_address = $1\n " }, - "4e2b733fea9ca7cef542602fcd80acf1a9d2e0f1e22566f1076c4837e3ac7e61": { + "5c39f043c9b36693b0a845eb36549374a2d931e62615bc7e6ecd0af957b42a13": { "describe": { "columns": [ { - "name": "id", + "name": "number", "ordinal": 0, "type_info": "Int8" }, { - "name": "instance_host", + "name": "timestamp", "ordinal": 1, - "type_info": "Inet" + "type_info": "Int8" }, { - "name": "instance_port", + "name": "hash", "ordinal": 2, - "type_info": "Int4" + "type_info": "Bytea" }, { - "name": "instance_status", + "name": "l1_tx_count", "ordinal": 3, - "type_info": "Text" + "type_info": "Int4" }, { - "name": "created_at", + "name": "l2_tx_count", "ordinal": 4, - "type_info": "Timestamp" + "type_info": "Int4" }, { - "name": "updated_at", + "name": "base_fee_per_gas", "ordinal": 5, - "type_info": "Timestamp" + "type_info": "Numeric" }, { - "name": "processing_started_at", + "name": "l1_gas_price", "ordinal": 6, - "type_info": "Timestamp" + "type_info": "Int8" }, { - "name": "queue_free_slots", + "name": "l2_fair_gas_price", "ordinal": 7, - "type_info": "Int4" + "type_info": "Int8" }, { - "name": "queue_capacity", + "name": "bootloader_code_hash", "ordinal": 8, - "type_info": "Int4" + "type_info": "Bytea" }, { - "name": "specialized_prover_group_id", + "name": "default_aa_code_hash", "ordinal": 9, - "type_info": "Int2" + "type_info": "Bytea" }, { - "name": "region", + "name": "protocol_version", "ordinal": 10, - "type_info": "Text" + "type_info": "Int4" }, { - "name": "zone", + "name": "virtual_blocks", "ordinal": 11, - "type_info": "Text" - }, - { - "name": "num_gpu", - "ordinal": 12, - "type_info": "Int2" + "type_info": "Int8" } ], "nullable": [ @@ -4263,53 +4804,22 @@ false, false, false, + false, + false, true, true, true, - true, - false, - false, - true + false ], "parameters": { "Left": [ - "Interval", - "Int2", - "Text", - "Text" - ] - } - }, - "query": "\n UPDATE gpu_prover_queue\n SET instance_status = 'reserved',\n updated_at = now(),\n processing_started_at = now()\n WHERE id in (\n SELECT id\n FROM gpu_prover_queue\n WHERE specialized_prover_group_id=$2\n AND region=$3\n AND zone=$4\n AND (\n instance_status = 'available'\n OR (instance_status = 'reserved' AND processing_started_at < now() - $1::interval)\n )\n ORDER BY updated_at ASC\n LIMIT 1\n FOR UPDATE\n SKIP LOCKED\n )\n RETURNING gpu_prover_queue.*\n " - }, - "5089dfb745ff04a9b071b5785e68194a6f6a7a72754d23a65adc7d6838f7f640": { - "describe": { - "columns": [], - "nullable": [], - "parameters": { - "Left": [ - "Int4" - ] - } - }, - "query": "UPDATE eth_txs SET has_failed = TRUE WHERE id = $1" - }, - "50cdc4e59990eb75ab12f002b0f41d196196c17194ee68ef5b0f7edb9f0f7f69": { - "describe": { - "columns": [], - "nullable": [], - "parameters": { - "Left": [ - "Int8", - "Text", - "Jsonb", - "Text" + "Int8" ] } }, - "query": "UPDATE contract_verification_requests SET status = 'failed', updated_at = now(), error = $2, compilation_errors = $3, panic_message = $4 WHERE id = $1" + "query": "\n SELECT\n number,\n timestamp,\n hash,\n l1_tx_count,\n l2_tx_count,\n base_fee_per_gas,\n l1_gas_price,\n l2_fair_gas_price,\n bootloader_code_hash,\n default_aa_code_hash,\n protocol_version,\n virtual_blocks\n FROM\n miniblocks\n WHERE\n number = $1\n " }, - "51cb712685991ffd600dce59f5ed8b5a1bfce8feed46ebd02471c43802e6e65a": { + "5d493cbce749cc5b56d4069423597b16599abaf51df0f19effe1a536376cf6a6": { "describe": { "columns": [ { @@ -4333,119 +4843,93 @@ ] } }, - "query": "SELECT bootloader_code_hash, default_account_code_hash FROM protocol_versions\n WHERE id = $1\n " + "query": "\n SELECT\n bootloader_code_hash,\n default_account_code_hash\n FROM\n protocol_versions\n WHERE\n id = $1\n " }, - "51d02f2e314ebf78c27949cc10997bd2171755400cc3a13c63994c85e15cb3df": { + "5e781f84ec41edd0941fa84de837effac442434c6e734d977e6682a7484abe7f": { "describe": { "columns": [ { - "name": "count!", + "name": "l1_batch_number", "ordinal": 0, "type_info": "Int8" }, { - "name": "circuit_id!", + "name": "status", "ordinal": 1, - "type_info": "Int2" + "type_info": "Text" }, { - "name": "aggregation_round!", + "name": "attempts", "ordinal": 2, "type_info": "Int2" - }, - { - "name": "status!", - "ordinal": 3, - "type_info": "Text" } ], "nullable": [ - null, false, false, false ], "parameters": { - "Left": [] + "Left": [ + "Interval", + "Int2" + ] } }, - "query": "\n SELECT COUNT(*) as \"count!\", circuit_id as \"circuit_id!\", aggregation_round as \"aggregation_round!\", status as \"status!\"\n FROM prover_jobs_fri\n WHERE status <> 'skipped' and status <> 'successful'\n GROUP BY circuit_id, aggregation_round, status\n " + "query": "\n UPDATE proof_compression_jobs_fri\n SET\n status = 'queued',\n updated_at = NOW(),\n processing_started_at = NOW()\n WHERE\n (\n status = 'in_progress'\n AND processing_started_at <= NOW() - $1::INTERVAL\n AND attempts < $2\n )\n OR (\n status = 'failed'\n AND attempts < $2\n )\n RETURNING\n l1_batch_number,\n status,\n attempts\n " }, - "52eeb8c529efb796fdefb30a381fcf6c931512f30e55e24c155f6c649e662909": { + "5f6885b5457aaa78e10917ae5b8cd0bc0e8923a6bae64f22f09242766835ee0c": { "describe": { "columns": [ { - "name": "l1_batch_number", + "name": "id", "ordinal": 0, "type_info": "Int8" - } - ], - "nullable": [ - false - ], - "parameters": { - "Left": [] - } - }, - "query": "\n UPDATE scheduler_dependency_tracker_fri\n SET status='queuing'\n WHERE l1_batch_number IN\n (SELECT l1_batch_number FROM scheduler_dependency_tracker_fri\n WHERE status != 'queued'\n AND circuit_1_final_prover_job_id IS NOT NULL\n AND circuit_2_final_prover_job_id IS NOT NULL\n AND circuit_3_final_prover_job_id IS NOT NULL\n AND circuit_4_final_prover_job_id IS NOT NULL\n AND circuit_5_final_prover_job_id IS NOT NULL\n AND circuit_6_final_prover_job_id IS NOT NULL\n AND circuit_7_final_prover_job_id IS NOT NULL\n AND circuit_8_final_prover_job_id IS NOT NULL\n AND circuit_9_final_prover_job_id IS NOT NULL\n AND circuit_10_final_prover_job_id IS NOT NULL\n AND circuit_11_final_prover_job_id IS NOT NULL\n AND circuit_12_final_prover_job_id IS NOT NULL\n AND circuit_13_final_prover_job_id IS NOT NULL\n )\n RETURNING l1_batch_number;\n " - }, - "5490012051be6faaaa11fad0f196eb53160a9c5c045fe9d66afcef7f33403fe2": { - "describe": { - "columns": [ - { - "name": "id", - "ordinal": 0, - "type_info": "Int4" }, { - "name": "timestamp", + "name": "contract_address", "ordinal": 1, - "type_info": "Int8" + "type_info": "Bytea" }, { - "name": "recursion_scheduler_level_vk_hash", + "name": "source_code", "ordinal": 2, - "type_info": "Bytea" + "type_info": "Text" }, { - "name": "recursion_node_level_vk_hash", + "name": "contract_name", "ordinal": 3, - "type_info": "Bytea" + "type_info": "Text" }, { - "name": "recursion_leaf_level_vk_hash", + "name": "zk_compiler_version", "ordinal": 4, - "type_info": "Bytea" + "type_info": "Text" }, { - "name": "recursion_circuits_set_vks_hash", + "name": "compiler_version", "ordinal": 5, - "type_info": "Bytea" + "type_info": "Text" }, { - "name": "bootloader_code_hash", + "name": "optimization_used", "ordinal": 6, - "type_info": "Bytea" + "type_info": "Bool" }, { - "name": "default_account_code_hash", + "name": "optimizer_mode", "ordinal": 7, - "type_info": "Bytea" + "type_info": "Text" }, { - "name": "verifier_address", + "name": "constructor_arguments", "ordinal": 8, "type_info": "Bytea" }, { - "name": "upgrade_tx_hash", + "name": "is_system", "ordinal": 9, - "type_info": "Bytea" - }, - { - "name": "created_at", - "ordinal": 10, - "type_info": "Timestamp" + "type_info": "Bool" } ], "nullable": [ @@ -4456,526 +4940,268 @@ false, false, false, - false, - false, true, + false, false ], "parameters": { - "Left": [ - "Int4" - ] - } - }, - "query": "SELECT * FROM protocol_versions\n WHERE id < $1\n ORDER BY id DESC\n LIMIT 1\n " - }, - "5503575d9377785894de6cf6139a8d4768c6a803a1a90889e5a1b8254c315231": { - "describe": { - "columns": [ - { - "name": "id", - "ordinal": 0, - "type_info": "Int4" - } - ], - "nullable": [ - false - ], - "parameters": { - "Left": [ - "Text" - ] + "Left": [] } }, - "query": "INSERT INTO eth_txs (raw_tx, nonce, tx_type, contract_address, predicted_gas_cost, created_at, updated_at) VALUES ('\\x00', 0, $1, '', 0, now(), now()) RETURNING id" + "query": "\n SELECT\n id,\n contract_address,\n source_code,\n contract_name,\n zk_compiler_version,\n compiler_version,\n optimization_used,\n optimizer_mode,\n constructor_arguments,\n is_system\n FROM\n contract_verification_requests\n WHERE\n status = 'successful'\n ORDER BY\n id\n " }, - "5563da0d52ca7310ae7bc957caa5d8b3dcbd9386bb2a0be68dcd21ebb044cdbd": { + "5f8fc05ae782846898295d210dd3d55ff2b1510868dfe80d14fffa3f5ff07b83": { "describe": { - "columns": [ - { - "name": "bytecode_hash", - "ordinal": 0, - "type_info": "Bytea" - }, - { - "name": "bytecode", - "ordinal": 1, - "type_info": "Bytea" - } - ], - "nullable": [ - false, - false - ], + "columns": [], + "nullable": [], "parameters": { "Left": [ + "Int8", "Int8" ] } }, - "query": "SELECT bytecode_hash, bytecode FROM factory_deps INNER JOIN miniblocks ON miniblocks.number = factory_deps.miniblock_number WHERE miniblocks.l1_batch_number = $1" + "query": "\n UPDATE l1_batches\n SET\n predicted_commit_gas_cost = $2,\n updated_at = NOW()\n WHERE\n number = $1\n " }, - "55debba852ef32f3b5ba6ffcb745f7b59d6888a21cb8792f8f9027e3b164a245": { + "608ee7ab02c003b0035db84a46b16da979d97a8f8cd10595cc55bdfa156e4c33": { "describe": { "columns": [ { - "name": "region", + "name": "number", "ordinal": 0, - "type_info": "Text" + "type_info": "Int8" }, { - "name": "zone", + "name": "timestamp", "ordinal": 1, - "type_info": "Text" + "type_info": "Int8" }, { - "name": "total_gpus", + "name": "is_finished", "ordinal": 2, - "type_info": "Int8" - } - ], - "nullable": [ - false, - false, - null - ], - "parameters": { - "Left": [] - } - }, - "query": "\n SELECT region, zone, SUM(num_gpu) AS total_gpus\n FROM gpu_prover_queue\n GROUP BY region, zone\n " - }, - "565a302151a5a55aa717048e3e21b5d7379ab47c2b80229024f0cb2699136b11": { - "describe": { - "columns": [], - "nullable": [], - "parameters": { - "Left": [ - "Int4" - ] - } - }, - "query": "UPDATE miniblocks SET protocol_version = $1 WHERE l1_batch_number IS NULL" - }, - "57742ed088179b89b50920a2ab1a103b745598ee0ba05d1793fc54e63b477319": { - "describe": { - "columns": [], - "nullable": [], - "parameters": { - "Left": [ - "Int4", - "Int8", - "Int8" - ] - } - }, - "query": "UPDATE l1_batches SET eth_commit_tx_id = $1, updated_at = now() WHERE number BETWEEN $2 AND $3" - }, - "58489a4e8730646ce20efee849742444740c72f59fad2495647742417ed0ab5a": { - "describe": { - "columns": [ + "type_info": "Bool" + }, { - "name": "base_fee_per_gas", - "ordinal": 0, - "type_info": "Numeric" - } - ], - "nullable": [ - false - ], - "parameters": { - "Left": [ - "Int8", - "Int8" - ] - } - }, - "query": "SELECT base_fee_per_gas FROM miniblocks WHERE number <= $1 ORDER BY number DESC LIMIT $2" - }, - "5922fdf40632a6ffecfe824a3ba29bcf7b379aff5253db2739cc7be6145524e8": { - "describe": { - "columns": [ + "name": "l1_tx_count", + "ordinal": 3, + "type_info": "Int4" + }, { - "name": "bootloader_code_hash", - "ordinal": 0, + "name": "l2_tx_count", + "ordinal": 4, + "type_info": "Int4" + }, + { + "name": "fee_account_address", + "ordinal": 5, "type_info": "Bytea" }, { - "name": "default_account_code_hash", - "ordinal": 1, + "name": "bloom", + "ordinal": 6, "type_info": "Bytea" }, { - "name": "id", - "ordinal": 2, - "type_info": "Int4" - } - ], - "nullable": [ - false, - false, - false - ], - "parameters": { - "Left": [ - "Int8" - ] - } - }, - "query": "SELECT bootloader_code_hash, default_account_code_hash, id FROM protocol_versions\n WHERE timestamp <= $1\n ORDER BY id DESC\n LIMIT 1\n " - }, - "596ede80b21f08fc4dcf3e1fcc40810fe4c8f5123bcc19faebd15bfac86029d7": { - "describe": { - "columns": [], - "nullable": [], - "parameters": { - "Left": [ - "Bytea", - "Jsonb" - ] - } - }, - "query": "INSERT INTO contracts_verification_info (address, verification_info) VALUES ($1, $2) ON CONFLICT (address) DO UPDATE SET verification_info = $2" - }, - "59a318fc330369353f2570bfef09909d11e22a1c76ba5277839a6866d8e796b6": { - "describe": { - "columns": [ + "name": "priority_ops_onchain_data", + "ordinal": 7, + "type_info": "ByteaArray" + }, { - "name": "hashed_key", - "ordinal": 0, + "name": "hash", + "ordinal": 8, "type_info": "Bytea" }, { - "name": "index", - "ordinal": 1, - "type_info": "Int8" - } - ], - "nullable": [ - false, - false - ], - "parameters": { - "Left": [ - "Int8" - ] - } - }, - "query": "SELECT hashed_key, index FROM initial_writes WHERE l1_batch_number = $1 ORDER BY index" - }, - "5a27a65fa105897b60a99c1e0015e4b8c93c45e0c448e77b03565db5c36695ed": { - "describe": { - "columns": [ + "name": "parent_hash", + "ordinal": 9, + "type_info": "Bytea" + }, { - "name": "max", - "ordinal": 0, - "type_info": "Int8" - } - ], - "nullable": [ - null - ], - "parameters": { - "Left": [] - } - }, - "query": "SELECT MAX(l1_batch_number) FROM witness_inputs WHERE merkel_tree_paths_blob_url IS NOT NULL" - }, - "5a2f35f3b0135ab88451ea141e97b1160ea1b4cf495b6700b5d178a43499e0d8": { - "describe": { - "columns": [ + "name": "commitment", + "ordinal": 10, + "type_info": "Bytea" + }, { - "name": "fee_account_address", - "ordinal": 0, + "name": "compressed_write_logs", + "ordinal": 11, "type_info": "Bytea" - } - ], - "nullable": [ - false - ], - "parameters": { - "Left": [ - "Int8" - ] - } - }, - "query": "SELECT fee_account_address FROM l1_batches WHERE number = $1" - }, - "5a5844af61cc685a414fcd3cad70900bdce8f48e905c105f8dd50dc52e0c6f14": { - "describe": { - "columns": [ + }, { - "name": "l1_batch_number", - "ordinal": 0, - "type_info": "Int8" + "name": "compressed_contracts", + "ordinal": 12, + "type_info": "Bytea" }, { - "name": "attempts", - "ordinal": 1, + "name": "eth_prove_tx_id", + "ordinal": 13, "type_info": "Int4" - } - ], - "nullable": [ - false, - false - ], - "parameters": { - "Left": [ - "Text", - "Int8" - ] - } - }, - "query": "\n UPDATE prover_jobs\n SET status = 'failed', error = $1, updated_at = now()\n WHERE id = $2\n RETURNING l1_batch_number, attempts\n " - }, - "5ac872e2c5a00b376cc053324b3776ef6a0bb7f6850e5a24a133dfee052c49e1": { - "describe": { - "columns": [ + }, { - "name": "value", - "ordinal": 0, + "name": "eth_commit_tx_id", + "ordinal": 14, + "type_info": "Int4" + }, + { + "name": "eth_execute_tx_id", + "ordinal": 15, + "type_info": "Int4" + }, + { + "name": "merkle_root_hash", + "ordinal": 16, "type_info": "Bytea" - } - ], - "nullable": [ - false - ], - "parameters": { - "Left": [ - "Bytea" - ] - } - }, - "query": "SELECT value FROM storage WHERE hashed_key = $1" - }, - "5b2935b5b7e8c2907f5e221a6b1e6f4b8737b9fc618c5d021a3e1d58a3aed116": { - "describe": { - "columns": [], - "nullable": [], - "parameters": { - "Left": [ - "Text", - "Int8" - ] - } - }, - "query": "\n UPDATE prover_jobs_fri\n SET status = 'failed', error = $1, updated_at = now()\n WHERE id = $2\n " - }, - "5bc8a41ae0f255b966df2102f1bd9059d55833e0afaf6e62c7ddcc9c06de8deb": { - "describe": { - "columns": [ + }, { - "name": "l1_batch_number!", - "ordinal": 0, - "type_info": "Int8" + "name": "l2_to_l1_logs", + "ordinal": 17, + "type_info": "ByteaArray" }, { - "name": "aggregation_round", - "ordinal": 1, - "type_info": "Int4" - } - ], - "nullable": [ - null, - false - ], - "parameters": { - "Left": [] - } - }, - "query": "SELECT MAX(l1_batch_number) as \"l1_batch_number!\", aggregation_round FROM prover_jobs \n WHERE status='successful'\n GROUP BY aggregation_round \n " - }, - "5bc8cdc7ed710bb2f9b0035654fd7e9dcc01731ca581c6aa75d55184817bc100": { - "describe": { - "columns": [ + "name": "l2_to_l1_messages", + "ordinal": 18, + "type_info": "ByteaArray" + }, { - "name": "number", - "ordinal": 0, - "type_info": "Int8" - } - ], - "nullable": [ - null - ], - "parameters": { - "Left": [] - } - }, - "query": "SELECT MAX(number) as \"number\" FROM l1_batches WHERE hash IS NOT NULL" - }, - "5cc93efebc14dc0b78ed32bf7f167a44bd083f32ab308662c57ce1f726c0f1f9": { - "describe": { - "columns": [ + "name": "used_contract_hashes", + "ordinal": 19, + "type_info": "Jsonb" + }, { - "name": "attempts", - "ordinal": 0, - "type_info": "Int2" - } - ], - "nullable": [ - false - ], - "parameters": { - "Left": [ - "Int8" - ] - } - }, - "query": "SELECT attempts FROM node_aggregation_witness_jobs_fri WHERE id = $1" - }, - "5df806b33f84893d4ddfacf3b289b0e173e85ad9204cbb7ad314e68a94cdc41e": { - "describe": { - "columns": [], - "nullable": [], - "parameters": { - "Left": [ - "Text", - "Int8", - "Int2", - "Int4", - "Int4" - ] - } - }, - "query": "\n UPDATE node_aggregation_witness_jobs_fri\n SET aggregations_url = $1, number_of_dependent_jobs = $5, updated_at = now()\n WHERE l1_batch_number = $2\n AND circuit_id = $3\n AND depth = $4\n " - }, - "5e09f2359dd69380c1f183f613d82696029a56896e2b985738a2fa25d6cb8a71": { - "describe": { - "columns": [ + "name": "compressed_initial_writes", + "ordinal": 20, + "type_info": "Bytea" + }, { - "name": "op_id", - "ordinal": 0, - "type_info": "Int8" - } - ], - "nullable": [ - null - ], - "parameters": { - "Left": [] - } - }, - "query": "SELECT MAX(priority_op_id) as \"op_id\" from transactions where is_priority = true" - }, - "5f037f6ae8489d5224772d4f9e3e6cfc2075560957fa491d97a95c0e79ff4830": { - "describe": { - "columns": [ + "name": "compressed_repeated_writes", + "ordinal": 21, + "type_info": "Bytea" + }, { - "name": "block_batch?", - "ordinal": 0, - "type_info": "Int8" + "name": "l2_l1_compressed_messages", + "ordinal": 22, + "type_info": "Bytea" }, { - "name": "max_batch?", - "ordinal": 1, + "name": "l2_l1_merkle_root", + "ordinal": 23, + "type_info": "Bytea" + }, + { + "name": "l1_gas_price", + "ordinal": 24, "type_info": "Int8" - } - ], - "nullable": [ - null, - null - ], - "parameters": { - "Left": [ - "Int8" - ] - } - }, - "query": "SELECT (SELECT l1_batch_number FROM miniblocks WHERE number = $1) as \"block_batch?\", (SELECT MAX(number) + 1 FROM l1_batches) as \"max_batch?\"" - }, - "5f29e71af038c974e2d83b908c5a2559ab8afbb169bc0ae9f881a6628dc087fd": { - "describe": { - "columns": [ + }, { - "name": "l1_batch_number", - "ordinal": 0, + "name": "l2_fair_gas_price", + "ordinal": 25, "type_info": "Int8" - } - ], - "nullable": [ - false - ], - "parameters": { - "Left": [] - } - }, - "query": "SELECT l1_batch_number FROM proof_generation_details WHERE status NOT IN ('generated', 'skipped') ORDER BY l1_batch_number ASC LIMIT 1" - }, - "5f40849646bb7436e29cda8fb87fece2a4dcb580644f45ecb82388dece04f222": { - "describe": { - "columns": [ + }, { - "name": "id", - "ordinal": 0, + "name": "rollup_last_leaf_index", + "ordinal": 26, "type_info": "Int8" }, { - "name": "status", - "ordinal": 1, - "type_info": "Text" + "name": "zkporter_is_available", + "ordinal": 27, + "type_info": "Bool" }, { - "name": "attempts", - "ordinal": 2, - "type_info": "Int2" - } - ], - "nullable": [ - false, - false, - false - ], - "parameters": { - "Left": [ - "Interval", - "Int2" - ] - } - }, - "query": "\n UPDATE prover_jobs_fri\n SET status = 'queued', updated_at = now(), processing_started_at = now()\n WHERE id in (\n SELECT id\n FROM prover_jobs_fri\n WHERE (status = 'in_progress' AND processing_started_at <= now() - $1::interval AND attempts < $2)\n OR (status = 'in_gpu_proof' AND processing_started_at <= now() - $1::interval AND attempts < $2)\n OR (status = 'failed' AND attempts < $2)\n FOR UPDATE SKIP LOCKED\n )\n RETURNING id, status, attempts\n " - }, - "5f4b1091b74424ffd20c0aede98287418afa2bb37dbc941200c1d6190c96bec5": { - "describe": { - "columns": [ + "name": "bootloader_code_hash", + "ordinal": 28, + "type_info": "Bytea" + }, { - "name": "timestamp", - "ordinal": 0, - "type_info": "Int8" - } - ], - "nullable": [ - false - ], - "parameters": { - "Left": [] - } - }, - "query": "SELECT timestamp FROM l1_batches WHERE eth_commit_tx_id IS NULL AND number > 0 ORDER BY number LIMIT 1" - }, - "601487490349c5eee83d6de19137b1a1079235e46c4a3f07e1eaa9db7760f586": { - "describe": { - "columns": [], - "nullable": [], - "parameters": { - "Left": [ - "Int8", - "Jsonb" - ] - } - }, - "query": "INSERT INTO events_queue (l1_batch_number, serialized_events_queue) VALUES ($1, $2)" - }, - "61cc5a1564918a34b4235290c421f04c40ef935f72f2c72744a5b741439a966a": { - "describe": { - "columns": [ + "name": "default_aa_code_hash", + "ordinal": 29, + "type_info": "Bytea" + }, { - "name": "bytecode", - "ordinal": 0, + "name": "base_fee_per_gas", + "ordinal": 30, + "type_info": "Numeric" + }, + { + "name": "aux_data_hash", + "ordinal": 31, + "type_info": "Bytea" + }, + { + "name": "pass_through_data_hash", + "ordinal": 32, + "type_info": "Bytea" + }, + { + "name": "meta_parameters_hash", + "ordinal": 33, + "type_info": "Bytea" + }, + { + "name": "protocol_version", + "ordinal": 34, + "type_info": "Int4" + }, + { + "name": "system_logs", + "ordinal": 35, + "type_info": "ByteaArray" + }, + { + "name": "compressed_state_diffs", + "ordinal": 36, + "type_info": "Bytea" + }, + { + "name": "events_queue_commitment", + "ordinal": 37, + "type_info": "Bytea" + }, + { + "name": "bootloader_initial_content_commitment", + "ordinal": 38, "type_info": "Bytea" } ], "nullable": [ - false + false, + false, + false, + false, + false, + false, + false, + false, + true, + true, + true, + true, + true, + true, + true, + true, + true, + false, + false, + false, + true, + true, + true, + true, + false, + false, + true, + true, + true, + true, + false, + true, + true, + true, + true, + false, + true, + true, + true ], "parameters": { "Left": [ @@ -4983,29 +5209,9 @@ ] } }, - "query": "SELECT bytecode FROM factory_deps WHERE miniblock_number <= $1" - }, - "6317155050a5dae24ea202cfd54d1e58cc7aeb0bfd4d95aa351f85cff04d3bff": { - "describe": { - "columns": [ - { - "name": "version", - "ordinal": 0, - "type_info": "Text" - } - ], - "nullable": [ - false - ], - "parameters": { - "Left": [ - "Text" - ] - } - }, - "query": "SELECT version FROM compiler_versions WHERE compiler = $1 ORDER by version" + "query": "\n SELECT\n number,\n timestamp,\n is_finished,\n l1_tx_count,\n l2_tx_count,\n fee_account_address,\n bloom,\n priority_ops_onchain_data,\n hash,\n parent_hash,\n commitment,\n compressed_write_logs,\n compressed_contracts,\n eth_prove_tx_id,\n eth_commit_tx_id,\n eth_execute_tx_id,\n merkle_root_hash,\n l2_to_l1_logs,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_compressed_messages,\n l2_l1_merkle_root,\n l1_gas_price,\n l2_fair_gas_price,\n rollup_last_leaf_index,\n zkporter_is_available,\n bootloader_code_hash,\n default_aa_code_hash,\n base_fee_per_gas,\n aux_data_hash,\n pass_through_data_hash,\n meta_parameters_hash,\n protocol_version,\n system_logs,\n compressed_state_diffs,\n events_queue_commitment,\n bootloader_initial_content_commitment\n FROM\n l1_batches\n LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number\n WHERE\n number = $1\n " }, - "65a31949cd7f8890e9448d26a0efee852ddf59bfbbc858b51fba10048d47d27b": { + "6132af955efc6a7b0dfe8bae021d79feb4576dbd37c2d93c2aefaaf79efce87c": { "describe": { "columns": [ { @@ -5179,9 +5385,9 @@ "type_info": "Bytea" }, { - "name": "system_logs", + "name": "protocol_version", "ordinal": 34, - "type_info": "ByteaArray" + "type_info": "Int4" }, { "name": "compressed_state_diffs", @@ -5189,9 +5395,9 @@ "type_info": "Bytea" }, { - "name": "protocol_version", + "name": "system_logs", "ordinal": 36, - "type_info": "Int4" + "type_info": "ByteaArray" }, { "name": "events_queue_commitment", @@ -5239,167 +5445,209 @@ true, true, true, - false, true, true, + false, true, true ], "parameters": { "Left": [ - "Int8", - "Int8" - ] - } - }, - "query": "SELECT number, timestamp, is_finished, l1_tx_count, l2_tx_count, fee_account_address, bloom, priority_ops_onchain_data, hash, parent_hash, commitment, compressed_write_logs, compressed_contracts, eth_prove_tx_id, eth_commit_tx_id, eth_execute_tx_id, merkle_root_hash, l2_to_l1_logs, l2_to_l1_messages, used_contract_hashes, compressed_initial_writes, compressed_repeated_writes, l2_l1_compressed_messages, l2_l1_merkle_root, l1_gas_price, l2_fair_gas_price, rollup_last_leaf_index, zkporter_is_available, bootloader_code_hash, default_aa_code_hash, base_fee_per_gas, aux_data_hash, pass_through_data_hash, meta_parameters_hash, system_logs, compressed_state_diffs, protocol_version, events_queue_commitment, bootloader_initial_content_commitment FROM (SELECT l1_batches.*, row_number() OVER (ORDER BY number ASC) AS row_number FROM l1_batches WHERE eth_commit_tx_id IS NOT NULL AND l1_batches.skip_proof = TRUE AND l1_batches.number > $1 ORDER BY number LIMIT $2) inn LEFT JOIN commitments ON commitments.l1_batch_number = inn.number WHERE number - row_number = $1" - }, - "65e2cdb70ccef97d886fb53d1bb298875e13b0ffe7b744ac5dd86433f0929eb0": { - "describe": { - "columns": [], - "nullable": [], - "parameters": { - "Left": [ - { - "Custom": { - "kind": { - "Enum": [ - "Queued", - "ManuallySkipped", - "InProgress", - "Successful", - "Failed" - ] - }, - "name": "basic_witness_input_producer_job_status" - } - }, - "Int8", - "Time", - "Text" - ] - } - }, - "query": "UPDATE basic_witness_input_producer_jobs SET status = $1, updated_at = now(), time_taken = $3, input_blob_url = $4 WHERE l1_batch_number = $2" - }, - "665112c83ed7f126f94d1c47408de3495ee6431970e334d94ae75f853496eb48": { - "describe": { - "columns": [], - "nullable": [], - "parameters": { - "Left": [ - "Text", + "Bytea", + "Bytea", + "Int4", "Int8" ] } }, - "query": "\n UPDATE node_aggregation_witness_jobs_fri\n SET status ='failed', error= $1, updated_at = now()\n WHERE id = $2\n " + "query": "\n SELECT\n number,\n l1_batches.timestamp,\n is_finished,\n l1_tx_count,\n l2_tx_count,\n fee_account_address,\n bloom,\n priority_ops_onchain_data,\n hash,\n parent_hash,\n commitment,\n compressed_write_logs,\n compressed_contracts,\n eth_prove_tx_id,\n eth_commit_tx_id,\n eth_execute_tx_id,\n merkle_root_hash,\n l2_to_l1_logs,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_compressed_messages,\n l2_l1_merkle_root,\n l1_gas_price,\n l2_fair_gas_price,\n rollup_last_leaf_index,\n zkporter_is_available,\n l1_batches.bootloader_code_hash,\n l1_batches.default_aa_code_hash,\n base_fee_per_gas,\n aux_data_hash,\n pass_through_data_hash,\n meta_parameters_hash,\n protocol_version,\n compressed_state_diffs,\n system_logs,\n events_queue_commitment,\n bootloader_initial_content_commitment\n FROM\n l1_batches\n LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number\n JOIN protocol_versions ON protocol_versions.id = l1_batches.protocol_version\n WHERE\n eth_commit_tx_id IS NULL\n AND number != 0\n AND protocol_versions.bootloader_code_hash = $1\n AND protocol_versions.default_account_code_hash = $2\n AND commitment IS NOT NULL\n AND (\n protocol_versions.id = $3\n OR protocol_versions.upgrade_tx_hash IS NULL\n )\n ORDER BY\n number\n LIMIT\n $4\n " }, - "67a47f1e7d5f8dafcef94bea3f268b4baec1888c6ef11c92ab66480ecdcb9aef": { + "61b2b858d4636809c21838635aa52aeb5f06c26f68d131dd242f6ed68816c513": { "describe": { - "columns": [], - "nullable": [], + "columns": [ + { + "name": "l1_batch_number", + "ordinal": 0, + "type_info": "Int8" + } + ], + "nullable": [ + false + ], "parameters": { "Left": [ - "Time", - "Bytea", - "Text", - "Int8" + "Int2" ] } }, - "query": "\n UPDATE prover_jobs\n SET status = 'successful', updated_at = now(), time_taken = $1, result = $2, proccesed_by = $3\n WHERE id = $4\n " + "query": "\n SELECT\n l1_batch_number\n FROM\n prover_jobs_fri\n WHERE\n status <> 'skipped'\n AND status <> 'successful'\n AND aggregation_round = $1\n ORDER BY\n l1_batch_number ASC\n LIMIT\n 1\n " }, - "67ecdc69e39e689f1f23f867d31e6b8c47e9c041e18cbd84a2ad6482a9be4e74": { + "61bc330d6d1b5fddec78342c1b0f00e82b0b3ad9ae36bf4fe44d7e85b74c6f49": { "describe": { "columns": [ { - "name": "l2_to_l1_logs", + "name": "op_id", "ordinal": 0, - "type_info": "ByteaArray" + "type_info": "Int8" } ], "nullable": [ - false + null ], "parameters": { - "Left": [ - "Int8" - ] + "Left": [] } }, - "query": "SELECT l2_to_l1_logs FROM l1_batches WHERE number = $1" + "query": "\n SELECT\n MAX(priority_op_id) AS \"op_id\"\n FROM\n transactions\n WHERE\n is_priority = TRUE\n AND miniblock_number IS NOT NULL\n " }, - "6939e766e122458b2ac618d19b2759c4a7298ef72b81e8c3957e0a5cf35c9552": { + "6692ff6c0fbb2fc94f5cd2837a43ce80f9b2b27758651ccfc09df61a4ae8a363": { "describe": { "columns": [ { - "name": "l1_batch_number", + "name": "id", "ordinal": 0, - "type_info": "Int8" + "type_info": "Int4" }, { - "name": "status", + "name": "nonce", "ordinal": 1, - "type_info": "Text" + "type_info": "Int8" }, { - "name": "attempts", + "name": "raw_tx", "ordinal": 2, - "type_info": "Int2" + "type_info": "Bytea" + }, + { + "name": "contract_address", + "ordinal": 3, + "type_info": "Text" + }, + { + "name": "tx_type", + "ordinal": 4, + "type_info": "Text" + }, + { + "name": "gas_used", + "ordinal": 5, + "type_info": "Int8" + }, + { + "name": "created_at", + "ordinal": 6, + "type_info": "Timestamp" + }, + { + "name": "updated_at", + "ordinal": 7, + "type_info": "Timestamp" + }, + { + "name": "has_failed", + "ordinal": 8, + "type_info": "Bool" + }, + { + "name": "sent_at_block", + "ordinal": 9, + "type_info": "Int4" + }, + { + "name": "confirmed_eth_tx_history_id", + "ordinal": 10, + "type_info": "Int4" + }, + { + "name": "predicted_gas_cost", + "ordinal": 11, + "type_info": "Int8" } ], "nullable": [ false, false, + false, + false, + false, + true, + false, + false, + false, + true, + true, false ], "parameters": { "Left": [ - "Interval", - "Int2" + "Int4" ] } }, - "query": "\n UPDATE witness_inputs_fri\n SET status = 'queued', updated_at = now(), processing_started_at = now()\n WHERE (status = 'in_progress' AND processing_started_at <= now() - $1::interval AND attempts < $2)\n OR (status = 'in_gpu_proof' AND processing_started_at <= now() - $1::interval AND attempts < $2)\n OR (status = 'failed' AND attempts < $2)\n RETURNING l1_batch_number, status, attempts\n " + "query": "\n SELECT\n *\n FROM\n eth_txs\n WHERE\n id = $1\n " }, - "697835cdd5be1b99a0f332c4c8f3245e317b0282b46e55f15e728a7642382b25": { + "66e012ce974c38d9fe84cfc7eb28927f9e976319a305e0928ff366d535a97104": { "describe": { "columns": [ { "name": "id", "ordinal": 0, - "type_info": "Int8" + "type_info": "Int4" }, { - "name": "l1_batch_number", + "name": "nonce", "ordinal": 1, "type_info": "Int8" }, { - "name": "circuit_id", + "name": "raw_tx", "ordinal": 2, - "type_info": "Int2" + "type_info": "Bytea" }, { - "name": "aggregation_round", + "name": "contract_address", "ordinal": 3, - "type_info": "Int2" + "type_info": "Text" }, { - "name": "sequence_number", + "name": "tx_type", "ordinal": 4, - "type_info": "Int4" + "type_info": "Text" }, { - "name": "depth", + "name": "gas_used", "ordinal": 5, - "type_info": "Int4" + "type_info": "Int8" }, { - "name": "is_node_final_proof", + "name": "created_at", "ordinal": 6, + "type_info": "Timestamp" + }, + { + "name": "updated_at", + "ordinal": 7, + "type_info": "Timestamp" + }, + { + "name": "has_failed", + "ordinal": 8, "type_info": "Bool" + }, + { + "name": "sent_at_block", + "ordinal": 9, + "type_info": "Int4" + }, + { + "name": "confirmed_eth_tx_history_id", + "ordinal": 10, + "type_info": "Int4" + }, + { + "name": "predicted_gas_cost", + "ordinal": 11, + "type_info": "Int8" } ], "nullable": [ @@ -5408,51 +5656,58 @@ false, false, false, + true, + false, + false, false, + true, + true, false ], "parameters": { "Left": [ - "Time", + "Bytea", + "Int8", + "Text", + "Text", + "Int8" + ] + } + }, + "query": "\n INSERT INTO\n eth_txs (\n raw_tx,\n nonce,\n tx_type,\n contract_address,\n predicted_gas_cost,\n created_at,\n updated_at\n )\n VALUES\n ($1, $2, $3, $4, $5, NOW(), NOW())\n RETURNING\n *\n " + }, + "684775aaed3d7f3f5580363e5180a04e7a1af1057995805cb6fd35d0b810e734": { + "describe": { + "columns": [], + "nullable": [], + "parameters": { + "Left": [ + "Text", + "Text", + "Int4", + "Int4", "Text", - "Int8" + "Text" ] } }, - "query": "\n UPDATE prover_jobs_fri\n SET status = 'successful', updated_at = now(), time_taken = $1, proof_blob_url=$2\n WHERE id = $3\n RETURNING prover_jobs_fri.id, prover_jobs_fri.l1_batch_number, prover_jobs_fri.circuit_id,\n prover_jobs_fri.aggregation_round, prover_jobs_fri.sequence_number, prover_jobs_fri.depth,\n prover_jobs_fri.is_node_final_proof\n " + "query": "\n UPDATE gpu_prover_queue\n SET\n instance_status = $1,\n updated_at = NOW(),\n queue_free_slots = $4\n WHERE\n instance_host = $2::TEXT::inet\n AND instance_port = $3\n AND region = $5\n AND zone = $6\n " }, - "6a282084b02cddd8646e984a729b689bdb758e07096fc8cf60f68c6ec5bd6a9c": { + "68936a53e5b80576f3f341523e6843eb48b5e26ee92cd8476f50251e8c32610d": { "describe": { "columns": [ { - "name": "max?", + "name": "count!", "ordinal": 0, - "type_info": "Int4" + "type_info": "Int8" } ], "nullable": [ null ], - "parameters": { - "Left": [] - } - }, - "query": "SELECT MAX(id) as \"max?\" FROM protocol_versions" - }, - "6a3af113a71bffa445d4a729e24fbc2be90bfffbdd072c74f9ca58669b7e5f80": { - "describe": { - "columns": [ - { - "name": "id", - "ordinal": 0, - "type_info": "Int4" - } - ], - "nullable": [ - false - ], "parameters": { "Left": [ + "Int8", "Bytea", "Bytea", "Bytea", @@ -5460,81 +5715,105 @@ ] } }, - "query": "SELECT id FROM prover_fri_protocol_versions WHERE recursion_circuits_set_vks_hash = $1 AND recursion_leaf_level_vk_hash = $2 AND recursion_node_level_vk_hash = $3 AND recursion_scheduler_level_vk_hash = $4 " + "query": "\n SELECT\n COUNT(*) AS \"count!\"\n FROM\n l1_batches\n WHERE\n number = $1\n AND hash = $2\n AND merkle_root_hash = $3\n AND parent_hash = $4\n AND l2_l1_merkle_root = $5\n " }, - "6ad9309a48f387da7d437ba6ed94aa7b6a42813e5ee566104b904f0bee0dfde7": { + "68a937c42e280690a7a63eeec6883d30eeb6e614ca75edf582b44378c0a698ed": { "describe": { "columns": [ { - "name": "number", + "name": "id", "ordinal": 0, "type_info": "Int8" }, { - "name": "l1_batch_number!", + "name": "l1_batch_number", "ordinal": 1, "type_info": "Int8" }, { - "name": "last_batch_miniblock?", + "name": "circuit_type", "ordinal": 2, - "type_info": "Int8" + "type_info": "Text" }, { - "name": "timestamp", + "name": "prover_input", "ordinal": 3, - "type_info": "Int8" + "type_info": "Bytea" }, { - "name": "l1_gas_price", + "name": "status", "ordinal": 4, - "type_info": "Int8" + "type_info": "Text" }, { - "name": "l2_fair_gas_price", + "name": "error", "ordinal": 5, - "type_info": "Int8" + "type_info": "Text" }, { - "name": "bootloader_code_hash", + "name": "processing_started_at", "ordinal": 6, - "type_info": "Bytea" + "type_info": "Timestamp" }, { - "name": "default_aa_code_hash", + "name": "created_at", "ordinal": 7, - "type_info": "Bytea" + "type_info": "Timestamp" }, { - "name": "virtual_blocks", + "name": "updated_at", "ordinal": 8, - "type_info": "Int8" + "type_info": "Timestamp" }, { - "name": "hash", + "name": "time_taken", "ordinal": 9, - "type_info": "Bytea" + "type_info": "Time" }, { - "name": "consensus", + "name": "aggregation_round", "ordinal": 10, - "type_info": "Jsonb" + "type_info": "Int4" }, { - "name": "protocol_version!", + "name": "result", "ordinal": 11, - "type_info": "Int4" + "type_info": "Bytea" }, { - "name": "fee_account_address?", + "name": "sequence_number", "ordinal": 12, - "type_info": "Bytea" + "type_info": "Int4" + }, + { + "name": "attempts", + "ordinal": 13, + "type_info": "Int4" + }, + { + "name": "circuit_input_blob_url", + "ordinal": 14, + "type_info": "Text" + }, + { + "name": "proccesed_by", + "ordinal": 15, + "type_info": "Text" + }, + { + "name": "is_blob_cleaned", + "ordinal": 16, + "type_info": "Bool" + }, + { + "name": "protocol_version", + "ordinal": 17, + "type_info": "Int4" } ], "nullable": [ false, - null, - null, + false, false, false, false, @@ -5542,9 +5821,15 @@ true, false, false, + false, + false, + true, + false, + false, true, true, - false + false, + true ], "parameters": { "Left": [ @@ -5552,225 +5837,261 @@ ] } }, - "query": "SELECT miniblocks.number, COALESCE(miniblocks.l1_batch_number, (SELECT (max(number) + 1) FROM l1_batches)) as \"l1_batch_number!\", (SELECT max(m2.number) FROM miniblocks m2 WHERE miniblocks.l1_batch_number = m2.l1_batch_number) as \"last_batch_miniblock?\", miniblocks.timestamp, miniblocks.l1_gas_price, miniblocks.l2_fair_gas_price, miniblocks.bootloader_code_hash, miniblocks.default_aa_code_hash, miniblocks.virtual_blocks, miniblocks.hash, miniblocks.consensus, miniblocks.protocol_version as \"protocol_version!\", l1_batches.fee_account_address as \"fee_account_address?\" FROM miniblocks LEFT JOIN l1_batches ON miniblocks.l1_batch_number = l1_batches.number WHERE miniblocks.number = $1" + "query": "\n SELECT\n *\n FROM\n prover_jobs\n WHERE\n id = $1\n " }, - "6b53e5cb619c9649d28ae33df6a43e6984e2d9320f894f3d04156a2d1235bb60": { + "68c891ee9d71cffe709731f2804b734d5d255e36e48668b3bfc25a0f86ea52e7": { "describe": { "columns": [ { - "name": "hash", + "name": "is_replaced!", "ordinal": 0, - "type_info": "Bytea" + "type_info": "Bool" } ], "nullable": [ - false + null ], "parameters": { "Left": [ + "Bytea", + "Bytea", "Int8", - "Int8" + "Bytea", + "Numeric", + "Numeric", + "Numeric", + "Numeric", + "Bytea", + "Jsonb", + "Int4", + "Bytea", + "Numeric", + "Bytea", + "Bytea", + "Int8", + "Int4", + "Int4", + "Timestamp" ] } }, - "query": "SELECT hash FROM miniblocks WHERE number BETWEEN $1 AND $2 ORDER BY number" + "query": "\n INSERT INTO\n transactions (\n hash,\n is_priority,\n initiator_address,\n nonce,\n signature,\n gas_limit,\n max_fee_per_gas,\n max_priority_fee_per_gas,\n gas_per_pubdata_limit,\n input,\n data,\n tx_format,\n contract_address,\n value,\n paymaster,\n paymaster_input,\n execution_info,\n received_at,\n created_at,\n updated_at\n )\n VALUES\n (\n $1,\n FALSE,\n $2,\n $3,\n $4,\n $5,\n $6,\n $7,\n $8,\n $9,\n $10,\n $11,\n $12,\n $13,\n $14,\n $15,\n JSONB_BUILD_OBJECT('gas_used', $16::BIGINT, 'storage_writes', $17::INT, 'contracts_used', $18::INT),\n $19,\n NOW(),\n NOW()\n )\n ON CONFLICT (initiator_address, nonce) DO\n UPDATE\n SET\n hash = $1,\n signature = $4,\n gas_limit = $5,\n max_fee_per_gas = $6,\n max_priority_fee_per_gas = $7,\n gas_per_pubdata_limit = $8,\n input = $9,\n data = $10,\n tx_format = $11,\n contract_address = $12,\n value = $13,\n paymaster = $14,\n paymaster_input = $15,\n execution_info = JSONB_BUILD_OBJECT('gas_used', $16::BIGINT, 'storage_writes', $17::INT, 'contracts_used', $18::INT),\n in_mempool = FALSE,\n received_at = $19,\n created_at = NOW(),\n updated_at = NOW(),\n error = NULL\n WHERE\n transactions.is_priority = FALSE\n AND transactions.miniblock_number IS NULL\n RETURNING\n (\n SELECT\n hash\n FROM\n transactions\n WHERE\n transactions.initiator_address = $2\n AND transactions.nonce = $3\n ) IS NOT NULL AS \"is_replaced!\"\n " }, - "6c0915ed87e6d0fdf83cb24a51cc277e366bea0ba8821c048092d2a0aadb2771": { + "6ae2ed34230beae0e86c584e293e7ee767e4c98706246eb113498c0f817f5f38": { "describe": { "columns": [], "nullable": [], "parameters": { "Left": [ - "Int8", - "Int8", - "Bytea", - "Int4", - "Int4", - "Numeric", - "Int8", - "Int8", - "Int8", - "Bytea", - "Bytea", + "Text", "Int4", - "Int8" + "Int2", + "Text" ] } }, - "query": "INSERT INTO miniblocks ( number, timestamp, hash, l1_tx_count, l2_tx_count, base_fee_per_gas, l1_gas_price, l2_fair_gas_price, gas_per_pubdata_limit, bootloader_code_hash, default_aa_code_hash, protocol_version, virtual_blocks, created_at, updated_at ) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, now(), now())" + "query": "\n INSERT INTO\n gpu_prover_queue_fri (\n instance_host,\n instance_port,\n instance_status,\n specialized_prover_group_id,\n zone,\n created_at,\n updated_at\n )\n VALUES\n (CAST($1::TEXT AS inet), $2, 'available', $3, $4, NOW(), NOW())\n ON CONFLICT (instance_host, instance_port, zone) DO\n UPDATE\n SET\n instance_status = 'available',\n specialized_prover_group_id = $3,\n zone = $4,\n updated_at = NOW()\n " }, - "6d142503d0d8682992a0353bae4a6b25ec82e7cadf0b2bbadcfd23c27f646bae": { + "6b327df84d2b3b31d02db35fd5d91a8d67abcdb743a619ed0d1b9c16206a3c20": { "describe": { "columns": [], "nullable": [], "parameters": { - "Left": [ - "TextArray", - "Text" - ] + "Left": [] } }, - "query": "INSERT INTO compiler_versions (version, compiler, created_at, updated_at) SELECT u.version, $2, now(), now() FROM UNNEST($1::text[]) AS u(version) ON CONFLICT (version, compiler) DO NOTHING" + "query": "\n DELETE FROM eth_txs\n WHERE\n id >= (\n SELECT\n MIN(id)\n FROM\n eth_txs\n WHERE\n has_failed = TRUE\n )\n " }, - "715aba794d60ce2faf937eacd9498b203dbb8e620d6d8850b9071cd72902ffbf": { + "6bd3094be764e6378fe52b5bb533260b49ce42daaf9dbe8075daf0a8e0ad9914": { "describe": { "columns": [], "nullable": [], "parameters": { - "Left": [ - "ByteaArray", - "ByteaArray", - "Int8" - ] + "Left": [] } }, - "query": "INSERT INTO factory_deps (bytecode_hash, bytecode, miniblock_number, created_at, updated_at) SELECT u.bytecode_hash, u.bytecode, $3, now(), now() FROM UNNEST($1::bytea[], $2::bytea[]) AS u(bytecode_hash, bytecode) ON CONFLICT (bytecode_hash) DO NOTHING" + "query": "\n DELETE FROM basic_witness_input_producer_jobs\n " }, - "741b13b0a4769a30186c650a4a1b24855806a27ccd8d5a50594741842dde44ec": { + "6bf641312081de59ae8be08326fc50bd670d8ee9aa7c28eed728dbaa1b8bab25": { "describe": { "columns": [ { - "name": "min?", + "name": "tx_hash", "ordinal": 0, - "type_info": "Int8" + "type_info": "Bytea" }, { - "name": "max?", + "name": "index_in_block", "ordinal": 1, + "type_info": "Int4" + }, + { + "name": "l1_batch_tx_index", + "ordinal": 2, + "type_info": "Int4" + }, + { + "name": "block_number", + "ordinal": 3, "type_info": "Int8" - } - ], - "nullable": [ - null, - null - ], - "parameters": { - "Left": [ - "Int8" - ] - } - }, - "query": "SELECT MIN(miniblocks.number) as \"min?\", MAX(miniblocks.number) as \"max?\" FROM miniblocks WHERE l1_batch_number = $1" - }, - "751c8e5ed1fc211dbb4c7419a316c5f4e49a7f0b4f3a5c74c2abd8daebc457dd": { - "describe": { - "columns": [ + }, { - "name": "l1_batch_number", - "ordinal": 0, + "name": "error", + "ordinal": 4, + "type_info": "Varchar" + }, + { + "name": "effective_gas_price", + "ordinal": 5, + "type_info": "Numeric" + }, + { + "name": "initiator_address", + "ordinal": 6, + "type_info": "Bytea" + }, + { + "name": "transfer_to?", + "ordinal": 7, + "type_info": "Jsonb" + }, + { + "name": "execute_contract_address?", + "ordinal": 8, + "type_info": "Jsonb" + }, + { + "name": "tx_format?", + "ordinal": 9, + "type_info": "Int4" + }, + { + "name": "refunded_gas", + "ordinal": 10, "type_info": "Int8" - } - ], - "nullable": [ - true - ], - "parameters": { - "Left": [ - "Int8" - ] - } - }, - "query": "SELECT l1_batch_number FROM miniblocks WHERE number = $1" - }, - "7717652bb4933f87cbeb7baa2e70e8e0b439663c6b15493bd2e406bed2486b42": { - "describe": { - "columns": [ + }, { - "name": "max", - "ordinal": 0, + "name": "gas_limit", + "ordinal": 11, + "type_info": "Numeric" + }, + { + "name": "block_hash?", + "ordinal": 12, + "type_info": "Bytea" + }, + { + "name": "l1_batch_number?", + "ordinal": 13, "type_info": "Int8" + }, + { + "name": "contract_address?", + "ordinal": 14, + "type_info": "Bytea" } ], "nullable": [ - null + false, + true, + true, + true, + true, + true, + false, + null, + null, + true, + false, + true, + false, + true, + false ], "parameters": { "Left": [ - "Numeric" + "Bytea", + "Bytea", + "Bytea" ] } }, - "query": "SELECT max(l1_batches.number) FROM l1_batches JOIN eth_txs ON (l1_batches.eth_commit_tx_id = eth_txs.id) JOIN eth_txs_history AS commit_tx ON (eth_txs.confirmed_eth_tx_history_id = commit_tx.id) WHERE commit_tx.confirmed_at IS NOT NULL AND eth_prove_tx_id IS NOT NULL AND eth_execute_tx_id IS NULL AND EXTRACT(epoch FROM commit_tx.confirmed_at) < $1" + "query": "\n WITH\n sl AS (\n SELECT\n *\n FROM\n storage_logs\n WHERE\n storage_logs.address = $1\n AND storage_logs.tx_hash = $2\n ORDER BY\n storage_logs.miniblock_number DESC,\n storage_logs.operation_number DESC\n LIMIT\n 1\n )\n SELECT\n transactions.hash AS tx_hash,\n transactions.index_in_block AS index_in_block,\n transactions.l1_batch_tx_index AS l1_batch_tx_index,\n transactions.miniblock_number AS block_number,\n transactions.error AS error,\n transactions.effective_gas_price AS effective_gas_price,\n transactions.initiator_address AS initiator_address,\n transactions.data -> 'to' AS \"transfer_to?\",\n transactions.data -> 'contractAddress' AS \"execute_contract_address?\",\n transactions.tx_format AS \"tx_format?\",\n transactions.refunded_gas AS refunded_gas,\n transactions.gas_limit AS gas_limit,\n miniblocks.hash AS \"block_hash?\",\n miniblocks.l1_batch_number AS \"l1_batch_number?\",\n sl.key AS \"contract_address?\"\n FROM\n transactions\n LEFT JOIN miniblocks ON miniblocks.number = transactions.miniblock_number\n LEFT JOIN sl ON sl.value != $3\n WHERE\n transactions.hash = $2\n " }, - "77d78689b5c0b631da047f21c89a607213bec507cd9cf2b5cb4ea86e1a084796": { + "6c0d03b1fbe6f47546bc34c6b2eab01cb2c55bf86d2c8c99abb1b7ca21cf75c0": { "describe": { "columns": [], "nullable": [], "parameters": { "Left": [ - "Bytea", - "Bytea", - "Bytea", - "Bytea", - "Bytea", - "Bytea", - "Bytea", - "Bytea", - "Bool", - "Bytea", - "Int8", - "Bytea", - "Bytea", - "Bytea", - "Bytea", - "Int8" + "Int4" ] } }, - "query": "UPDATE l1_batches SET hash = $1, merkle_root_hash = $2, commitment = $3, default_aa_code_hash = $4, compressed_repeated_writes = $5, compressed_initial_writes = $6, l2_l1_compressed_messages = $7, l2_l1_merkle_root = $8, zkporter_is_available = $9, bootloader_code_hash = $10, rollup_last_leaf_index = $11, aux_data_hash = $12, pass_through_data_hash = $13, meta_parameters_hash = $14, compressed_state_diffs = $15, updated_at = now() WHERE number = $16" + "query": "\n UPDATE miniblocks\n SET\n protocol_version = $1\n WHERE\n l1_batch_number IS NULL\n " }, - "78ba607e97bdf8b7c0b5e3cf87e10dc3b352a8552c2e94532b0f392af7dbe9cd": { + "6ccb3beec0624153ef2e7bff61ba896e34b757421fca9682aecb3a98b54695a6": { "describe": { "columns": [ { - "name": "id", + "name": "number", "ordinal": 0, "type_info": "Int8" }, { - "name": "contract_address", + "name": "timestamp", "ordinal": 1, - "type_info": "Bytea" + "type_info": "Int8" }, { - "name": "source_code", + "name": "hash", "ordinal": 2, - "type_info": "Text" + "type_info": "Bytea" }, { - "name": "contract_name", + "name": "l1_tx_count", "ordinal": 3, - "type_info": "Text" + "type_info": "Int4" }, { - "name": "zk_compiler_version", + "name": "l2_tx_count", "ordinal": 4, - "type_info": "Text" + "type_info": "Int4" }, { - "name": "compiler_version", + "name": "base_fee_per_gas", "ordinal": 5, - "type_info": "Text" + "type_info": "Numeric" }, { - "name": "optimization_used", + "name": "l1_gas_price", "ordinal": 6, - "type_info": "Bool" + "type_info": "Int8" }, { - "name": "optimizer_mode", + "name": "l2_fair_gas_price", "ordinal": 7, - "type_info": "Text" + "type_info": "Int8" }, { - "name": "constructor_arguments", + "name": "bootloader_code_hash", "ordinal": 8, "type_info": "Bytea" }, { - "name": "is_system", + "name": "default_aa_code_hash", "ordinal": 9, - "type_info": "Bool" + "type_info": "Bytea" + }, + { + "name": "protocol_version", + "ordinal": 10, + "type_info": "Int4" + }, + { + "name": "virtual_blocks", + "ordinal": 11, + "type_info": "Int8" } ], "nullable": [ @@ -5781,79 +6102,19 @@ false, false, false, - true, - false, - false - ], - "parameters": { - "Left": [ - "Interval" - ] - } - }, - "query": "UPDATE contract_verification_requests SET status = 'in_progress', attempts = attempts + 1, updated_at = now(), processing_started_at = now() WHERE id = ( SELECT id FROM contract_verification_requests WHERE status = 'queued' OR (status = 'in_progress' AND processing_started_at < now() - $1::interval) ORDER BY created_at LIMIT 1 FOR UPDATE SKIP LOCKED ) RETURNING id, contract_address, source_code, contract_name, zk_compiler_version, compiler_version, optimization_used, optimizer_mode, constructor_arguments, is_system" - }, - "79420f7676acb3f17aeb538271cdb4067a342fd554adcf7bd0550b6682b4c82b": { - "describe": { - "columns": [ - { - "name": "tx_hash", - "ordinal": 0, - "type_info": "Bytea" - }, - { - "name": "call_trace", - "ordinal": 1, - "type_info": "Bytea" - } - ], - "nullable": [ false, + true, + true, + true, false ], "parameters": { - "Left": [ - "Int8" - ] - } - }, - "query": "SELECT * FROM call_traces WHERE tx_hash IN (SELECT hash FROM transactions WHERE miniblock_number = $1)" - }, - "79cdb4cdd3c47b3654e6240178985fb4b4420e0634f9482a6ef8169e90200b84": { - "describe": { - "columns": [ - { - "name": "attempts", - "ordinal": 0, - "type_info": "Int2" - } - ], - "nullable": [ - false - ], - "parameters": { - "Left": [ - "Int8" - ] - } - }, - "query": "SELECT attempts FROM scheduler_witness_jobs_fri WHERE l1_batch_number = $1" - }, - "7b8043a59029a19a3ba2433a438e8a4fe560aba7eda57b7a63b580de2e19aacb": { - "describe": { - "columns": [], - "nullable": [], - "parameters": { - "Left": [ - "Int8", - "Text", - "Int4" - ] + "Left": [] } }, - "query": "INSERT INTO witness_inputs_fri(l1_batch_number, merkle_tree_paths_blob_url, protocol_version, status, created_at, updated_at) VALUES ($1, $2, $3, 'queued', now(), now()) ON CONFLICT (l1_batch_number) DO NOTHING" + "query": "\n SELECT\n number,\n timestamp,\n hash,\n l1_tx_count,\n l2_tx_count,\n base_fee_per_gas,\n l1_gas_price,\n l2_fair_gas_price,\n bootloader_code_hash,\n default_aa_code_hash,\n protocol_version,\n virtual_blocks\n FROM\n miniblocks\n ORDER BY\n number DESC\n LIMIT\n 1\n " }, - "7c3e55a10c8cf90e60001bca401113fd5335ec6c4b1ffdb6d6ff063d244d23e2": { + "6f6f60e7139fc789ca420d8610985a918e90b4e7087a98356ab19e22783c88cd": { "describe": { "columns": [ { @@ -5862,29 +6123,29 @@ "type_info": "Int8" }, { - "name": "l1_batch_number", + "name": "instance_host", "ordinal": 1, - "type_info": "Int8" + "type_info": "Inet" }, { - "name": "circuit_type", + "name": "instance_port", "ordinal": 2, - "type_info": "Text" + "type_info": "Int4" }, { - "name": "prover_input", + "name": "instance_status", "ordinal": 3, - "type_info": "Bytea" + "type_info": "Text" }, { - "name": "status", + "name": "created_at", "ordinal": 4, - "type_info": "Text" + "type_info": "Timestamp" }, { - "name": "error", + "name": "updated_at", "ordinal": 5, - "type_info": "Text" + "type_info": "Timestamp" }, { "name": "processing_started_at", @@ -5892,59 +6153,34 @@ "type_info": "Timestamp" }, { - "name": "created_at", + "name": "queue_free_slots", "ordinal": 7, - "type_info": "Timestamp" + "type_info": "Int4" }, { - "name": "updated_at", + "name": "queue_capacity", "ordinal": 8, - "type_info": "Timestamp" + "type_info": "Int4" }, { - "name": "time_taken", + "name": "specialized_prover_group_id", "ordinal": 9, - "type_info": "Time" + "type_info": "Int2" }, { - "name": "aggregation_round", + "name": "region", "ordinal": 10, - "type_info": "Int4" - }, - { - "name": "result", - "ordinal": 11, - "type_info": "Bytea" - }, - { - "name": "sequence_number", - "ordinal": 12, - "type_info": "Int4" - }, - { - "name": "attempts", - "ordinal": 13, - "type_info": "Int4" - }, - { - "name": "circuit_input_blob_url", - "ordinal": 14, "type_info": "Text" }, { - "name": "proccesed_by", - "ordinal": 15, + "name": "zone", + "ordinal": 11, "type_info": "Text" }, { - "name": "is_blob_cleaned", - "ordinal": 16, - "type_info": "Bool" - }, - { - "name": "protocol_version", - "ordinal": 17, - "type_info": "Int4" + "name": "num_gpu", + "ordinal": 12, + "type_info": "Int2" } ], "nullable": [ @@ -5953,160 +6189,150 @@ false, false, false, - true, - true, - false, - false, - false, false, true, - false, - false, true, true, - false, - true - ], - "parameters": { - "Left": [ - "TextArray", - "Int4Array" - ] - } - }, - "query": "\n UPDATE prover_jobs\n SET status = 'in_progress', attempts = attempts + 1,\n updated_at = now(), processing_started_at = now()\n WHERE id = (\n SELECT id\n FROM prover_jobs\n WHERE circuit_type = ANY($1)\n AND status = 'queued'\n AND protocol_version = ANY($2)\n ORDER BY aggregation_round DESC, l1_batch_number ASC, id ASC\n LIMIT 1\n FOR UPDATE\n SKIP LOCKED\n )\n RETURNING prover_jobs.*\n " - }, - "7ca78be8b18638857111cdbc6117ed2c204e3eb22682d5e4553ac4f47efab6e2": { - "describe": { - "columns": [ - { - "name": "hash", - "ordinal": 0, - "type_info": "Bytea" - } - ], - "nullable": [ - false - ], - "parameters": { - "Left": [ - "Int8" - ] - } - }, - "query": "UPDATE transactions\n SET l1_batch_number = NULL, miniblock_number = NULL, error = NULL, index_in_block = NULL, execution_info = '{}'\n WHERE miniblock_number > $1\n RETURNING hash\n " - }, - "7cf855c4869db43b765b92762402596f6b97b3717735b6d87a16a5776f2eca71": { - "describe": { - "columns": [], - "nullable": [], + true, + false, + false, + true + ], "parameters": { "Left": [ - "Bytea", - "Numeric", - "Timestamp" + "Interval", + "Int2", + "Text", + "Text" ] } }, - "query": "UPDATE tokens SET usd_price = $2, usd_price_updated_at = $3, updated_at = now() WHERE l1_address = $1" + "query": "\n UPDATE gpu_prover_queue\n SET\n instance_status = 'reserved',\n updated_at = NOW(),\n processing_started_at = NOW()\n WHERE\n id IN (\n SELECT\n id\n FROM\n gpu_prover_queue\n WHERE\n specialized_prover_group_id = $2\n AND region = $3\n AND zone = $4\n AND (\n instance_status = 'available'\n OR (\n instance_status = 'reserved'\n AND processing_started_at < NOW() - $1::INTERVAL\n )\n )\n ORDER BY\n updated_at ASC\n LIMIT\n 1\n FOR UPDATE\n SKIP LOCKED\n )\n RETURNING\n gpu_prover_queue.*\n " }, - "7d4210089c5abb84befec962fc769b396ff7ad7da212d079bd4460f9ea4d60dc": { + "708b2b3e40887e6d8d2d7aa20448a58479487686d774e6b2b1391347bdafe06d": { "describe": { "columns": [ { - "name": "l1_batch_number?", + "name": "number", "ordinal": 0, "type_info": "Int8" + }, + { + "name": "hash", + "ordinal": 1, + "type_info": "Bytea" } ], "nullable": [ - null + false, + false ], - "parameters": { - "Left": [] - } - }, - "query": "\n SELECT MIN(l1_batch_number) as \"l1_batch_number?\" FROM (\n SELECT MIN(l1_batch_number) as \"l1_batch_number\"\n FROM prover_jobs\n WHERE status = 'successful' OR aggregation_round < 3\n GROUP BY l1_batch_number\n HAVING MAX(aggregation_round) < 3\n ) as inn\n " - }, - "7df997e5a203e8df350b1346863fddf26d32123159213c02e8794c39240e48dc": { - "describe": { - "columns": [], - "nullable": [], "parameters": { "Left": [ + "Int8", "Int8" ] } }, - "query": "UPDATE miniblocks SET l1_batch_number = $1 WHERE l1_batch_number IS NULL" + "query": "\n SELECT\n number,\n hash\n FROM\n miniblocks\n WHERE\n number >= $1\n ORDER BY\n number ASC\n LIMIT\n $2\n " }, - "8045a697a6a1070857b6fdc656f60ee6bab4b3a875ab98099beee227c199f818": { + "711820868a1e3016e68f0f4ed92ba6a3edc9f72675dae6ff44442e09caf48178": { "describe": { "columns": [ { - "name": "miniblock_number", + "name": "number", "ordinal": 0, "type_info": "Int8" }, { - "name": "log_index_in_miniblock", + "name": "l1_tx_count", "ordinal": 1, "type_info": "Int4" }, { - "name": "log_index_in_tx", + "name": "l2_tx_count", "ordinal": 2, "type_info": "Int4" }, { - "name": "tx_hash", + "name": "timestamp", "ordinal": 3, - "type_info": "Bytea" + "type_info": "Int8" }, { - "name": "block_hash", + "name": "is_finished", "ordinal": 4, - "type_info": "Bytea" + "type_info": "Bool" }, { - "name": "l1_batch_number?", + "name": "fee_account_address", "ordinal": 5, - "type_info": "Int8" + "type_info": "Bytea" }, { - "name": "shard_id", + "name": "l2_to_l1_logs", "ordinal": 6, - "type_info": "Int4" + "type_info": "ByteaArray" }, { - "name": "is_service", + "name": "l2_to_l1_messages", "ordinal": 7, - "type_info": "Bool" + "type_info": "ByteaArray" }, { - "name": "tx_index_in_miniblock", + "name": "bloom", "ordinal": 8, - "type_info": "Int4" + "type_info": "Bytea" }, { - "name": "tx_index_in_l1_batch", + "name": "priority_ops_onchain_data", "ordinal": 9, - "type_info": "Int4" + "type_info": "ByteaArray" }, { - "name": "sender", + "name": "used_contract_hashes", "ordinal": 10, - "type_info": "Bytea" + "type_info": "Jsonb" }, { - "name": "key", + "name": "base_fee_per_gas", "ordinal": 11, - "type_info": "Bytea" + "type_info": "Numeric" }, { - "name": "value", + "name": "l1_gas_price", "ordinal": 12, + "type_info": "Int8" + }, + { + "name": "l2_fair_gas_price", + "ordinal": 13, + "type_info": "Int8" + }, + { + "name": "bootloader_code_hash", + "ordinal": 14, + "type_info": "Bytea" + }, + { + "name": "default_aa_code_hash", + "ordinal": 15, + "type_info": "Bytea" + }, + { + "name": "protocol_version", + "ordinal": 16, + "type_info": "Int4" + }, + { + "name": "compressed_state_diffs", + "ordinal": 17, "type_info": "Bytea" + }, + { + "name": "system_logs", + "ordinal": 18, + "type_info": "ByteaArray" } ], "nullable": [ @@ -6114,200 +6340,271 @@ false, false, false, - null, - null, false, false, false, false, false, false, + false, + false, + false, + false, + true, + true, + true, + true, false ], "parameters": { "Left": [ - "Bytea" + "Int8" ] } }, - "query": "SELECT miniblock_number, log_index_in_miniblock, log_index_in_tx, tx_hash, Null::bytea as \"block_hash\", Null::bigint as \"l1_batch_number?\", shard_id, is_service, tx_index_in_miniblock, tx_index_in_l1_batch, sender, key, value FROM l2_to_l1_logs WHERE tx_hash = $1 ORDER BY log_index_in_tx ASC" + "query": "\n SELECT\n number,\n l1_tx_count,\n l2_tx_count,\n timestamp,\n is_finished,\n fee_account_address,\n l2_to_l1_logs,\n l2_to_l1_messages,\n bloom,\n priority_ops_onchain_data,\n used_contract_hashes,\n base_fee_per_gas,\n l1_gas_price,\n l2_fair_gas_price,\n bootloader_code_hash,\n default_aa_code_hash,\n protocol_version,\n compressed_state_diffs,\n system_logs\n FROM\n l1_batches\n WHERE\n number = $1\n " }, - "832105952074e4ff35252d8e7973faa1b24455abc89820307db5e49a834c0718": { + "72a4f50355324cce85ebaef9fa32826095e9290f0c1157094bd0c44e06012e42": { "describe": { "columns": [ { - "name": "number", + "name": "hash", "ordinal": 0, - "type_info": "Int8" + "type_info": "Bytea" }, { - "name": "l1_tx_count", + "name": "is_priority", "ordinal": 1, - "type_info": "Int4" + "type_info": "Bool" }, { - "name": "l2_tx_count", + "name": "full_fee", "ordinal": 2, - "type_info": "Int4" + "type_info": "Numeric" }, { - "name": "timestamp", + "name": "layer_2_tip_fee", "ordinal": 3, - "type_info": "Int8" + "type_info": "Numeric" }, { - "name": "is_finished", + "name": "initiator_address", "ordinal": 4, - "type_info": "Bool" + "type_info": "Bytea" }, { - "name": "fee_account_address", + "name": "nonce", "ordinal": 5, - "type_info": "Bytea" + "type_info": "Int8" }, { - "name": "l2_to_l1_logs", + "name": "signature", "ordinal": 6, - "type_info": "ByteaArray" + "type_info": "Bytea" }, { - "name": "l2_to_l1_messages", + "name": "input", "ordinal": 7, - "type_info": "ByteaArray" + "type_info": "Bytea" }, { - "name": "bloom", + "name": "data", "ordinal": 8, - "type_info": "Bytea" + "type_info": "Jsonb" }, { - "name": "priority_ops_onchain_data", + "name": "received_at", "ordinal": 9, - "type_info": "ByteaArray" + "type_info": "Timestamp" }, { - "name": "used_contract_hashes", + "name": "priority_op_id", "ordinal": 10, - "type_info": "Jsonb" + "type_info": "Int8" }, { - "name": "base_fee_per_gas", + "name": "l1_batch_number", "ordinal": 11, - "type_info": "Numeric" + "type_info": "Int8" }, { - "name": "l1_gas_price", + "name": "index_in_block", "ordinal": 12, - "type_info": "Int8" + "type_info": "Int4" }, { - "name": "l2_fair_gas_price", + "name": "error", "ordinal": 13, + "type_info": "Varchar" + }, + { + "name": "gas_limit", + "ordinal": 14, + "type_info": "Numeric" + }, + { + "name": "gas_per_storage_limit", + "ordinal": 15, + "type_info": "Numeric" + }, + { + "name": "gas_per_pubdata_limit", + "ordinal": 16, + "type_info": "Numeric" + }, + { + "name": "tx_format", + "ordinal": 17, + "type_info": "Int4" + }, + { + "name": "created_at", + "ordinal": 18, + "type_info": "Timestamp" + }, + { + "name": "updated_at", + "ordinal": 19, + "type_info": "Timestamp" + }, + { + "name": "execution_info", + "ordinal": 20, + "type_info": "Jsonb" + }, + { + "name": "contract_address", + "ordinal": 21, + "type_info": "Bytea" + }, + { + "name": "in_mempool", + "ordinal": 22, + "type_info": "Bool" + }, + { + "name": "l1_block_number", + "ordinal": 23, + "type_info": "Int4" + }, + { + "name": "value", + "ordinal": 24, + "type_info": "Numeric" + }, + { + "name": "paymaster", + "ordinal": 25, + "type_info": "Bytea" + }, + { + "name": "paymaster_input", + "ordinal": 26, + "type_info": "Bytea" + }, + { + "name": "max_fee_per_gas", + "ordinal": 27, + "type_info": "Numeric" + }, + { + "name": "max_priority_fee_per_gas", + "ordinal": 28, + "type_info": "Numeric" + }, + { + "name": "effective_gas_price", + "ordinal": 29, + "type_info": "Numeric" + }, + { + "name": "miniblock_number", + "ordinal": 30, "type_info": "Int8" }, { - "name": "bootloader_code_hash", - "ordinal": 14, - "type_info": "Bytea" + "name": "l1_batch_tx_index", + "ordinal": 31, + "type_info": "Int4" }, { - "name": "default_aa_code_hash", - "ordinal": 15, - "type_info": "Bytea" + "name": "refunded_gas", + "ordinal": 32, + "type_info": "Int8" }, { - "name": "protocol_version", - "ordinal": 16, - "type_info": "Int4" + "name": "l1_tx_mint", + "ordinal": 33, + "type_info": "Numeric" }, { - "name": "system_logs", - "ordinal": 17, - "type_info": "ByteaArray" + "name": "l1_tx_refund_recipient", + "ordinal": 34, + "type_info": "Bytea" }, { - "name": "compressed_state_diffs", - "ordinal": 18, - "type_info": "Bytea" + "name": "upgrade_id", + "ordinal": 35, + "type_info": "Int4" } ], "nullable": [ false, false, + true, + true, false, + true, + true, + true, false, false, + true, + true, + true, + true, + true, + true, + true, + true, false, false, false, + true, false, + true, false, false, false, - false, - false, + true, + true, true, true, true, false, + true, + true, true ], "parameters": { "Left": [ - "Int4" - ] - } - }, - "query": "SELECT number, l1_tx_count, l2_tx_count, timestamp, is_finished, fee_account_address, l2_to_l1_logs, l2_to_l1_messages, bloom, priority_ops_onchain_data, used_contract_hashes, base_fee_per_gas, l1_gas_price, l2_fair_gas_price, bootloader_code_hash, default_aa_code_hash, protocol_version, system_logs, compressed_state_diffs FROM l1_batches WHERE eth_commit_tx_id = $1 OR eth_prove_tx_id = $1 OR eth_execute_tx_id = $1" - }, - "84703029e09ab1362aa4b4177b38be594d2daf17e69508cae869647028055efb": { - "describe": { - "columns": [ - { - "name": "l1_batch_number", - "ordinal": 0, - "type_info": "Int8" - }, - { - "name": "status", - "ordinal": 1, - "type_info": "Text" - } - ], - "nullable": [ - false, - false - ], - "parameters": { - "Left": [ - "Text", - "Text" + "Bytea" ] } }, - "query": "SELECT l1_batch_number, status FROM proof_compression_jobs_fri\n WHERE l1_batch_number = ( SELECT MIN(l1_batch_number) FROM proof_compression_jobs_fri WHERE status = $1 OR status = $2\n )" + "query": "\n SELECT\n *\n FROM\n transactions\n WHERE\n hash = $1\n " }, - "848d82292a4960154449b425e0b10e250a4ced4c27fb324657589859a512d3a4": { + "72ff9df79e78129cb96d14ece0198129b44534062f524823666ed432d2fcd345": { "describe": { - "columns": [ - { - "name": "tx_hash", - "ordinal": 0, - "type_info": "Text" - } - ], - "nullable": [ - false - ], + "columns": [], + "nullable": [], "parameters": { - "Left": [ - "Int4" - ] + "Left": [] } }, - "query": "SELECT tx_hash FROM eth_txs_history WHERE eth_tx_id = $1 AND confirmed_at IS NOT NULL" + "query": "\n VACUUM storage_logs\n " }, - "85ac7fb2c4175d662c8f466e722d28b0eadcd2f252a788e366dbd05eac547b93": { + "73114e702ff74da985e1e757bbae8e56f148282e3f27ff701adf248281811d9f": { "describe": { "columns": [ { @@ -6548,267 +6845,141 @@ true ], "parameters": { - "Left": [] + "Left": [ + "Int8" + ] } }, - "query": "SELECT number, timestamp, is_finished, l1_tx_count, l2_tx_count, fee_account_address, bloom, priority_ops_onchain_data, hash, parent_hash, commitment, compressed_write_logs, compressed_contracts, eth_prove_tx_id, eth_commit_tx_id, eth_execute_tx_id, merkle_root_hash, l2_to_l1_logs, l2_to_l1_messages, used_contract_hashes, compressed_initial_writes, compressed_repeated_writes, l2_l1_compressed_messages, l2_l1_merkle_root, l1_gas_price, l2_fair_gas_price, rollup_last_leaf_index, zkporter_is_available, bootloader_code_hash, default_aa_code_hash, base_fee_per_gas, aux_data_hash, pass_through_data_hash, meta_parameters_hash, protocol_version, compressed_state_diffs, system_logs, events_queue_commitment, bootloader_initial_content_commitment\n FROM l1_batches LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number WHERE number = 0 OR eth_commit_tx_id IS NOT NULL AND commitment IS NOT NULL ORDER BY number DESC LIMIT 1" + "query": "\n SELECT\n number,\n timestamp,\n is_finished,\n l1_tx_count,\n l2_tx_count,\n fee_account_address,\n bloom,\n priority_ops_onchain_data,\n hash,\n parent_hash,\n commitment,\n compressed_write_logs,\n compressed_contracts,\n eth_prove_tx_id,\n eth_commit_tx_id,\n eth_execute_tx_id,\n merkle_root_hash,\n l2_to_l1_logs,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_compressed_messages,\n l2_l1_merkle_root,\n l1_gas_price,\n l2_fair_gas_price,\n rollup_last_leaf_index,\n zkporter_is_available,\n bootloader_code_hash,\n default_aa_code_hash,\n base_fee_per_gas,\n aux_data_hash,\n pass_through_data_hash,\n meta_parameters_hash,\n protocol_version,\n compressed_state_diffs,\n system_logs,\n events_queue_commitment,\n bootloader_initial_content_commitment\n FROM\n l1_batches\n LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number\n WHERE\n eth_commit_tx_id IS NOT NULL\n AND eth_prove_tx_id IS NULL\n ORDER BY\n number\n LIMIT\n $1\n " }, - "85c52cb09c73499507144e3a684c3230c2c71eb4f8ddef43e67fbd33de2747c8": { + "73c4bf1e35d49faaab9f7828e80f396f9d193615d70184d4327378a7fc8a5665": { "describe": { - "columns": [ - { - "name": "timestamp", - "ordinal": 0, - "type_info": "Int8" - }, - { - "name": "hash", - "ordinal": 1, - "type_info": "Bytea" - } - ], - "nullable": [ - false, - true - ], + "columns": [], + "nullable": [], "parameters": { "Left": [ - "Int8" + { + "Custom": { + "kind": { + "Enum": [ + "Queued", + "ManuallySkipped", + "InProgress", + "Successful", + "Failed" + ] + }, + "name": "basic_witness_input_producer_job_status" + } + }, + "Int8", + "Time", + "Text" ] } }, - "query": "SELECT timestamp, hash FROM l1_batches WHERE number = $1" + "query": "\n UPDATE basic_witness_input_producer_jobs\n SET\n status = $1,\n updated_at = NOW(),\n time_taken = $3,\n input_blob_url = $4\n WHERE\n l1_batch_number = $2\n " }, - "87e1ae393bf250f834704c940482884c9ed729a24f41d1ec07319fa0cbcc21a7": { + "7560ba61643a8ec8eeefbe6034226313c255ce356a9a4e25c098484d3129c914": { "describe": { "columns": [], "nullable": [], "parameters": { "Left": [ - "Int8" + "Int4" ] } }, - "query": "DELETE FROM l1_batches WHERE number > $1" + "query": "\n DELETE FROM eth_txs_history\n WHERE\n id = $1\n " }, - "8996a1794585dfe0f9c16a11e113831a63d5d944bc8061d7caa25ea33f12b19d": { + "759b80414b5bcbfe03a0e1e15b37f92c4cfad9313b1461e12242d9becb59e0b0": { "describe": { "columns": [ { - "name": "is_priority", + "name": "max?", "ordinal": 0, - "type_info": "Bool" - }, - { - "name": "initiator_address", - "ordinal": 1, - "type_info": "Bytea" - }, - { - "name": "gas_limit", - "ordinal": 2, - "type_info": "Numeric" - }, - { - "name": "gas_per_pubdata_limit", - "ordinal": 3, - "type_info": "Numeric" - }, - { - "name": "received_at", - "ordinal": 4, - "type_info": "Timestamp" - }, - { - "name": "miniblock_number", - "ordinal": 5, - "type_info": "Int8" - }, - { - "name": "error", - "ordinal": 6, - "type_info": "Varchar" - }, - { - "name": "effective_gas_price", - "ordinal": 7, - "type_info": "Numeric" - }, - { - "name": "refunded_gas", - "ordinal": 8, - "type_info": "Int8" - }, - { - "name": "eth_commit_tx_hash?", - "ordinal": 9, - "type_info": "Text" - }, - { - "name": "eth_prove_tx_hash?", - "ordinal": 10, - "type_info": "Text" - }, - { - "name": "eth_execute_tx_hash?", - "ordinal": 11, - "type_info": "Text" + "type_info": "Int4" } ], "nullable": [ - false, - false, - true, - true, - false, - true, - true, - true, - false, - false, - false, - false + null ], "parameters": { "Left": [ - "Bytea" - ] - } - }, - "query": "\n SELECT transactions.is_priority,\n transactions.initiator_address,\n transactions.gas_limit,\n transactions.gas_per_pubdata_limit,\n transactions.received_at,\n transactions.miniblock_number,\n transactions.error,\n transactions.effective_gas_price,\n transactions.refunded_gas,\n commit_tx.tx_hash as \"eth_commit_tx_hash?\",\n prove_tx.tx_hash as \"eth_prove_tx_hash?\",\n execute_tx.tx_hash as \"eth_execute_tx_hash?\"\n FROM transactions\n LEFT JOIN miniblocks ON miniblocks.number = transactions.miniblock_number\n LEFT JOIN l1_batches ON l1_batches.number = miniblocks.l1_batch_number\n LEFT JOIN eth_txs_history as commit_tx ON (l1_batches.eth_commit_tx_id = commit_tx.eth_tx_id AND commit_tx.confirmed_at IS NOT NULL)\n LEFT JOIN eth_txs_history as prove_tx ON (l1_batches.eth_prove_tx_id = prove_tx.eth_tx_id AND prove_tx.confirmed_at IS NOT NULL)\n LEFT JOIN eth_txs_history as execute_tx ON (l1_batches.eth_execute_tx_id = execute_tx.eth_tx_id AND execute_tx.confirmed_at IS NOT NULL)\n WHERE transactions.hash = $1\n " - }, - "89b124c78f4f6e86790af8ec391a2c486ce01b33cfb4492a443187b1731cae1e": { - "describe": { - "columns": [], - "nullable": [], - "parameters": { - "Left": [ - "Int4", - "Int8", - "Int8" - ] - } - }, - "query": "UPDATE l1_batches SET eth_prove_tx_id = $1, updated_at = now() WHERE number BETWEEN $2 AND $3" - }, - "8a05b6c052ace9b5a383b301f3f441536d90a96bbb791f4711304b22e02193df": { - "describe": { - "columns": [], - "nullable": [], - "parameters": { - "Left": [ - "Time", "Int8" ] } }, - "query": "\n UPDATE leaf_aggregation_witness_jobs_fri\n SET status = 'successful', updated_at = now(), time_taken = $1\n WHERE id = $2\n " + "query": "\n SELECT\n MAX(operation_number) AS \"max?\"\n FROM\n storage_logs\n WHERE\n miniblock_number = $1\n " }, - "8cd540b6063f4a0c1bf4ccb3d111a0ecc341ca8b46b83544c515aa4d809ab9f1": { + "75f6eaa518e7840374c4e44b0788bf92c7f2c55386c8208e3a82b30456abd5b4": { "describe": { "columns": [ { - "name": "number", - "ordinal": 0, - "type_info": "Int8" - }, - { - "name": "l1_batch_number!", - "ordinal": 1, - "type_info": "Int8" - }, - { - "name": "timestamp", - "ordinal": 2, - "type_info": "Int8" - }, - { - "name": "l1_tx_count", - "ordinal": 3, - "type_info": "Int4" - }, - { - "name": "l2_tx_count", - "ordinal": 4, - "type_info": "Int4" - }, - { - "name": "root_hash?", - "ordinal": 5, - "type_info": "Bytea" + "name": "l1_batch_number", + "ordinal": 0, + "type_info": "Int8" }, { - "name": "commit_tx_hash?", - "ordinal": 6, + "name": "merkle_tree_paths_blob_url", + "ordinal": 1, "type_info": "Text" }, { - "name": "committed_at?", - "ordinal": 7, - "type_info": "Timestamp" + "name": "attempts", + "ordinal": 2, + "type_info": "Int2" }, { - "name": "prove_tx_hash?", - "ordinal": 8, + "name": "status", + "ordinal": 3, "type_info": "Text" }, { - "name": "proven_at?", - "ordinal": 9, - "type_info": "Timestamp" - }, - { - "name": "execute_tx_hash?", - "ordinal": 10, + "name": "error", + "ordinal": 4, "type_info": "Text" }, { - "name": "executed_at?", - "ordinal": 11, + "name": "created_at", + "ordinal": 5, "type_info": "Timestamp" }, { - "name": "l1_gas_price", - "ordinal": 12, - "type_info": "Int8" + "name": "updated_at", + "ordinal": 6, + "type_info": "Timestamp" }, { - "name": "l2_fair_gas_price", - "ordinal": 13, - "type_info": "Int8" + "name": "processing_started_at", + "ordinal": 7, + "type_info": "Timestamp" }, { - "name": "bootloader_code_hash", - "ordinal": 14, - "type_info": "Bytea" + "name": "time_taken", + "ordinal": 8, + "type_info": "Time" }, { - "name": "default_aa_code_hash", - "ordinal": 15, - "type_info": "Bytea" + "name": "is_blob_cleaned", + "ordinal": 9, + "type_info": "Bool" }, { "name": "protocol_version", - "ordinal": 16, + "ordinal": 10, "type_info": "Int4" }, { - "name": "fee_account_address?", - "ordinal": 17, - "type_info": "Bytea" + "name": "picked_by", + "ordinal": 11, + "type_info": "Text" } ], "nullable": [ - false, - null, - false, - false, - false, - false, false, true, false, - true, false, true, false, @@ -6816,589 +6987,585 @@ true, true, true, - false - ], - "parameters": { - "Left": [ - "Int8" - ] - } - }, - "query": "\n SELECT miniblocks.number,\n COALESCE(miniblocks.l1_batch_number, (SELECT (max(number) + 1) FROM l1_batches)) as \"l1_batch_number!\",\n miniblocks.timestamp,\n miniblocks.l1_tx_count,\n miniblocks.l2_tx_count,\n miniblocks.hash as \"root_hash?\",\n commit_tx.tx_hash as \"commit_tx_hash?\",\n commit_tx.confirmed_at as \"committed_at?\",\n prove_tx.tx_hash as \"prove_tx_hash?\",\n prove_tx.confirmed_at as \"proven_at?\",\n execute_tx.tx_hash as \"execute_tx_hash?\",\n execute_tx.confirmed_at as \"executed_at?\",\n miniblocks.l1_gas_price,\n miniblocks.l2_fair_gas_price,\n miniblocks.bootloader_code_hash,\n miniblocks.default_aa_code_hash,\n miniblocks.protocol_version,\n l1_batches.fee_account_address as \"fee_account_address?\"\n FROM miniblocks\n LEFT JOIN l1_batches ON miniblocks.l1_batch_number = l1_batches.number\n LEFT JOIN eth_txs_history as commit_tx ON (l1_batches.eth_commit_tx_id = commit_tx.eth_tx_id AND commit_tx.confirmed_at IS NOT NULL)\n LEFT JOIN eth_txs_history as prove_tx ON (l1_batches.eth_prove_tx_id = prove_tx.eth_tx_id AND prove_tx.confirmed_at IS NOT NULL)\n LEFT JOIN eth_txs_history as execute_tx ON (l1_batches.eth_execute_tx_id = execute_tx.eth_tx_id AND execute_tx.confirmed_at IS NOT NULL)\n WHERE miniblocks.number = $1\n " - }, - "8d3c9575e3cea3956ba84edc982fcf6e0f7667350e6c2cd6801db8400eabaf9b": { - "describe": { - "columns": [ - { - "name": "hashed_key", - "ordinal": 0, - "type_info": "Bytea" - } - ], - "nullable": [ - false + true, + true ], "parameters": { "Left": [ - "Int8" + "Int8", + "Int4Array", + "Text" ] } }, - "query": "SELECT DISTINCT ON (hashed_key) hashed_key FROM (SELECT * FROM storage_logs WHERE miniblock_number > $1) inn" + "query": "\n UPDATE witness_inputs_fri\n SET\n status = 'in_progress',\n attempts = attempts + 1,\n updated_at = NOW(),\n processing_started_at = NOW(),\n picked_by = $3\n WHERE\n l1_batch_number = (\n SELECT\n l1_batch_number\n FROM\n witness_inputs_fri\n WHERE\n l1_batch_number <= $1\n AND status = 'queued'\n AND protocol_version = ANY ($2)\n ORDER BY\n l1_batch_number ASC\n LIMIT\n 1\n FOR UPDATE\n SKIP LOCKED\n )\n RETURNING\n witness_inputs_fri.*\n " }, - "8dcbaaa6186da52ca8b440b6428826288dc668af5a6fc99ef3078c8bcb38c419": { + "75fa24c29dc312cbfa89bf1f4a04a42b4ead6964edd17bfcacb4a828492bba60": { "describe": { "columns": [ { - "name": "l1_batch_number", + "name": "state!", "ordinal": 0, - "type_info": "Int8" - }, - { - "name": "circuit_id", - "ordinal": 1, - "type_info": "Int2" - }, - { - "name": "depth", - "ordinal": 2, - "type_info": "Int4" + "type_info": "Jsonb" } ], "nullable": [ - false, - false, false ], "parameters": { "Left": [] } }, - "query": "\n UPDATE node_aggregation_witness_jobs_fri\n SET status='queued'\n WHERE (l1_batch_number, circuit_id, depth) IN\n (SELECT prover_jobs_fri.l1_batch_number, prover_jobs_fri.circuit_id, prover_jobs_fri.depth\n FROM prover_jobs_fri\n JOIN node_aggregation_witness_jobs_fri nawj ON\n prover_jobs_fri.l1_batch_number = nawj.l1_batch_number\n AND prover_jobs_fri.circuit_id = nawj.circuit_id\n AND prover_jobs_fri.depth = nawj.depth\n WHERE nawj.status = 'waiting_for_proofs'\n AND prover_jobs_fri.status = 'successful'\n AND prover_jobs_fri.aggregation_round = 2\n GROUP BY prover_jobs_fri.l1_batch_number, prover_jobs_fri.circuit_id, prover_jobs_fri.depth, nawj.number_of_dependent_jobs\n HAVING COUNT(*) = nawj.number_of_dependent_jobs)\n RETURNING l1_batch_number, circuit_id, depth;\n " + "query": "\n SELECT\n state AS \"state!\"\n FROM\n consensus_replica_state\n WHERE\n fake_key\n " }, - "8f75c5aa615080fc02b60baccae9c49a81e282a54864ea3eb874ebe10a23eafe": { + "76cb9ad97b70d584b19af194576dcf2324f380932698386aa8f9751b1fa24a7b": { "describe": { "columns": [], "nullable": [], "parameters": { "Left": [ - "Int8" + "ByteaArray", + "ByteaArray" ] } }, - "query": "UPDATE prover_jobs_fri SET status = 'sent_to_server', updated_at = now() WHERE l1_batch_number = $1" + "query": "\n INSERT INTO\n call_traces (tx_hash, call_trace)\n SELECT\n u.tx_hash,\n u.call_trace\n FROM\n UNNEST($1::bytea[], $2::bytea[]) AS u (tx_hash, call_trace)\n " }, - "8fa1a390d7b11b60b3352fafc0a8a7fa15bc761b1bb902f5105fd66b2e3087f2": { + "77a43830ca31eac85a3c03d87696bf94a013e49bf50ce23f4de4968781df0796": { "describe": { "columns": [], "nullable": [], "parameters": { "Left": [ + "Bytea", "Int8" ] } }, - "query": "\n INSERT INTO scheduler_dependency_tracker_fri\n (l1_batch_number, status, created_at, updated_at)\n VALUES ($1, 'waiting_for_proofs', now(), now())\n ON CONFLICT(l1_batch_number)\n DO UPDATE SET updated_at=now()\n " + "query": "\n UPDATE l1_batches\n SET\n hash = $1\n WHERE\n number = $2\n " }, - "8fda20e48c41a9c1e58c8c607222a65e1409f63eba91ac99b2736ca5ebbb5ec6": { + "77b35855fbb989f6314469b419726dc7bb98e0f7feaf14656307e20bd2bb0b6c": { "describe": { "columns": [], "nullable": [], "parameters": { "Left": [ - "Bytea", - "Bytea", - "Numeric", - "Numeric", - "Numeric", - "Jsonb", - "Int4", - "Bytea", - "Int4", - "Numeric", - "Bytea", - "Bytea", - "Int4", - "Numeric", - "Bytea", - "Timestamp" + "Jsonb" ] } }, - "query": "\n INSERT INTO transactions\n (\n hash,\n is_priority,\n initiator_address,\n\n gas_limit,\n max_fee_per_gas,\n gas_per_pubdata_limit,\n\n data,\n upgrade_id,\n contract_address,\n l1_block_number,\n value,\n\n paymaster,\n paymaster_input,\n tx_format,\n\n l1_tx_mint,\n l1_tx_refund_recipient,\n\n received_at,\n created_at,\n updated_at\n )\n VALUES\n (\n $1, TRUE, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12,\n $13, $14, $15, $16, now(), now()\n )\n ON CONFLICT (hash) DO NOTHING\n " + "query": "\n INSERT INTO\n consensus_replica_state (fake_key, state)\n VALUES\n (TRUE, $1)\n ON CONFLICT (fake_key) DO\n UPDATE\n SET\n state = excluded.state\n " }, - "8fe01036cac5181aabfdc06095da291c4de6b1e0f82f846c37509bb550ef544e": { + "78720a210af2364dbf0e6213ae1b9263dbe6655fcce708998ca871d22cc41df0": { "describe": { "columns": [ { "name": "l1_address", "ordinal": 0, "type_info": "Bytea" + }, + { + "name": "l2_address", + "ordinal": 1, + "type_info": "Bytea" } ], "nullable": [ + false, false ], "parameters": { - "Left": [] - } - }, - "query": "SELECT l1_address FROM tokens WHERE well_known = false" - }, - "8ff84e800faad1a10eedf537195d37a74a68d8020f286444824d6ccac6727003": { - "describe": { - "columns": [ - { - "name": "number", - "ordinal": 0, - "type_info": "Int8" - }, - { - "name": "timestamp", - "ordinal": 1, - "type_info": "Int8" - }, - { - "name": "is_finished", - "ordinal": 2, - "type_info": "Bool" - }, - { - "name": "l1_tx_count", - "ordinal": 3, - "type_info": "Int4" - }, - { - "name": "l2_tx_count", - "ordinal": 4, - "type_info": "Int4" - }, - { - "name": "fee_account_address", - "ordinal": 5, - "type_info": "Bytea" - }, - { - "name": "bloom", - "ordinal": 6, - "type_info": "Bytea" - }, - { - "name": "priority_ops_onchain_data", - "ordinal": 7, - "type_info": "ByteaArray" - }, - { - "name": "hash", - "ordinal": 8, - "type_info": "Bytea" - }, - { - "name": "parent_hash", - "ordinal": 9, - "type_info": "Bytea" - }, - { - "name": "commitment", - "ordinal": 10, - "type_info": "Bytea" - }, - { - "name": "compressed_write_logs", - "ordinal": 11, - "type_info": "Bytea" - }, - { - "name": "compressed_contracts", - "ordinal": 12, - "type_info": "Bytea" - }, - { - "name": "eth_prove_tx_id", - "ordinal": 13, - "type_info": "Int4" - }, - { - "name": "eth_commit_tx_id", - "ordinal": 14, - "type_info": "Int4" - }, - { - "name": "eth_execute_tx_id", - "ordinal": 15, - "type_info": "Int4" - }, - { - "name": "merkle_root_hash", - "ordinal": 16, - "type_info": "Bytea" - }, - { - "name": "l2_to_l1_logs", - "ordinal": 17, - "type_info": "ByteaArray" - }, - { - "name": "l2_to_l1_messages", - "ordinal": 18, - "type_info": "ByteaArray" - }, - { - "name": "used_contract_hashes", - "ordinal": 19, - "type_info": "Jsonb" - }, - { - "name": "compressed_initial_writes", - "ordinal": 20, - "type_info": "Bytea" - }, - { - "name": "compressed_repeated_writes", - "ordinal": 21, - "type_info": "Bytea" - }, + "Left": [] + } + }, + "query": "\n SELECT\n l1_address,\n l2_address\n FROM\n tokens\n WHERE\n well_known = TRUE\n " + }, + "78978c19282961c5b3dc06352b41caa4cca66d6ad74b2cd1a34ea5f7bc1e6909": { + "describe": { + "columns": [ { - "name": "l2_l1_compressed_messages", - "ordinal": 22, + "name": "tx_hash", + "ordinal": 0, "type_info": "Bytea" }, { - "name": "l2_l1_merkle_root", - "ordinal": 23, + "name": "call_trace", + "ordinal": 1, "type_info": "Bytea" - }, + } + ], + "nullable": [ + false, + false + ], + "parameters": { + "Left": [ + "Bytea" + ] + } + }, + "query": "\n SELECT\n *\n FROM\n call_traces\n WHERE\n tx_hash = $1\n " + }, + "7a2145e2234a7896031bbc1ce82715e903f3b399886c2c73e838bd924fed6776": { + "describe": { + "columns": [], + "nullable": [], + "parameters": { + "Left": [ + "Text", + "Int8", + "Int2", + "Int4", + "Int4" + ] + } + }, + "query": "\n UPDATE node_aggregation_witness_jobs_fri\n SET\n aggregations_url = $1,\n number_of_dependent_jobs = $5,\n updated_at = NOW()\n WHERE\n l1_batch_number = $2\n AND circuit_id = $3\n AND depth = $4\n " + }, + "7a8fffe8d4e3085e00c98f770d250d625f057acf1440b6550375ce5509a816a6": { + "describe": { + "columns": [ { - "name": "l1_gas_price", - "ordinal": 24, + "name": "id", + "ordinal": 0, "type_info": "Int8" }, { - "name": "l2_fair_gas_price", - "ordinal": 25, + "name": "l1_batch_number", + "ordinal": 1, "type_info": "Int8" }, { - "name": "rollup_last_leaf_index", - "ordinal": 26, - "type_info": "Int8" + "name": "circuit_id", + "ordinal": 2, + "type_info": "Int2" }, { - "name": "zkporter_is_available", - "ordinal": 27, - "type_info": "Bool" + "name": "closed_form_inputs_blob_url", + "ordinal": 3, + "type_info": "Text" }, { - "name": "bootloader_code_hash", - "ordinal": 28, - "type_info": "Bytea" + "name": "attempts", + "ordinal": 4, + "type_info": "Int2" }, { - "name": "default_aa_code_hash", - "ordinal": 29, - "type_info": "Bytea" + "name": "status", + "ordinal": 5, + "type_info": "Text" }, { - "name": "base_fee_per_gas", - "ordinal": 30, - "type_info": "Numeric" + "name": "error", + "ordinal": 6, + "type_info": "Text" }, { - "name": "aux_data_hash", - "ordinal": 31, - "type_info": "Bytea" + "name": "created_at", + "ordinal": 7, + "type_info": "Timestamp" }, { - "name": "pass_through_data_hash", - "ordinal": 32, - "type_info": "Bytea" + "name": "updated_at", + "ordinal": 8, + "type_info": "Timestamp" }, { - "name": "meta_parameters_hash", - "ordinal": 33, - "type_info": "Bytea" + "name": "processing_started_at", + "ordinal": 9, + "type_info": "Timestamp" }, { - "name": "protocol_version", - "ordinal": 34, - "type_info": "Int4" + "name": "time_taken", + "ordinal": 10, + "type_info": "Time" }, { - "name": "compressed_state_diffs", - "ordinal": 35, - "type_info": "Bytea" + "name": "is_blob_cleaned", + "ordinal": 11, + "type_info": "Bool" }, { - "name": "system_logs", - "ordinal": 36, - "type_info": "ByteaArray" + "name": "number_of_basic_circuits", + "ordinal": 12, + "type_info": "Int4" }, { - "name": "events_queue_commitment", - "ordinal": 37, - "type_info": "Bytea" + "name": "protocol_version", + "ordinal": 13, + "type_info": "Int4" }, { - "name": "bootloader_initial_content_commitment", - "ordinal": 38, - "type_info": "Bytea" + "name": "picked_by", + "ordinal": 14, + "type_info": "Text" } ], "nullable": [ false, false, false, - false, - false, - false, - false, - false, - true, true, - true, - true, - true, - true, - true, - true, - true, - false, false, false, true, - true, - true, - true, - false, false, - true, - true, - true, - true, false, true, true, true, true, true, - false, - true, true ], "parameters": { "Left": [ + "Int4Array", + "Text" + ] + } + }, + "query": "\n UPDATE leaf_aggregation_witness_jobs_fri\n SET\n status = 'in_progress',\n attempts = attempts + 1,\n updated_at = NOW(),\n processing_started_at = NOW(),\n picked_by = $2\n WHERE\n id = (\n SELECT\n id\n FROM\n leaf_aggregation_witness_jobs_fri\n WHERE\n status = 'queued'\n AND protocol_version = ANY ($1)\n ORDER BY\n l1_batch_number ASC,\n id ASC\n LIMIT\n 1\n FOR UPDATE\n SKIP LOCKED\n )\n RETURNING\n leaf_aggregation_witness_jobs_fri.*\n " + }, + "7fccc28bd829bce334f37197ee6b139e943f3ad2a41387b610606a42b7f03283": { + "describe": { + "columns": [], + "nullable": [], + "parameters": { + "Left": [ + "Bytea", + "Bytea", + "Numeric", + "Numeric", + "Numeric", + "Jsonb", + "Int4", + "Bytea", + "Int4", + "Numeric", + "Bytea", + "Bytea", + "Int4", + "Numeric", + "Bytea", + "Timestamp" + ] + } + }, + "query": "\n INSERT INTO\n transactions (\n hash,\n is_priority,\n initiator_address,\n gas_limit,\n max_fee_per_gas,\n gas_per_pubdata_limit,\n data,\n upgrade_id,\n contract_address,\n l1_block_number,\n value,\n paymaster,\n paymaster_input,\n tx_format,\n l1_tx_mint,\n l1_tx_refund_recipient,\n received_at,\n created_at,\n updated_at\n )\n VALUES\n (\n $1,\n TRUE,\n $2,\n $3,\n $4,\n $5,\n $6,\n $7,\n $8,\n $9,\n $10,\n $11,\n $12,\n $13,\n $14,\n $15,\n $16,\n NOW(),\n NOW()\n )\n ON CONFLICT (hash) DO NOTHING\n " + }, + "806b82a9effd885ba537a2a1c7d7227120a8279db1875d26ccae5ee0785f46a9": { + "describe": { + "columns": [ + { + "name": "attempts", + "ordinal": 0, + "type_info": "Int2" + } + ], + "nullable": [ + false + ], + "parameters": { + "Left": [ + "Int8" + ] + } + }, + "query": "\n SELECT\n attempts\n FROM\n node_aggregation_witness_jobs_fri\n WHERE\n id = $1\n " + }, + "8182690d0326b820d23fba49d391578db18c29cdca85b8b6aad86fe2a9bf6bbe": { + "describe": { + "columns": [ + { + "name": "l1_batch_number", + "ordinal": 0, + "type_info": "Int8" + }, + { + "name": "circuit_id", + "ordinal": 1, + "type_info": "Int2" + }, + { + "name": "depth", + "ordinal": 2, + "type_info": "Int4" + } + ], + "nullable": [ + false, + false, + false + ], + "parameters": { + "Left": [] + } + }, + "query": "\n UPDATE node_aggregation_witness_jobs_fri\n SET\n status = 'queued'\n WHERE\n (l1_batch_number, circuit_id, depth) IN (\n SELECT\n prover_jobs_fri.l1_batch_number,\n prover_jobs_fri.circuit_id,\n prover_jobs_fri.depth\n FROM\n prover_jobs_fri\n JOIN node_aggregation_witness_jobs_fri nawj ON prover_jobs_fri.l1_batch_number = nawj.l1_batch_number\n AND prover_jobs_fri.circuit_id = nawj.circuit_id\n AND prover_jobs_fri.depth = nawj.depth\n WHERE\n nawj.status = 'waiting_for_proofs'\n AND prover_jobs_fri.status = 'successful'\n AND prover_jobs_fri.aggregation_round = 2\n GROUP BY\n prover_jobs_fri.l1_batch_number,\n prover_jobs_fri.circuit_id,\n prover_jobs_fri.depth,\n nawj.number_of_dependent_jobs\n HAVING\n COUNT(*) = nawj.number_of_dependent_jobs\n )\n RETURNING\n l1_batch_number,\n circuit_id,\n depth;\n " + }, + "81869cb392e9fcbb71ceaa857af77b39429d56072f63b3530c576fb31d7a56f9": { + "describe": { + "columns": [], + "nullable": [], + "parameters": { + "Left": [ + "ByteaArray", + "ByteaArray", + "ByteaArray", + "ByteaArray", + "ByteaArray" + ] + } + }, + "query": "\n INSERT INTO\n storage (hashed_key, address, key, value, tx_hash, created_at, updated_at)\n SELECT\n u.hashed_key,\n u.address,\n u.key,\n u.value,\n u.tx_hash,\n NOW(),\n NOW()\n FROM\n UNNEST($1::bytea[], $2::bytea[], $3::bytea[], $4::bytea[], $5::bytea[]) AS u (hashed_key, address, key, value, tx_hash)\n ON CONFLICT (hashed_key) DO\n UPDATE\n SET\n tx_hash = excluded.tx_hash,\n value = excluded.value,\n updated_at = NOW()\n " + }, + "83134807aee4b6154a1aee4f76dd989d5b4637a97f815b84ace70587acc95e7c": { + "describe": { + "columns": [], + "nullable": [], + "parameters": { + "Left": [ + "Int8", + "TextArray", + "Text" + ] + } + }, + "query": "\n INSERT INTO\n snapshots (\n l1_batch_number,\n storage_logs_filepaths,\n factory_deps_filepath,\n created_at,\n updated_at\n )\n VALUES\n ($1, $2, $3, NOW(), NOW())\n " + }, + "831f7bec105541bd3ff9bcf6940d6b6b9d558224ad2d8ed079a68c7e339ded6b": { + "describe": { + "columns": [ + { + "name": "l1_batch_number?", + "ordinal": 0, + "type_info": "Int8" + } + ], + "nullable": [ + null + ], + "parameters": { + "Left": [] + } + }, + "query": "\n SELECT\n MIN(l1_batch_number) AS \"l1_batch_number?\"\n FROM\n (\n SELECT\n MIN(l1_batch_number) AS \"l1_batch_number\"\n FROM\n prover_jobs\n WHERE\n status = 'successful'\n OR aggregation_round < 3\n GROUP BY\n l1_batch_number\n HAVING\n MAX(aggregation_round) < 3\n ) AS inn\n " + }, + "83a931ceddf34e1c760649d613f534014b9ab9ca7725e14fb17aa050d9f35eb8": { + "describe": { + "columns": [ + { + "name": "base_fee_per_gas", + "ordinal": 0, + "type_info": "Numeric" + } + ], + "nullable": [ + false + ], + "parameters": { + "Left": [ + "Int8", "Int8" ] } }, - "query": "SELECT number, timestamp, is_finished, l1_tx_count, l2_tx_count, fee_account_address, bloom, priority_ops_onchain_data, hash, parent_hash, commitment, compressed_write_logs, compressed_contracts, eth_prove_tx_id, eth_commit_tx_id, eth_execute_tx_id, merkle_root_hash, l2_to_l1_logs, l2_to_l1_messages, used_contract_hashes, compressed_initial_writes, compressed_repeated_writes, l2_l1_compressed_messages, l2_l1_merkle_root, l1_gas_price, l2_fair_gas_price, rollup_last_leaf_index, zkporter_is_available, bootloader_code_hash, default_aa_code_hash, base_fee_per_gas, aux_data_hash, pass_through_data_hash, meta_parameters_hash, protocol_version, compressed_state_diffs, system_logs, events_queue_commitment, bootloader_initial_content_commitment FROM l1_batches LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number WHERE eth_prove_tx_id IS NOT NULL AND eth_execute_tx_id IS NULL ORDER BY number LIMIT $1" + "query": "\n SELECT\n base_fee_per_gas\n FROM\n miniblocks\n WHERE\n number <= $1\n ORDER BY\n number DESC\n LIMIT\n $2\n " }, - "9051cc1a715e152afdd0c19739c76666b1a9b134e17601ef9fdf3dec5d2fc561": { + "852aa5fe1c3b2dfe875cd4adf0d19a00c170cf7725d95dd6eb8b753fa5facec8": { "describe": { "columns": [ { - "name": "number", + "name": "hash", "ordinal": 0, - "type_info": "Int8" + "type_info": "Bytea" }, { - "name": "timestamp", + "name": "is_priority", "ordinal": 1, - "type_info": "Int8" + "type_info": "Bool" }, { - "name": "is_finished", + "name": "full_fee", "ordinal": 2, - "type_info": "Bool" + "type_info": "Numeric" }, { - "name": "l1_tx_count", + "name": "layer_2_tip_fee", "ordinal": 3, - "type_info": "Int4" + "type_info": "Numeric" }, { - "name": "l2_tx_count", + "name": "initiator_address", "ordinal": 4, - "type_info": "Int4" + "type_info": "Bytea" }, { - "name": "fee_account_address", + "name": "nonce", "ordinal": 5, - "type_info": "Bytea" + "type_info": "Int8" }, { - "name": "bloom", + "name": "signature", "ordinal": 6, "type_info": "Bytea" }, { - "name": "priority_ops_onchain_data", + "name": "input", "ordinal": 7, - "type_info": "ByteaArray" + "type_info": "Bytea" }, { - "name": "hash", + "name": "data", "ordinal": 8, - "type_info": "Bytea" + "type_info": "Jsonb" }, { - "name": "parent_hash", + "name": "received_at", "ordinal": 9, - "type_info": "Bytea" + "type_info": "Timestamp" }, { - "name": "commitment", + "name": "priority_op_id", "ordinal": 10, - "type_info": "Bytea" + "type_info": "Int8" }, { - "name": "compressed_write_logs", + "name": "l1_batch_number", "ordinal": 11, - "type_info": "Bytea" + "type_info": "Int8" }, { - "name": "compressed_contracts", + "name": "index_in_block", "ordinal": 12, - "type_info": "Bytea" + "type_info": "Int4" }, { - "name": "eth_prove_tx_id", + "name": "error", "ordinal": 13, - "type_info": "Int4" + "type_info": "Varchar" }, { - "name": "eth_commit_tx_id", + "name": "gas_limit", "ordinal": 14, - "type_info": "Int4" + "type_info": "Numeric" }, { - "name": "eth_execute_tx_id", + "name": "gas_per_storage_limit", "ordinal": 15, - "type_info": "Int4" + "type_info": "Numeric" }, { - "name": "merkle_root_hash", + "name": "gas_per_pubdata_limit", "ordinal": 16, - "type_info": "Bytea" + "type_info": "Numeric" }, { - "name": "l2_to_l1_logs", + "name": "tx_format", "ordinal": 17, - "type_info": "ByteaArray" + "type_info": "Int4" }, { - "name": "l2_to_l1_messages", + "name": "created_at", "ordinal": 18, - "type_info": "ByteaArray" + "type_info": "Timestamp" }, { - "name": "used_contract_hashes", + "name": "updated_at", "ordinal": 19, - "type_info": "Jsonb" + "type_info": "Timestamp" }, { - "name": "compressed_initial_writes", + "name": "execution_info", "ordinal": 20, - "type_info": "Bytea" + "type_info": "Jsonb" }, { - "name": "compressed_repeated_writes", + "name": "contract_address", "ordinal": 21, "type_info": "Bytea" }, { - "name": "l2_l1_compressed_messages", + "name": "in_mempool", "ordinal": 22, - "type_info": "Bytea" + "type_info": "Bool" }, { - "name": "l2_l1_merkle_root", + "name": "l1_block_number", "ordinal": 23, - "type_info": "Bytea" + "type_info": "Int4" }, { - "name": "l1_gas_price", + "name": "value", "ordinal": 24, - "type_info": "Int8" + "type_info": "Numeric" }, { - "name": "l2_fair_gas_price", + "name": "paymaster", "ordinal": 25, - "type_info": "Int8" + "type_info": "Bytea" }, { - "name": "rollup_last_leaf_index", + "name": "paymaster_input", "ordinal": 26, - "type_info": "Int8" + "type_info": "Bytea" }, { - "name": "zkporter_is_available", + "name": "max_fee_per_gas", "ordinal": 27, - "type_info": "Bool" + "type_info": "Numeric" }, { - "name": "bootloader_code_hash", + "name": "max_priority_fee_per_gas", "ordinal": 28, - "type_info": "Bytea" + "type_info": "Numeric" }, { - "name": "default_aa_code_hash", + "name": "effective_gas_price", "ordinal": 29, - "type_info": "Bytea" + "type_info": "Numeric" }, { - "name": "base_fee_per_gas", + "name": "miniblock_number", "ordinal": 30, - "type_info": "Numeric" + "type_info": "Int8" }, { - "name": "aux_data_hash", + "name": "l1_batch_tx_index", "ordinal": 31, - "type_info": "Bytea" + "type_info": "Int4" }, { - "name": "pass_through_data_hash", + "name": "refunded_gas", "ordinal": 32, - "type_info": "Bytea" + "type_info": "Int8" }, { - "name": "meta_parameters_hash", + "name": "l1_tx_mint", "ordinal": 33, - "type_info": "Bytea" + "type_info": "Numeric" }, { - "name": "protocol_version", + "name": "l1_tx_refund_recipient", "ordinal": 34, - "type_info": "Int4" - }, - { - "name": "compressed_state_diffs", - "ordinal": 35, - "type_info": "Bytea" - }, - { - "name": "system_logs", - "ordinal": 36, - "type_info": "ByteaArray" - }, - { - "name": "events_queue_commitment", - "ordinal": 37, "type_info": "Bytea" }, { - "name": "bootloader_initial_content_commitment", - "ordinal": 38, - "type_info": "Bytea" + "name": "upgrade_id", + "ordinal": 35, + "type_info": "Int4" } ], "nullable": [ false, false, + true, + true, false, - false, - false, - false, + true, + true, + true, false, false, true, @@ -7409,20 +7576,14 @@ true, true, true, - true, false, false, false, true, - true, - true, + false, true, false, false, - true, - true, - true, - true, false, true, true, @@ -7431,25 +7592,27 @@ true, false, true, + true, true ], "parameters": { "Left": [ "Int8", - "Int8", - "Int8" + "Numeric", + "Numeric", + "Int4" ] } }, - "query": "SELECT number, timestamp, is_finished, l1_tx_count, l2_tx_count, fee_account_address, bloom, priority_ops_onchain_data, hash, parent_hash, commitment, compressed_write_logs, compressed_contracts, eth_prove_tx_id, eth_commit_tx_id, eth_execute_tx_id, merkle_root_hash, l2_to_l1_logs, l2_to_l1_messages, used_contract_hashes, compressed_initial_writes, compressed_repeated_writes, l2_l1_compressed_messages, l2_l1_merkle_root, l1_gas_price, l2_fair_gas_price, rollup_last_leaf_index, zkporter_is_available, bootloader_code_hash, default_aa_code_hash, base_fee_per_gas, aux_data_hash, pass_through_data_hash, meta_parameters_hash, protocol_version, compressed_state_diffs, system_logs, events_queue_commitment, bootloader_initial_content_commitment FROM l1_batches LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number WHERE number BETWEEN $1 AND $2 ORDER BY number LIMIT $3" + "query": "\n UPDATE transactions\n SET\n in_mempool = TRUE\n FROM\n (\n SELECT\n hash\n FROM\n (\n SELECT\n hash\n FROM\n transactions\n WHERE\n miniblock_number IS NULL\n AND in_mempool = FALSE\n AND error IS NULL\n AND (\n is_priority = TRUE\n OR (\n max_fee_per_gas >= $2\n AND gas_per_pubdata_limit >= $3\n )\n )\n AND tx_format != $4\n ORDER BY\n is_priority DESC,\n priority_op_id,\n received_at\n LIMIT\n $1\n ) AS subquery1\n ORDER BY\n hash\n ) AS subquery2\n WHERE\n transactions.hash = subquery2.hash\n RETURNING\n transactions.*\n " }, - "91db60cc4f98ebcaef1435342607da0a86fe16e20a696cb81a569772d5d5ae88": { + "8625ca45ce76b8c8633d390e35e0c5f885240d99ea69140a4636b00469d08497": { "describe": { "columns": [ { - "name": "value", + "name": "tx_hash", "ordinal": 0, - "type_info": "Bytea" + "type_info": "Text" } ], "nullable": [ @@ -7457,80 +7620,102 @@ ], "parameters": { "Left": [ - "Bytea", - "Int8" + "Int4" ] } }, - "query": "\n SELECT value\n FROM storage_logs\n WHERE storage_logs.hashed_key = $1 AND storage_logs.miniblock_number <= $2\n ORDER BY storage_logs.miniblock_number DESC, storage_logs.operation_number DESC\n LIMIT 1\n " + "query": "\n SELECT\n tx_hash\n FROM\n eth_txs_history\n WHERE\n eth_tx_id = $1\n AND confirmed_at IS NOT NULL\n " }, - "944c38995043e7b11e6633beb68b5479059ff27b26fd2df171a3d9650f070547": { + "877d20634068170326ab5801b69c70aff49e60b7def3d93b9206e650c259168b": { "describe": { "columns": [ { - "name": "id", + "name": "timestamp", "ordinal": 0, "type_info": "Int8" - }, + } + ], + "nullable": [ + false + ], + "parameters": { + "Left": [] + } + }, + "query": "\n SELECT\n timestamp\n FROM\n l1_batches\n WHERE\n eth_execute_tx_id IS NULL\n AND number > 0\n ORDER BY\n number\n LIMIT\n 1\n " + }, + "878c9cdfd69ad8988d049041edd63595237a0c54f67b8c669dfbb4fca32757e4": { + "describe": { + "columns": [ { - "name": "status", - "ordinal": 1, - "type_info": "Text" - }, + "name": "l2_address", + "ordinal": 0, + "type_info": "Bytea" + } + ], + "nullable": [ + false + ], + "parameters": { + "Left": [] + } + }, + "query": "\n SELECT\n l2_address\n FROM\n tokens\n " + }, + "88c629334e30bb9f5c81c858aa51af63b86e8da6d908d48998012231e1d66a60": { + "describe": { + "columns": [ { - "name": "attempts", - "ordinal": 2, - "type_info": "Int2" + "name": "timestamp", + "ordinal": 0, + "type_info": "Int8" + }, + { + "name": "virtual_blocks", + "ordinal": 1, + "type_info": "Int8" } ], "nullable": [ - false, false, false ], "parameters": { "Left": [ - "Interval", - "Int2" + "Int8", + "Int8" ] } }, - "query": "\n UPDATE leaf_aggregation_witness_jobs_fri\n SET status = 'queued', updated_at = now(), processing_started_at = now()\n WHERE (status = 'in_progress' AND processing_started_at <= now() - $1::interval AND attempts < $2)\n OR (status = 'failed' AND attempts < $2)\n RETURNING id, status, attempts\n " + "query": "\n SELECT\n timestamp,\n virtual_blocks\n FROM\n miniblocks\n WHERE\n number BETWEEN $1 AND $2\n ORDER BY\n number\n " }, - "9554593134830bc197e95f3a7e69844839bfe31bf567934ddbab760017710e39": { + "8903ba5db3f87851c12da133573b4207b69cc48b4ba648e797211631be612b69": { "describe": { "columns": [ { - "name": "bytecode", + "name": "bytecode_hash", "ordinal": 0, "type_info": "Bytea" }, { - "name": "data?", + "name": "bytecode", "ordinal": 1, - "type_info": "Jsonb" - }, - { - "name": "contract_address?", - "ordinal": 2, "type_info": "Bytea" } ], "nullable": [ false, - false, - true + false ], "parameters": { "Left": [ - "Bytea", - "Bytea" + "Int8" ] } }, - "query": "SELECT factory_deps.bytecode, transactions.data as \"data?\", transactions.contract_address as \"contract_address?\" FROM ( SELECT * FROM storage_logs WHERE storage_logs.hashed_key = $1 ORDER BY miniblock_number DESC, operation_number DESC LIMIT 1 ) storage_logs JOIN factory_deps ON factory_deps.bytecode_hash = storage_logs.value LEFT JOIN transactions ON transactions.hash = storage_logs.tx_hash WHERE storage_logs.value != $2" + "query": "\n SELECT\n bytecode_hash,\n bytecode\n FROM\n factory_deps\n INNER JOIN miniblocks ON miniblocks.number = factory_deps.miniblock_number\n WHERE\n miniblocks.l1_batch_number = $1\n " }, - "957ceda740ffb36740acf1e3fbacf76a2ea7422dd9d76a38d745113359e4b7a6": { + "894665c2c467bd1aaeb331b112c567e2667c63a033baa6b427bd8a0898c08bf2": { "describe": { "columns": [ { @@ -7548,444 +7733,297 @@ ] } }, - "query": "SELECT protocol_version FROM l1_batches WHERE number = $1" + "query": "\n SELECT\n protocol_version\n FROM\n miniblocks\n WHERE\n number = $1\n " }, - "96623dfb2cb9efa255a54d87d61f748aebaf4e75ee09c05d04535d8c97a95d88": { + "8a773618c9df11217467222c9117d6868fbf88ee21d8868a7d133e7cebb3d20e": { "describe": { "columns": [ { - "name": "count!", + "name": "successful_limit!", "ordinal": 0, "type_info": "Int8" + }, + { + "name": "queued_limit!", + "ordinal": 1, + "type_info": "Int8" + }, + { + "name": "max_block!", + "ordinal": 2, + "type_info": "Int8" } ], "nullable": [ + null, + null, null ], "parameters": { - "Left": [ - "Bytea" - ] + "Left": [] } }, - "query": "SELECT COUNT(*) as \"count!\" FROM contracts_verification_info WHERE address = $1" + "query": "\n SELECT\n (\n SELECT\n l1_batch_number\n FROM\n prover_jobs\n WHERE\n status NOT IN ('successful', 'skipped')\n ORDER BY\n l1_batch_number\n LIMIT\n 1\n ) AS \"successful_limit!\",\n (\n SELECT\n l1_batch_number\n FROM\n prover_jobs\n WHERE\n status <> 'queued'\n ORDER BY\n l1_batch_number DESC\n LIMIT\n 1\n ) AS \"queued_limit!\",\n (\n SELECT\n MAX(l1_batch_number) AS \"max!\"\n FROM\n prover_jobs\n ) AS \"max_block!\"\n " }, - "96b1cd2bb6861064b633d597a4a09d279dbc7bcd7a810a7270da3d7941af0fff": { + "8a7a57ca3d4d65da3e0877c003902c690c33686c889d318b1d64bdd7fa6374db": { "describe": { "columns": [ { - "name": "count!", + "name": "l1_block_number", "ordinal": 0, - "type_info": "Int8" + "type_info": "Int4" } ], "nullable": [ - null + true ], "parameters": { - "Left": [ - "Bytea", - "Bytea" - ] - } - }, - "query": "SELECT COUNT(*) as \"count!\" FROM (SELECT * FROM storage_logs WHERE storage_logs.hashed_key = $1 ORDER BY storage_logs.miniblock_number DESC, storage_logs.operation_number DESC LIMIT 1) sl WHERE sl.value != $2" - }, - "96f6d06a49646f93ba1918080ef1efba868d506c6b51ede981e610f1b57bf88b": { - "describe": { - "columns": [], - "nullable": [], - "parameters": { - "Left": [ - "ByteaArray" - ] + "Left": [] } }, - "query": "DELETE FROM storage WHERE hashed_key = ANY($1)" + "query": "\n SELECT\n l1_block_number\n FROM\n transactions\n WHERE\n priority_op_id IS NOT NULL\n ORDER BY\n priority_op_id DESC\n LIMIT\n 1\n " }, - "97d81c27885fda4390ebc9789c6169cb94a449f583f7819ec74286fb0d9f81d5": { + "8b9e5d525c026de97c0a732b1adc8dc4bd57e32dfefe1017acba9a15fc14b895": { "describe": { "columns": [ { - "name": "number", + "name": "hashed_key", "ordinal": 0, - "type_info": "Int8" - }, - { - "name": "timestamp", - "ordinal": 1, - "type_info": "Int8" - }, - { - "name": "is_finished", - "ordinal": 2, - "type_info": "Bool" - }, - { - "name": "l1_tx_count", - "ordinal": 3, - "type_info": "Int4" - }, - { - "name": "l2_tx_count", - "ordinal": 4, - "type_info": "Int4" - }, - { - "name": "fee_account_address", - "ordinal": 5, - "type_info": "Bytea" - }, - { - "name": "bloom", - "ordinal": 6, - "type_info": "Bytea" - }, - { - "name": "priority_ops_onchain_data", - "ordinal": 7, - "type_info": "ByteaArray" - }, - { - "name": "hash", - "ordinal": 8, - "type_info": "Bytea" - }, - { - "name": "parent_hash", - "ordinal": 9, - "type_info": "Bytea" - }, - { - "name": "commitment", - "ordinal": 10, - "type_info": "Bytea" - }, - { - "name": "compressed_write_logs", - "ordinal": 11, - "type_info": "Bytea" - }, - { - "name": "compressed_contracts", - "ordinal": 12, - "type_info": "Bytea" - }, - { - "name": "eth_prove_tx_id", - "ordinal": 13, - "type_info": "Int4" - }, - { - "name": "eth_commit_tx_id", - "ordinal": 14, - "type_info": "Int4" - }, - { - "name": "eth_execute_tx_id", - "ordinal": 15, - "type_info": "Int4" - }, - { - "name": "merkle_root_hash", - "ordinal": 16, - "type_info": "Bytea" - }, - { - "name": "l2_to_l1_logs", - "ordinal": 17, - "type_info": "ByteaArray" - }, - { - "name": "l2_to_l1_messages", - "ordinal": 18, - "type_info": "ByteaArray" - }, - { - "name": "used_contract_hashes", - "ordinal": 19, - "type_info": "Jsonb" - }, - { - "name": "compressed_initial_writes", - "ordinal": 20, - "type_info": "Bytea" - }, - { - "name": "compressed_repeated_writes", - "ordinal": 21, - "type_info": "Bytea" - }, - { - "name": "l2_l1_compressed_messages", - "ordinal": 22, "type_info": "Bytea" }, { - "name": "l2_l1_merkle_root", - "ordinal": 23, + "name": "value", + "ordinal": 1, "type_info": "Bytea" }, { - "name": "l1_gas_price", - "ordinal": 24, - "type_info": "Int8" - }, - { - "name": "l2_fair_gas_price", - "ordinal": 25, - "type_info": "Int8" - }, - { - "name": "rollup_last_leaf_index", - "ordinal": 26, + "name": "index", + "ordinal": 2, "type_info": "Int8" - }, - { - "name": "zkporter_is_available", - "ordinal": 27, - "type_info": "Bool" - }, - { - "name": "bootloader_code_hash", - "ordinal": 28, - "type_info": "Bytea" - }, - { - "name": "default_aa_code_hash", - "ordinal": 29, - "type_info": "Bytea" - }, - { - "name": "base_fee_per_gas", - "ordinal": 30, - "type_info": "Numeric" - }, - { - "name": "aux_data_hash", - "ordinal": 31, - "type_info": "Bytea" - }, - { - "name": "pass_through_data_hash", - "ordinal": 32, - "type_info": "Bytea" - }, - { - "name": "meta_parameters_hash", - "ordinal": 33, - "type_info": "Bytea" - }, - { - "name": "protocol_version", - "ordinal": 34, - "type_info": "Int4" - }, - { - "name": "system_logs", - "ordinal": 35, - "type_info": "ByteaArray" - }, + } + ], + "nullable": [ + false, + false, + false + ], + "parameters": { + "Left": [ + "Int8", + "Bytea", + "Bytea" + ] + } + }, + "query": "\n SELECT\n storage_logs.hashed_key,\n storage_logs.value,\n initial_writes.index\n FROM\n storage_logs\n INNER JOIN initial_writes ON storage_logs.hashed_key = initial_writes.hashed_key\n WHERE\n storage_logs.miniblock_number = $1\n AND storage_logs.hashed_key >= $2::bytea\n AND storage_logs.hashed_key <= $3::bytea\n ORDER BY\n storage_logs.hashed_key\n " + }, + "8f5e89ccadd4ea1da7bfe9793a1cbb724af0f0216433a70f19d784e3f2afbc9f": { + "describe": { + "columns": [ { - "name": "compressed_state_diffs", - "ordinal": 36, - "type_info": "Bytea" - }, + "name": "protocol_version", + "ordinal": 0, + "type_info": "Int4" + } + ], + "nullable": [ + true + ], + "parameters": { + "Left": [ + "Int8" + ] + } + }, + "query": "\n SELECT\n protocol_version\n FROM\n witness_inputs_fri\n WHERE\n l1_batch_number = $1\n " + }, + "90f7657bae05c4bad6902c6bfb1b8ba0b771cb45573aca81db254f6bcfc17c77": { + "describe": { + "columns": [ { - "name": "events_queue_commitment", - "ordinal": 37, - "type_info": "Bytea" - }, + "name": "nonce", + "ordinal": 0, + "type_info": "Int8" + } + ], + "nullable": [ + false + ], + "parameters": { + "Left": [] + } + }, + "query": "\n SELECT\n nonce\n FROM\n eth_txs\n ORDER BY\n id DESC\n LIMIT\n 1\n " + }, + "9334df89c9562d4b35611b8e5ffb17305343df99ebc55f240278b5c4e63f89f5": { + "describe": { + "columns": [ { - "name": "bootloader_initial_content_commitment", - "ordinal": 38, + "name": "value", + "ordinal": 0, "type_info": "Bytea" } ], "nullable": [ - false, - false, - false, - false, - false, - false, - false, - false, - true, - true, - true, - true, - true, - true, - true, - true, - true, - false, - false, - false, - true, - true, - true, - true, - false, - false, - true, - true, - true, - true, - false, - true, - true, - true, - true, - false, - true, - true, - true + false ], "parameters": { "Left": [ - "Int8" + "Bytea" ] } }, - "query": "SELECT number, timestamp, is_finished, l1_tx_count, l2_tx_count, fee_account_address, bloom, priority_ops_onchain_data, hash, parent_hash, commitment, compressed_write_logs, compressed_contracts, eth_prove_tx_id, eth_commit_tx_id, eth_execute_tx_id, merkle_root_hash, l2_to_l1_logs, l2_to_l1_messages, used_contract_hashes, compressed_initial_writes, compressed_repeated_writes, l2_l1_compressed_messages, l2_l1_merkle_root, l1_gas_price, l2_fair_gas_price, rollup_last_leaf_index, zkporter_is_available, bootloader_code_hash, default_aa_code_hash, base_fee_per_gas, aux_data_hash, pass_through_data_hash, meta_parameters_hash, protocol_version, system_logs, compressed_state_diffs, events_queue_commitment, bootloader_initial_content_commitment FROM l1_batches LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number WHERE number = $1" + "query": "\n SELECT\n value\n FROM\n storage\n WHERE\n hashed_key = $1\n " }, - "987fcbbd716648c7c368462643f13d8001d5c6d197add90613ae21d21fdef79b": { + "95ea0522a3eff6c0d2d0b1c58fd2767e112b95f4d103c27acd6f7ede108bd300": { "describe": { "columns": [], "nullable": [], "parameters": { "Left": [ - "Text", - "Int8" + "Int8", + "Int4", + "Int4" ] } }, - "query": "UPDATE prover_jobs_fri SET status = $1, updated_at = now() WHERE id = $2" + "query": "\n UPDATE eth_txs\n SET\n gas_used = $1,\n confirmed_eth_tx_history_id = $2\n WHERE\n id = $3\n " }, - "98c81ee6f73859c6cd6ba54ab438c900dda646b70a700f936e5218d9ba3bd0ec": { + "966dddc881bfe6fd94b56f587424125a2633ddb6abaa129f2b12389140d83c3f": { "describe": { "columns": [ { - "name": "l1_batch_number!", + "name": "recursion_scheduler_level_vk_hash", "ordinal": 0, - "type_info": "Int8" + "type_info": "Bytea" }, { - "name": "circuit_id", + "name": "recursion_node_level_vk_hash", "ordinal": 1, - "type_info": "Int2" + "type_info": "Bytea" }, { - "name": "aggregation_round", + "name": "recursion_leaf_level_vk_hash", "ordinal": 2, - "type_info": "Int2" + "type_info": "Bytea" + }, + { + "name": "recursion_circuits_set_vks_hash", + "ordinal": 3, + "type_info": "Bytea" } ], "nullable": [ - null, + false, + false, false, false ], "parameters": { - "Left": [] + "Left": [ + "Int4" + ] } }, - "query": "\n SELECT MIN(l1_batch_number) as \"l1_batch_number!\", circuit_id, aggregation_round\n FROM prover_jobs_fri\n WHERE status IN('queued', 'in_gpu_proof', 'in_progress', 'failed')\n GROUP BY circuit_id, aggregation_round\n " + "query": "\n SELECT\n recursion_scheduler_level_vk_hash,\n recursion_node_level_vk_hash,\n recursion_leaf_level_vk_hash,\n recursion_circuits_set_vks_hash\n FROM\n protocol_versions\n WHERE\n id = $1\n " }, - "9970bb69f5ca9ab9f103e1547eb40c1d4f5dd3a540ff6f1b9724821350c9501a": { + "96c8383b5f6480b00a266908a0dbc0dbdc64f250432ed638cacb65a9e5a0d462": { "describe": { "columns": [ { - "name": "id", + "name": "number", "ordinal": 0, "type_info": "Int8" }, { - "name": "l1_batch_number", + "name": "l1_tx_count", "ordinal": 1, - "type_info": "Int8" + "type_info": "Int4" }, { - "name": "circuit_type", + "name": "l2_tx_count", "ordinal": 2, - "type_info": "Text" + "type_info": "Int4" }, { - "name": "prover_input", + "name": "timestamp", "ordinal": 3, - "type_info": "Bytea" + "type_info": "Int8" }, { - "name": "status", + "name": "is_finished", "ordinal": 4, - "type_info": "Text" + "type_info": "Bool" }, { - "name": "error", + "name": "fee_account_address", "ordinal": 5, - "type_info": "Text" + "type_info": "Bytea" }, { - "name": "processing_started_at", + "name": "l2_to_l1_logs", "ordinal": 6, - "type_info": "Timestamp" + "type_info": "ByteaArray" }, { - "name": "created_at", + "name": "l2_to_l1_messages", "ordinal": 7, - "type_info": "Timestamp" + "type_info": "ByteaArray" }, { - "name": "updated_at", + "name": "bloom", "ordinal": 8, - "type_info": "Timestamp" + "type_info": "Bytea" }, { - "name": "time_taken", + "name": "priority_ops_onchain_data", "ordinal": 9, - "type_info": "Time" + "type_info": "ByteaArray" }, { - "name": "aggregation_round", + "name": "used_contract_hashes", "ordinal": 10, - "type_info": "Int4" + "type_info": "Jsonb" }, { - "name": "result", + "name": "base_fee_per_gas", "ordinal": 11, - "type_info": "Bytea" + "type_info": "Numeric" }, { - "name": "sequence_number", + "name": "l1_gas_price", "ordinal": 12, - "type_info": "Int4" + "type_info": "Int8" }, { - "name": "attempts", + "name": "l2_fair_gas_price", "ordinal": 13, - "type_info": "Int4" + "type_info": "Int8" }, { - "name": "circuit_input_blob_url", + "name": "bootloader_code_hash", "ordinal": 14, - "type_info": "Text" + "type_info": "Bytea" }, { - "name": "proccesed_by", + "name": "default_aa_code_hash", "ordinal": 15, - "type_info": "Text" + "type_info": "Bytea" }, { - "name": "is_blob_cleaned", + "name": "protocol_version", "ordinal": 16, - "type_info": "Bool" + "type_info": "Int4" }, { - "name": "protocol_version", + "name": "compressed_state_diffs", "ordinal": 17, - "type_info": "Int4" + "type_info": "Bytea" + }, + { + "name": "system_logs", + "ordinal": 18, + "type_info": "ByteaArray" } ], "nullable": [ @@ -7994,285 +8032,147 @@ false, false, false, - true, - true, false, false, false, false, - true, false, false, - true, - true, false, - true - ], - "parameters": { - "Left": [ - "Int4Array" - ] - } - }, - "query": "\n UPDATE prover_jobs\n SET status = 'in_progress', attempts = attempts + 1,\n updated_at = now(), processing_started_at = now()\n WHERE id = (\n SELECT id\n FROM prover_jobs\n WHERE status = 'queued'\n AND protocol_version = ANY($1)\n ORDER BY aggregation_round DESC, l1_batch_number ASC, id ASC\n LIMIT 1\n FOR UPDATE\n SKIP LOCKED\n )\n RETURNING prover_jobs.*\n " - }, - "99d331d233d357302ab0cc7e3269ef9e414f0c3111785212660f471e3b4f6a04": { - "describe": { - "columns": [], - "nullable": [], - "parameters": { - "Left": [ - "ByteaArray", - "Int4Array", - "ByteaArray", - "ByteaArray", - "NumericArray", - "NumericArray", - "NumericArray", - "NumericArray", - "Int4Array", - "Int4Array", - "VarcharArray", - "NumericArray", - "JsonbArray", - "ByteaArray", - "JsonbArray", - "Int8Array", - "NumericArray", - "ByteaArray", - "ByteaArray", - "ByteaArray", - "Int8" - ] - } - }, - "query": "\n UPDATE transactions\n SET \n hash = data_table.hash,\n signature = data_table.signature,\n gas_limit = data_table.gas_limit,\n max_fee_per_gas = data_table.max_fee_per_gas,\n max_priority_fee_per_gas = data_table.max_priority_fee_per_gas,\n gas_per_pubdata_limit = data_table.gas_per_pubdata_limit,\n input = data_table.input,\n data = data_table.data,\n tx_format = data_table.tx_format,\n miniblock_number = $21,\n index_in_block = data_table.index_in_block,\n error = NULLIF(data_table.error, ''),\n effective_gas_price = data_table.effective_gas_price,\n execution_info = data_table.new_execution_info,\n refunded_gas = data_table.refunded_gas,\n value = data_table.value,\n contract_address = data_table.contract_address,\n paymaster = data_table.paymaster,\n paymaster_input = data_table.paymaster_input,\n in_mempool = FALSE,\n updated_at = now()\n FROM\n (\n SELECT data_table_temp.* FROM (\n SELECT\n UNNEST($1::bytea[]) AS initiator_address,\n UNNEST($2::int[]) AS nonce,\n UNNEST($3::bytea[]) AS hash,\n UNNEST($4::bytea[]) AS signature,\n UNNEST($5::numeric[]) AS gas_limit,\n UNNEST($6::numeric[]) AS max_fee_per_gas,\n UNNEST($7::numeric[]) AS max_priority_fee_per_gas,\n UNNEST($8::numeric[]) AS gas_per_pubdata_limit,\n UNNEST($9::int[]) AS tx_format,\n UNNEST($10::integer[]) AS index_in_block,\n UNNEST($11::varchar[]) AS error,\n UNNEST($12::numeric[]) AS effective_gas_price,\n UNNEST($13::jsonb[]) AS new_execution_info,\n UNNEST($14::bytea[]) AS input,\n UNNEST($15::jsonb[]) AS data,\n UNNEST($16::bigint[]) as refunded_gas,\n UNNEST($17::numeric[]) as value,\n UNNEST($18::bytea[]) as contract_address,\n UNNEST($19::bytea[]) as paymaster,\n UNNEST($20::bytea[]) as paymaster_input\n ) AS data_table_temp\n JOIN transactions ON transactions.initiator_address = data_table_temp.initiator_address\n AND transactions.nonce = data_table_temp.nonce\n ORDER BY transactions.hash\n ) AS data_table\n WHERE transactions.initiator_address=data_table.initiator_address\n AND transactions.nonce=data_table.nonce\n " - }, - "9a326e8fb44f8ebfdd26d945b73a054fd6802551594b23687d057a3954e24f33": { - "describe": { - "columns": [ - { - "name": "attempts", - "ordinal": 0, - "type_info": "Int2" - } - ], - "nullable": [ - false - ], - "parameters": { - "Left": [ - "Int8" - ] - } - }, - "query": "SELECT attempts FROM basic_witness_input_producer_jobs WHERE l1_batch_number = $1" - }, - "9b70e9039cdc1a8c8baf9220a9d42a9b1b209ce73f74cccb9e313bcacdc3daf3": { - "describe": { - "columns": [], - "nullable": [], + false, + false, + true, + true, + true, + true, + false + ], "parameters": { - "Left": [ - "Int8", - "Text", - "Int4", - "Bytea", - "Int4", - "Text", - "Int4" - ] + "Left": [] } }, - "query": "\n INSERT INTO prover_jobs (l1_batch_number, circuit_type, sequence_number, prover_input, aggregation_round, circuit_input_blob_url, protocol_version, status, created_at, updated_at)\n VALUES ($1, $2, $3, $4, $5, $6, $7, 'queued', now(), now())\n ON CONFLICT(l1_batch_number, aggregation_round, sequence_number) DO NOTHING\n " + "query": "\n SELECT\n number,\n l1_tx_count,\n l2_tx_count,\n timestamp,\n is_finished,\n fee_account_address,\n l2_to_l1_logs,\n l2_to_l1_messages,\n bloom,\n priority_ops_onchain_data,\n used_contract_hashes,\n base_fee_per_gas,\n l1_gas_price,\n l2_fair_gas_price,\n bootloader_code_hash,\n default_aa_code_hash,\n protocol_version,\n compressed_state_diffs,\n system_logs\n FROM\n l1_batches\n ORDER BY\n number DESC\n LIMIT\n 1\n " }, - "9bf32ea710825c1f0560a7eaa89f8f097ad196755ba82d98a729a2b0d34e1aca": { + "9955b9215096f781442153518c4f0a9676e26f422506545ccc90b7e8a36c8d47": { "describe": { "columns": [ { - "name": "successful_limit!", + "name": "bytecode", "ordinal": 0, - "type_info": "Int8" + "type_info": "Bytea" }, { - "name": "queued_limit!", + "name": "data?", "ordinal": 1, - "type_info": "Int8" + "type_info": "Jsonb" }, { - "name": "max_block!", + "name": "contract_address?", "ordinal": 2, - "type_info": "Int8" + "type_info": "Bytea" } ], "nullable": [ - null, - null, - null + false, + false, + true ], - "parameters": { - "Left": [] - } - }, - "query": "\n SELECT\n (SELECT l1_batch_number\n FROM prover_jobs\n WHERE status NOT IN ('successful', 'skipped')\n ORDER BY l1_batch_number\n LIMIT 1) as \"successful_limit!\",\n \n (SELECT l1_batch_number\n FROM prover_jobs\n WHERE status <> 'queued'\n ORDER BY l1_batch_number DESC\n LIMIT 1) as \"queued_limit!\",\n\n (SELECT MAX(l1_batch_number) as \"max!\" FROM prover_jobs) as \"max_block!\"\n " - }, - "9d28c1be3bda0c4fb37567d4a56730e801f48fbb2abad42ea894ebd8ee40412d": { - "describe": { - "columns": [], - "nullable": [], "parameters": { "Left": [ - "Int8", - "Int2", - "Text", - "Int2", - "Int4", - "Int4", - "Bool", - "Int4" + "Bytea", + "Bytea" ] } }, - "query": "\n INSERT INTO prover_jobs_fri (l1_batch_number, circuit_id, circuit_blob_url, aggregation_round, sequence_number, depth, is_node_final_proof, protocol_version, status, created_at, updated_at)\n VALUES ($1, $2, $3, $4, $5, $6, $7, $8, 'queued', now(), now())\n ON CONFLICT(l1_batch_number, aggregation_round, circuit_id, depth, sequence_number)\n DO UPDATE SET updated_at=now()\n " + "query": "\n SELECT\n factory_deps.bytecode,\n transactions.data AS \"data?\",\n transactions.contract_address AS \"contract_address?\"\n FROM\n (\n SELECT\n *\n FROM\n storage_logs\n WHERE\n storage_logs.hashed_key = $1\n ORDER BY\n miniblock_number DESC,\n operation_number DESC\n LIMIT\n 1\n ) storage_logs\n JOIN factory_deps ON factory_deps.bytecode_hash = storage_logs.value\n LEFT JOIN transactions ON transactions.hash = storage_logs.tx_hash\n WHERE\n storage_logs.value != $2\n " }, - "a074cd2c23434a8e801c2c0b42e63f1657765aceabd6d8a50ef2d2299bba99ab": { + "99acb091650478fe0feb367b1d64561347b81f8931cc2addefa907c9aa9355e6": { "describe": { "columns": [ { "name": "id", "ordinal": 0, - "type_info": "Int8" + "type_info": "Int4" }, { - "name": "l1_batch_number", + "name": "timestamp", "ordinal": 1, "type_info": "Int8" }, { - "name": "circuit_id", + "name": "recursion_scheduler_level_vk_hash", "ordinal": 2, - "type_info": "Int2" + "type_info": "Bytea" }, { - "name": "closed_form_inputs_blob_url", + "name": "recursion_node_level_vk_hash", "ordinal": 3, - "type_info": "Text" + "type_info": "Bytea" }, { - "name": "attempts", + "name": "recursion_leaf_level_vk_hash", "ordinal": 4, - "type_info": "Int2" + "type_info": "Bytea" }, { - "name": "status", + "name": "recursion_circuits_set_vks_hash", "ordinal": 5, - "type_info": "Text" + "type_info": "Bytea" }, { - "name": "error", + "name": "bootloader_code_hash", "ordinal": 6, - "type_info": "Text" + "type_info": "Bytea" }, { - "name": "created_at", + "name": "default_account_code_hash", "ordinal": 7, - "type_info": "Timestamp" + "type_info": "Bytea" }, { - "name": "updated_at", + "name": "verifier_address", "ordinal": 8, - "type_info": "Timestamp" + "type_info": "Bytea" }, { - "name": "processing_started_at", + "name": "upgrade_tx_hash", "ordinal": 9, - "type_info": "Timestamp" + "type_info": "Bytea" }, { - "name": "time_taken", + "name": "created_at", "ordinal": 10, - "type_info": "Time" - }, - { - "name": "is_blob_cleaned", - "ordinal": 11, - "type_info": "Bool" - }, - { - "name": "number_of_basic_circuits", - "ordinal": 12, - "type_info": "Int4" - }, - { - "name": "protocol_version", - "ordinal": 13, - "type_info": "Int4" - }, - { - "name": "picked_by", - "ordinal": 14, - "type_info": "Text" + "type_info": "Timestamp" } ], "nullable": [ false, false, false, - true, false, false, - true, + false, + false, false, false, true, - true, - true, - true, - true, - true + false ], "parameters": { "Left": [ - "Int4Array", - "Text" - ] - } - }, - "query": "\n UPDATE leaf_aggregation_witness_jobs_fri\n SET status = 'in_progress', attempts = attempts + 1,\n updated_at = now(), processing_started_at = now(),\n picked_by = $2\n WHERE id = (\n SELECT id\n FROM leaf_aggregation_witness_jobs_fri\n WHERE status = 'queued'\n AND protocol_version = ANY($1)\n ORDER BY l1_batch_number ASC, id ASC\n LIMIT 1\n FOR UPDATE\n SKIP LOCKED\n )\n RETURNING leaf_aggregation_witness_jobs_fri.*\n " - }, - "a0aa877e052e63b1c3df6fc4432eeb44f7f3930f624e66b034baa1c5d0f8bb30": { - "describe": { - "columns": [], - "nullable": [], - "parameters": { - "Left": [ - "Int8", - { - "Custom": { - "kind": { - "Enum": [ - "Queued", - "ManuallySkipped", - "InProgress", - "Successful", - "Failed" - ] - }, - "name": "basic_witness_input_producer_job_status" - } - } + "Int4" ] } }, - "query": "INSERT INTO basic_witness_input_producer_jobs (l1_batch_number, status, created_at, updated_at) VALUES ($1, $2, now(), now()) ON CONFLICT (l1_batch_number) DO NOTHING" + "query": "\n SELECT\n *\n FROM\n protocol_versions\n WHERE\n id < $1\n ORDER BY\n id DESC\n LIMIT\n 1\n " }, - "a190719309378ee1912ffedd8180c151aacf17c3ca3bfca8563fa404d587edc8": { + "99d9ee2a0d0450acefa0d9b6c031e30606fddf6631c859ab03819ec476bcf005": { "describe": { "columns": [ { - "name": "index", + "name": "hashed_key", "ordinal": 0, - "type_info": "Int8" + "type_info": "Bytea" } ], "nullable": [ @@ -8280,155 +8180,140 @@ ], "parameters": { "Left": [ - "Int8" + "ByteaArray" ] } }, - "query": "\n SELECT index\n FROM initial_writes\n WHERE l1_batch_number <= $1\n ORDER BY l1_batch_number DESC , index DESC \n LIMIT 1;\n " + "query": "\n SELECT\n hashed_key\n FROM\n initial_writes\n WHERE\n hashed_key = ANY ($1)\n " }, - "a19b7137403c5cdf1be5f5122ce4d297ed661fa8bdb3bc91f8a81fe9da47469e": { + "99dd6f04e82585d81ac23bc4871578179e6269c6ff36877cedee264067ccdafc": { "describe": { "columns": [ { - "name": "upgrade_tx_hash", + "name": "l1_batch_number", "ordinal": 0, - "type_info": "Bytea" + "type_info": "Int8" } ], "nullable": [ - true + false ], "parameters": { "Left": [ - "Int4" + { + "Custom": { + "kind": { + "Enum": [ + "Queued", + "ManuallySkipped", + "InProgress", + "Successful", + "Failed" + ] + }, + "name": "basic_witness_input_producer_job_status" + } + }, + { + "Custom": { + "kind": { + "Enum": [ + "Queued", + "ManuallySkipped", + "InProgress", + "Successful", + "Failed" + ] + }, + "name": "basic_witness_input_producer_job_status" + } + }, + { + "Custom": { + "kind": { + "Enum": [ + "Queued", + "ManuallySkipped", + "InProgress", + "Successful", + "Failed" + ] + }, + "name": "basic_witness_input_producer_job_status" + } + }, + "Interval", + "Int2" ] } }, - "query": "\n SELECT upgrade_tx_hash FROM protocol_versions\n WHERE id = $1\n " + "query": "\n UPDATE basic_witness_input_producer_jobs\n SET\n status = $1,\n attempts = attempts + 1,\n updated_at = NOW(),\n processing_started_at = NOW()\n WHERE\n l1_batch_number = (\n SELECT\n l1_batch_number\n FROM\n basic_witness_input_producer_jobs\n WHERE\n status = $2\n OR (\n status = $1\n AND processing_started_at < NOW() - $4::INTERVAL\n )\n OR (\n status = $3\n AND attempts < $5\n )\n ORDER BY\n l1_batch_number ASC\n LIMIT\n 1\n FOR UPDATE\n SKIP LOCKED\n )\n RETURNING\n basic_witness_input_producer_jobs.l1_batch_number\n " }, - "a1a6b52403c1db35c8d83d0a512ac453ecd54b34ec516027d540ee1890b40291": { + "9b90f7a7ffee3cd8439f90a6f79693831e2ab6d6d3c1805df5aa51d76994ec19": { "describe": { "columns": [], "nullable": [], "parameters": { "Left": [ - "Int4", - "Bytea", - "Bytea", - "Bytea", - "Bytea" + "Int8", + "Text", + "Int4" ] } }, - "query": "INSERT INTO prover_fri_protocol_versions (id, recursion_scheduler_level_vk_hash, recursion_node_level_vk_hash, recursion_leaf_level_vk_hash, recursion_circuits_set_vks_hash, created_at) VALUES ($1, $2, $3, $4, $5, now()) ON CONFLICT(id) DO NOTHING" + "query": "\n INSERT INTO\n witness_inputs_fri (\n l1_batch_number,\n merkle_tree_paths_blob_url,\n protocol_version,\n status,\n created_at,\n updated_at\n )\n VALUES\n ($1, $2, $3, 'queued', NOW(), NOW())\n ON CONFLICT (l1_batch_number) DO NOTHING\n " }, - "a39f760d2cd879a78112e57d8611d7099802b03b7cc4933cafb4c47e133ad543": { + "9c0c3e5edce083804f49137eb3b01c0b73dfb30bdb9e11fcbf370d599344f20e": { "describe": { "columns": [ { - "name": "address", - "ordinal": 0, - "type_info": "Bytea" - }, - { - "name": "topic1", - "ordinal": 1, - "type_info": "Bytea" - }, - { - "name": "topic2", - "ordinal": 2, - "type_info": "Bytea" - }, - { - "name": "topic3", - "ordinal": 3, - "type_info": "Bytea" - }, - { - "name": "topic4", - "ordinal": 4, - "type_info": "Bytea" - }, - { - "name": "value", - "ordinal": 5, - "type_info": "Bytea" - }, - { - "name": "block_hash", - "ordinal": 6, - "type_info": "Bytea" - }, - { - "name": "l1_batch_number?", - "ordinal": 7, - "type_info": "Int8" - }, - { - "name": "miniblock_number", - "ordinal": 8, + "name": "count!", + "ordinal": 0, "type_info": "Int8" }, { - "name": "tx_hash", - "ordinal": 9, - "type_info": "Bytea" - }, - { - "name": "tx_index_in_block", - "ordinal": 10, - "type_info": "Int4" - }, - { - "name": "event_index_in_block", - "ordinal": 11, - "type_info": "Int4" + "name": "circuit_type!", + "ordinal": 1, + "type_info": "Text" }, { - "name": "event_index_in_tx", - "ordinal": 12, - "type_info": "Int4" + "name": "status!", + "ordinal": 2, + "type_info": "Text" } ], "nullable": [ - false, - false, - false, - false, - false, - false, null, - null, - false, - false, - false, false, false ], "parameters": { - "Left": [ - "Bytea" - ] + "Left": [] } }, - "query": "\n SELECT\n address, topic1, topic2, topic3, topic4, value,\n Null::bytea as \"block_hash\", Null::bigint as \"l1_batch_number?\",\n miniblock_number, tx_hash, tx_index_in_block,\n event_index_in_block, event_index_in_tx\n FROM events\n WHERE tx_hash = $1\n ORDER BY miniblock_number ASC, event_index_in_block ASC\n " + "query": "\n SELECT\n COUNT(*) AS \"count!\",\n circuit_type AS \"circuit_type!\",\n status AS \"status!\"\n FROM\n prover_jobs\n WHERE\n status <> 'skipped'\n AND status <> 'successful'\n GROUP BY\n circuit_type,\n status\n " }, - "a3d526a5a341618e9784fc81626143a3174709483a527879254ff8e28f210ac3": { + "9c2a5f32c627d3a5c6f1e87b31ce3b0fd67aa1f5f7ea0de673a2fbe1f742db86": { "describe": { - "columns": [], - "nullable": [], + "columns": [ + { + "name": "timestamp", + "ordinal": 0, + "type_info": "Int8" + } + ], + "nullable": [ + false + ], "parameters": { "Left": [ - "Int4", - "Int8", "Int8" ] } }, - "query": "UPDATE l1_batches SET eth_execute_tx_id = $1, updated_at = now() WHERE number BETWEEN $2 AND $3" + "query": "\n SELECT\n timestamp\n FROM\n miniblocks\n WHERE\n number = $1\n " }, - "a42626c162a0600b9c7d22dd0d7997fa70cc95296ecc185ff9ae2e03593b07bf": { + "9cfcde703a48b110791d2ae1103c9317c01d6e35db3b07d0a31f436e7e3c7c40": { "describe": { "columns": [], "nullable": [], @@ -8438,69 +8323,45 @@ ] } }, - "query": "\n UPDATE scheduler_witness_jobs_fri\n SET status='queued'\n WHERE l1_batch_number = $1\n AND status != 'successful'\n AND status != 'in_progress'\n " + "query": "\n UPDATE contract_verification_requests\n SET\n status = 'successful',\n updated_at = NOW()\n WHERE\n id = $1\n " }, - "a4a14eb42b9acca3f93c67e5760ba700c333b5e9a38c132a3060a94c988e7f13": { + "9ef2f43e6201cc00a0e1425a666a36532fee1450733849852dfd20e18ded1f03": { "describe": { - "columns": [ - { - "name": "hash", - "ordinal": 0, - "type_info": "Bytea" - }, - { - "name": "received_at", - "ordinal": 1, - "type_info": "Timestamp" - } - ], - "nullable": [ - false, - false - ], + "columns": [], + "nullable": [], "parameters": { "Left": [ - "Timestamp", + "Text", "Int8" ] } }, - "query": "SELECT transactions.hash, transactions.received_at FROM transactions LEFT JOIN miniblocks ON miniblocks.number = miniblock_number WHERE received_at > $1 ORDER BY received_at ASC LIMIT $2" - }, - "a4f240188c1447f5b6dcef33dfcc9d00b105f62a6b4c3949a825bea979954160": { - "describe": { - "columns": [], - "nullable": [], - "parameters": { - "Left": [] - } - }, - "query": "DELETE FROM basic_witness_input_producer_jobs" + "query": "\n UPDATE scheduler_witness_jobs_fri\n SET\n status = 'failed',\n error = $1,\n updated_at = NOW()\n WHERE\n l1_batch_number = $2\n " }, - "a5115658f3a53462a9570fd6676f1931604d1c17a9a2b5f1475519006aaf03ba": { + "a0e2b2c034cc5f668f0b3d43b94d2e2326d7ace079b095def52723a45b65d3f3": { "describe": { "columns": [], "nullable": [], "parameters": { "Left": [ - "Int8", - "Text" + "Text", + "Int8" ] } }, - "query": "INSERT INTO proof_generation_details (l1_batch_number, status, proof_gen_data_blob_url, created_at, updated_at) VALUES ($1, 'ready_to_be_proven', $2, now(), now()) ON CONFLICT (l1_batch_number) DO NOTHING" + "query": "\n UPDATE witness_inputs_fri\n SET\n status = 'failed',\n error = $1,\n updated_at = NOW()\n WHERE\n l1_batch_number = $2\n " }, - "a7abde5a53248d6e63aa998acac521194231bbe08140c9c4efa548c4f3ae17fa": { + "a2d02b71e3dcc29a2c0c20b44392cfbaf09164aecfa5eed8d7142518ad96abea": { "describe": { "columns": [ { - "name": "max?", + "name": "initial_bootloader_heap_content", "ordinal": 0, - "type_info": "Int4" + "type_info": "Jsonb" } ], "nullable": [ - null + false ], "parameters": { "Left": [ @@ -8508,485 +8369,350 @@ ] } }, - "query": "SELECT MAX(operation_number) as \"max?\" FROM storage_logs WHERE miniblock_number = $1" + "query": "\n SELECT\n initial_bootloader_heap_content\n FROM\n l1_batches\n WHERE\n number = $1\n " }, - "a8b32073a67ad77caab11e73a5cac5aa5b5382648ff95d6787a309eb3f64d434": { + "a4861c931e84d897c27f666de1c5ca679a0459a012899a373c67393d30d12601": { "describe": { "columns": [], "nullable": [], "parameters": { "Left": [ - "Int4" + "Int8Array" ] } }, - "query": "DELETE FROM eth_txs_history WHERE id = $1" + "query": "\n UPDATE scheduler_dependency_tracker_fri\n SET\n status = 'queued'\n WHERE\n l1_batch_number = ANY ($1)\n " }, - "a9b1a31def214f8b1441dc3ab720bd270f3991c9f1c7528256276e176d532163": { + "a48c92f557e5e3a2674ce0dee9cd92f5a547150590b8c221c4065eab11175c7a": { "describe": { "columns": [ { - "name": "l1_batch_number", + "name": "max?", "ordinal": 0, "type_info": "Int8" } ], "nullable": [ - false + null ], "parameters": { - "Left": [ - "Bytea" - ] + "Left": [] } }, - "query": "SELECT l1_batch_number FROM initial_writes WHERE hashed_key = $1" + "query": "\n SELECT\n MAX(INDEX) AS \"max?\"\n FROM\n initial_writes\n " }, - "a9d96d6774af2637173d471f02995652cd4c131c05fdcb3d0e1644bcd1aa1809": { + "a4a4b0bfbe05eac100c42a717e8d7cbb0bc526ebe61a07f735d4ab587058b22c": { "describe": { "columns": [ { - "name": "proof", + "name": "hash", "ordinal": 0, "type_info": "Bytea" - }, - { - "name": "aggregation_result_coords", - "ordinal": 1, - "type_info": "Bytea" } ], "nullable": [ - true, - true + false ], "parameters": { "Left": [ - "Int8", "Int8" ] } }, - "query": "SELECT prover_jobs.result as proof, scheduler_witness_jobs.aggregation_result_coords\n FROM prover_jobs\n INNER JOIN scheduler_witness_jobs\n ON prover_jobs.l1_batch_number = scheduler_witness_jobs.l1_batch_number\n WHERE prover_jobs.l1_batch_number >= $1 AND prover_jobs.l1_batch_number <= $2\n AND prover_jobs.aggregation_round = 3\n AND prover_jobs.status = 'successful'\n " + "query": "\n SELECT\n hash\n FROM\n miniblocks\n WHERE\n number = $1\n " }, - "aa279ce3351b30788711be6c65cb99cb14304ac38f8fed6d332237ffafc7c86b": { + "a4fcd075b68467bb119e49e6b20a69138206dfeb41f3daff4a3eef1de0bed4e4": { "describe": { "columns": [], "nullable": [], "parameters": { "Left": [ - "Text", - "Time", - "Text", + "ByteaArray", + "Int8Array", "Int8" ] } }, - "query": "UPDATE proof_compression_jobs_fri SET status = $1, updated_at = now(), time_taken = $2, l1_proof_blob_url = $3WHERE l1_batch_number = $4" + "query": "\n INSERT INTO\n initial_writes (hashed_key, INDEX, l1_batch_number, created_at, updated_at)\n SELECT\n u.hashed_key,\n u.index,\n $3,\n NOW(),\n NOW()\n FROM\n UNNEST($1::bytea[], $2::BIGINT[]) AS u (hashed_key, INDEX)\n " }, - "aa7ae476aed5979227887891e9be995924588aa10ccba7424d6ce58f811eaa02": { + "a74d029f58801ec05d8d14a3b065d93e391600ab9da2e5fd4e8b139ab3d77583": { "describe": { - "columns": [ - { - "name": "number!", - "ordinal": 0, - "type_info": "Int8" - } - ], - "nullable": [ - null - ], + "columns": [], + "nullable": [], "parameters": { - "Left": [] + "Left": [ + "Text", + "Int8" + ] } }, - "query": "SELECT COALESCE(MAX(number), 0) AS \"number!\" FROM l1_batches WHERE eth_prove_tx_id IS NOT NULL" + "query": "\n UPDATE proof_generation_details\n SET\n status = 'generated',\n proof_blob_url = $1,\n updated_at = NOW()\n WHERE\n l1_batch_number = $2\n " }, - "aacaeff95b9a2988167dde78200d7139ba99edfa30dbcd8a7a57f72efc676477": { + "a83f853b1d63365e88975a926816c6e7b4595f3e7c3dca1d1590de5437187733": { "describe": { - "columns": [ - { - "name": "number", - "ordinal": 0, - "type_info": "Int8" - } - ], - "nullable": [ - false - ], + "columns": [], + "nullable": [], "parameters": { - "Left": [] + "Left": [ + "Bytea", + "Bytea", + "Bytea", + "Bytea", + "Bytea", + "Bytea", + "Bytea", + "Bytea", + "Bool", + "Bytea", + "Int8", + "Bytea", + "Bytea", + "Bytea", + "Bytea", + "Int8" + ] } }, - "query": "SELECT number FROM l1_batches LEFT JOIN eth_txs_history AS commit_tx ON (l1_batches.eth_commit_tx_id = commit_tx.eth_tx_id) WHERE commit_tx.confirmed_at IS NOT NULL ORDER BY number DESC LIMIT 1" + "query": "\n UPDATE l1_batches\n SET\n hash = $1,\n merkle_root_hash = $2,\n commitment = $3,\n default_aa_code_hash = $4,\n compressed_repeated_writes = $5,\n compressed_initial_writes = $6,\n l2_l1_compressed_messages = $7,\n l2_l1_merkle_root = $8,\n zkporter_is_available = $9,\n bootloader_code_hash = $10,\n rollup_last_leaf_index = $11,\n aux_data_hash = $12,\n pass_through_data_hash = $13,\n meta_parameters_hash = $14,\n compressed_state_diffs = $15,\n updated_at = NOW()\n WHERE\n number = $16\n " }, - "ac179b3a4eca421f3151f4f1eb844f2cee16fa1d2a47c910feb8e07d8f8ace6c": { + "a84ee70bec8c03bd51e1c6bad44c9a64904026506914abae2946e5d353d6a604": { "describe": { "columns": [ { "name": "id", "ordinal": 0, "type_info": "Int8" - }, - { - "name": "l1_batch_number", - "ordinal": 1, - "type_info": "Int8" - }, - { - "name": "circuit_id", - "ordinal": 2, - "type_info": "Int2" - }, - { - "name": "aggregation_round", - "ordinal": 3, - "type_info": "Int2" - }, - { - "name": "sequence_number", - "ordinal": 4, - "type_info": "Int4" - }, - { - "name": "depth", - "ordinal": 5, - "type_info": "Int4" - }, - { - "name": "is_node_final_proof", - "ordinal": 6, - "type_info": "Bool" } ], "nullable": [ - false, - false, - false, - false, - false, - false, false ], "parameters": { "Left": [ - "Int2Array", - "Int2Array", - "Int4Array", - "Text" - ] - } - }, - "query": "\n UPDATE prover_jobs_fri\n SET status = 'in_progress', attempts = attempts + 1,\n processing_started_at = now(), updated_at = now(), \n picked_by = $4\n WHERE id = (\n SELECT pj.id\n FROM ( SELECT * FROM unnest($1::smallint[], $2::smallint[]) ) AS tuple (circuit_id, round)\n JOIN LATERAL\n (\n SELECT * FROM prover_jobs_fri AS pj\n WHERE pj.status = 'queued'\n AND pj.protocol_version = ANY($3)\n AND pj.circuit_id = tuple.circuit_id AND pj.aggregation_round = tuple.round\n ORDER BY pj.l1_batch_number ASC, pj.id ASC\n LIMIT 1\n ) AS pj ON true\n ORDER BY pj.l1_batch_number ASC, pj.aggregation_round DESC, pj.id ASC\n LIMIT 1\n FOR UPDATE\n SKIP LOCKED\n )\n RETURNING prover_jobs_fri.id, prover_jobs_fri.l1_batch_number, prover_jobs_fri.circuit_id,\n prover_jobs_fri.aggregation_round, prover_jobs_fri.sequence_number, prover_jobs_fri.depth,\n prover_jobs_fri.is_node_final_proof\n " - }, - "ac35fb205c83d82d78983f4c9b47f56d3c91fbb2c95046555c7d60a9a2ebb446": { - "describe": { - "columns": [], - "nullable": [], - "parameters": { - "Left": [ - "ByteaArray", - "Int8Array", - "Int8" + "Int8", + "Int2" ] } }, - "query": "INSERT INTO initial_writes (hashed_key, index, l1_batch_number, created_at, updated_at) SELECT u.hashed_key, u.index, $3, now(), now() FROM UNNEST($1::bytea[], $2::bigint[]) AS u(hashed_key, index)" + "query": "\n SELECT\n id\n FROM\n prover_jobs_fri\n WHERE\n l1_batch_number = $1\n AND status = 'successful'\n AND aggregation_round = $2\n " }, - "ad11ec3e628ae6c64ac160d8dd689b2f64033f620e17a31469788b3ce4968ad3": { + "a91c23c4d33771122cec2589c6fe2757dbc13be6b30f5840744e5e0569adc66e": { "describe": { "columns": [ { - "name": "id", + "name": "upgrade_tx_hash", "ordinal": 0, - "type_info": "Int4" - }, - { - "name": "eth_tx_id", - "ordinal": 1, - "type_info": "Int4" - }, - { - "name": "tx_hash", - "ordinal": 2, - "type_info": "Text" - }, - { - "name": "created_at", - "ordinal": 3, - "type_info": "Timestamp" - }, - { - "name": "updated_at", - "ordinal": 4, - "type_info": "Timestamp" - }, - { - "name": "base_fee_per_gas", - "ordinal": 5, - "type_info": "Int8" - }, + "type_info": "Bytea" + } + ], + "nullable": [ + true + ], + "parameters": { + "Left": [ + "Int4" + ] + } + }, + "query": "\n SELECT\n upgrade_tx_hash\n FROM\n protocol_versions\n WHERE\n id = $1\n " + }, + "aa91697157517322b0dbb53dca99f41220c51f58a03c61d6b7789eab0504e320": { + "describe": { + "columns": [ { - "name": "priority_fee_per_gas", - "ordinal": 6, + "name": "l1_batch_number", + "ordinal": 0, "type_info": "Int8" }, { - "name": "confirmed_at", - "ordinal": 7, - "type_info": "Timestamp" - }, - { - "name": "signed_raw_tx", - "ordinal": 8, - "type_info": "Bytea" + "name": "circuit_id", + "ordinal": 1, + "type_info": "Int2" }, { - "name": "sent_at_block", - "ordinal": 9, + "name": "depth", + "ordinal": 2, "type_info": "Int4" - }, - { - "name": "sent_at", - "ordinal": 10, - "type_info": "Timestamp" } ], "nullable": [ false, false, - false, - false, - false, - false, - false, - true, - true, - true, - true + false ], "parameters": { - "Left": [ - "Int4" - ] + "Left": [] } }, - "query": "SELECT * FROM eth_txs_history WHERE eth_tx_id = $1 ORDER BY created_at DESC LIMIT 1" + "query": "\n UPDATE node_aggregation_witness_jobs_fri\n SET\n status = 'queued'\n WHERE\n (l1_batch_number, circuit_id, depth) IN (\n SELECT\n prover_jobs_fri.l1_batch_number,\n prover_jobs_fri.circuit_id,\n prover_jobs_fri.depth\n FROM\n prover_jobs_fri\n JOIN node_aggregation_witness_jobs_fri nawj ON prover_jobs_fri.l1_batch_number = nawj.l1_batch_number\n AND prover_jobs_fri.circuit_id = nawj.circuit_id\n AND prover_jobs_fri.depth = nawj.depth\n WHERE\n nawj.status = 'waiting_for_proofs'\n AND prover_jobs_fri.status = 'successful'\n AND prover_jobs_fri.aggregation_round = 1\n AND prover_jobs_fri.depth = 0\n GROUP BY\n prover_jobs_fri.l1_batch_number,\n prover_jobs_fri.circuit_id,\n prover_jobs_fri.depth,\n nawj.number_of_dependent_jobs\n HAVING\n COUNT(*) = nawj.number_of_dependent_jobs\n )\n RETURNING\n l1_batch_number,\n circuit_id,\n depth;\n " }, - "ad495160a947cf1bd7343819e723d18c9332bc95cfc2014ed8d04907eff3896e": { + "aaf4fb97c95a5290fb1620cd868477dcf21955e0921ba648ba2e751dbfc3cb45": { "describe": { "columns": [ { - "name": "l1_batch_number", + "name": "count!", "ordinal": 0, "type_info": "Int8" }, { - "name": "status", + "name": "circuit_id!", "ordinal": 1, - "type_info": "Text" + "type_info": "Int2" }, { - "name": "attempts", + "name": "aggregation_round!", "ordinal": 2, "type_info": "Int2" + }, + { + "name": "status!", + "ordinal": 3, + "type_info": "Text" } ], "nullable": [ + null, false, false, false ], "parameters": { - "Left": [ - "Interval", - "Int2" - ] + "Left": [] } }, - "query": "\n UPDATE scheduler_witness_jobs_fri\n SET status = 'queued', updated_at = now(), processing_started_at = now()\n WHERE (status = 'in_progress' AND processing_started_at <= now() - $1::interval AND attempts < $2)\n OR (status = 'failed' AND attempts < $2)\n RETURNING l1_batch_number, status, attempts\n " + "query": "\n SELECT\n COUNT(*) AS \"count!\",\n circuit_id AS \"circuit_id!\",\n aggregation_round AS \"aggregation_round!\",\n status AS \"status!\"\n FROM\n prover_jobs_fri\n WHERE\n status <> 'skipped'\n AND status <> 'successful'\n GROUP BY\n circuit_id,\n aggregation_round,\n status\n " }, - "ae072f51b65d0b5212264be9a34027922e5aedef7e4741517ad8104bf5aa79e9": { + "ac505ae6cfc744b07b52997db789bdc9efc6b89fc0444caf8271edd7dfe4a3bc": { "describe": { - "columns": [], - "nullable": [], + "columns": [ + { + "name": "id", + "ordinal": 0, + "type_info": "Int4" + } + ], + "nullable": [ + false + ], "parameters": { - "Left": [ - "Int8" - ] + "Left": [] } }, - "query": "DELETE FROM factory_deps WHERE miniblock_number > $1" + "query": "\n SELECT\n id\n FROM\n protocol_versions\n " }, - "aea4e8d1b018836973d252df943a2c1988dd5f3ffc629064b87d25af8cdb8638": { + "ac673a122962b57b0272df2d82a1788feea2fbb5682de09120dd109899510820": { "describe": { "columns": [ { - "name": "l1_batch_number", + "name": "block_batch?", "ordinal": 0, "type_info": "Int8" }, { - "name": "l1_batch_tx_index", + "name": "max_batch?", "ordinal": 1, - "type_info": "Int4" + "type_info": "Int8" } ], "nullable": [ - true, - true + null, + null ], "parameters": { "Left": [ - "Bytea" + "Int8" ] } }, - "query": "SELECT l1_batch_number, l1_batch_tx_index FROM transactions WHERE hash = $1" + "query": "\n SELECT\n (\n SELECT\n l1_batch_number\n FROM\n miniblocks\n WHERE\n number = $1\n ) AS \"block_batch?\",\n (\n SELECT\n MAX(number) + 1\n FROM\n l1_batches\n ) AS \"max_batch?\"\n " }, - "af22ad34bde12b8d25eb85da9939d12b7bed6407d732b868eeaf2916568c8646": { + "ad53e912e68d81628089ae68aaa4154b988ce8ed67af02f4254717a1cdd3da7e": { "describe": { "columns": [], "nullable": [], "parameters": { "Left": [ - "Time", - "Int8" + "Text", + "Int4", + "Int4", + "Text", + "Text" ] } }, - "query": "\n UPDATE scheduler_witness_jobs_fri\n SET status = 'successful', updated_at = now(), time_taken = $1\n WHERE l1_batch_number = $2\n " + "query": "\n UPDATE gpu_prover_queue\n SET\n instance_status = 'available',\n updated_at = NOW(),\n queue_free_slots = $3\n WHERE\n instance_host = $1::TEXT::inet\n AND instance_port = $2\n AND instance_status = 'full'\n AND region = $4\n AND zone = $5\n " }, - "af22b7cc067ac5e9c201514cdf783d61a0802cf788b4d44f8802554afee35bd9": { + "ada54322a28012b1b761f3631c4cd6ca26aa2fa565fcf208b6985f461c1868f2": { "describe": { "columns": [ { - "name": "count!", + "name": "id", "ordinal": 0, - "type_info": "Int8" - } - ], - "nullable": [ - null - ], - "parameters": { - "Left": [] - } - }, - "query": "SELECT COUNT(*) as \"count!\" FROM contract_verification_requests WHERE status = 'queued'" - }, - "af75db6b7e42b73ce62b28a7281e1bfa181ee0c80a85d7d8078831db5dcdb699": { - "describe": { - "columns": [ + "type_info": "Int4" + }, { - "name": "l1_block_number", - "ordinal": 0, + "name": "eth_tx_id", + "ordinal": 1, "type_info": "Int4" } ], "nullable": [ - true + false, + false ], "parameters": { - "Left": [] + "Left": [ + "Text" + ] } }, - "query": "SELECT l1_block_number FROM transactions\n WHERE priority_op_id IS NOT NULL\n ORDER BY priority_op_id DESC\n LIMIT 1" + "query": "\n UPDATE eth_txs_history\n SET\n updated_at = NOW(),\n confirmed_at = NOW()\n WHERE\n tx_hash = $1\n RETURNING\n id,\n eth_tx_id\n " }, - "b11978a1a31a57fe754d08f7bf547c14e5474786700b5ed7445596568d18543a": { + "aeda34b1beadca72e3e600ea9ae63f436a4f16dbeb784d0d28be392ad96b1c49": { "describe": { "columns": [], "nullable": [], "parameters": { "Left": [ - "Int4", "Int4" ] } }, - "query": "UPDATE eth_txs SET confirmed_eth_tx_history_id = $1 WHERE id = $2" + "query": "\n UPDATE eth_txs\n SET\n has_failed = TRUE\n WHERE\n id = $1\n " }, - "b1478907214ad20dddd4f3846fba4b0ddf1fff63ddb3b95c8999635e77c8b863": { + "aefea1f3e87f28791cc547f193a895006e23ec73018f4b4e0a364a741f5c9781": { "describe": { "columns": [ { - "name": "id", + "name": "l1_batch_number", "ordinal": 0, - "type_info": "Int4" - }, - { - "name": "eth_tx_id", - "ordinal": 1, - "type_info": "Int4" - }, - { - "name": "tx_hash", - "ordinal": 2, - "type_info": "Text" - }, - { - "name": "created_at", - "ordinal": 3, - "type_info": "Timestamp" - }, - { - "name": "updated_at", - "ordinal": 4, - "type_info": "Timestamp" - }, - { - "name": "base_fee_per_gas", - "ordinal": 5, - "type_info": "Int8" - }, - { - "name": "priority_fee_per_gas", - "ordinal": 6, "type_info": "Int8" - }, - { - "name": "confirmed_at", - "ordinal": 7, - "type_info": "Timestamp" - }, - { - "name": "signed_raw_tx", - "ordinal": 8, - "type_info": "Bytea" - }, - { - "name": "sent_at_block", - "ordinal": 9, - "type_info": "Int4" - }, - { - "name": "sent_at", - "ordinal": 10, - "type_info": "Timestamp" } ], "nullable": [ - false, - false, - false, - false, - false, - false, - false, - true, - true, - true, true ], "parameters": { "Left": [ - "Int4" + "Int8" + ] + } + }, + "query": "\n SELECT\n l1_batch_number\n FROM\n miniblocks\n WHERE\n number = $1\n " + }, + "af72fabd90eb43fb315f46d7fe9f724216807ffd481cd6f7f19968e42e52b284": { + "describe": { + "columns": [], + "nullable": [], + "parameters": { + "Left": [ + "Int8" ] } }, - "query": "SELECT * FROM eth_txs_history WHERE eth_tx_id = $1 ORDER BY created_at DESC" + "query": "\n UPDATE prover_jobs_fri\n SET\n status = 'sent_to_server',\n updated_at = NOW()\n WHERE\n l1_batch_number = $1\n " }, - "b14997f84d11d7eea89168383195c5579eed1c57bb2b416a749e2863ae6594a5": { + "afc24bd1407dba82cd3dc9e7ee71ac4ab2d73bda6022700aeb0a630a2563a4b4": { "describe": { "columns": [], "nullable": [], @@ -8997,160 +8723,170 @@ ] } }, - "query": "\n UPDATE leaf_aggregation_witness_jobs_fri\n SET status ='failed', error= $1, updated_at = now()\n WHERE id = $2\n " + "query": "\n UPDATE leaf_aggregation_witness_jobs_fri\n SET\n status = 'failed',\n error = $1,\n updated_at = NOW()\n WHERE\n id = $2\n " }, - "b250f4cb646081c8c0296a286d3fd921a1aefb310951a1ea25ec0fc533ed32ab": { + "b17c71983da060f08616e001b42f8dcbcb014b4f808c6232abd9a83354c995ac": { "describe": { "columns": [ { "name": "id", "ordinal": 0, - "type_info": "Int4" - }, - { - "name": "nonce", - "ordinal": 1, "type_info": "Int8" }, { - "name": "raw_tx", - "ordinal": 2, - "type_info": "Bytea" - }, - { - "name": "contract_address", - "ordinal": 3, - "type_info": "Text" - }, - { - "name": "tx_type", - "ordinal": 4, + "name": "status", + "ordinal": 1, "type_info": "Text" }, { - "name": "gas_used", - "ordinal": 5, - "type_info": "Int8" - }, - { - "name": "created_at", - "ordinal": 6, - "type_info": "Timestamp" - }, - { - "name": "updated_at", - "ordinal": 7, - "type_info": "Timestamp" - }, - { - "name": "has_failed", - "ordinal": 8, - "type_info": "Bool" - }, - { - "name": "sent_at_block", - "ordinal": 9, - "type_info": "Int4" - }, - { - "name": "confirmed_eth_tx_history_id", - "ordinal": 10, - "type_info": "Int4" - }, - { - "name": "predicted_gas_cost", - "ordinal": 11, - "type_info": "Int8" + "name": "attempts", + "ordinal": 2, + "type_info": "Int2" } ], "nullable": [ false, false, - false, - false, - false, - true, - false, - false, - false, - true, - true, false ], "parameters": { - "Left": [] + "Left": [ + "Interval", + "Int2" + ] } }, - "query": "SELECT * FROM eth_txs WHERE confirmed_eth_tx_history_id IS NULL AND id <= (SELECT COALESCE(MAX(eth_tx_id), 0) FROM eth_txs_history WHERE sent_at_block IS NOT NULL) ORDER BY id" + "query": "\n UPDATE node_aggregation_witness_jobs_fri\n SET\n status = 'queued',\n updated_at = NOW(),\n processing_started_at = NOW()\n WHERE\n (\n status = 'in_progress'\n AND processing_started_at <= NOW() - $1::INTERVAL\n AND attempts < $2\n )\n OR (\n status = 'failed'\n AND attempts < $2\n )\n RETURNING\n id,\n status,\n attempts\n " }, - "b36acfd014ab3e79b700399cd2663b4e92e14c55278dfd0ba45ee50e7dfffe73": { + "b23ddb16513d69331056b94d466663a9c5ea62ea7c99a77941eb8f05d4454125": { "describe": { "columns": [], "nullable": [], "parameters": { - "Left": [] + "Left": [ + "Int8", + "Int2", + "Text", + "Int4", + "Int4" + ] } }, - "query": "DELETE FROM eth_txs WHERE id >= (SELECT MIN(id) FROM eth_txs WHERE has_failed = TRUE)" + "query": "\n INSERT INTO\n leaf_aggregation_witness_jobs_fri (\n l1_batch_number,\n circuit_id,\n closed_form_inputs_blob_url,\n number_of_basic_circuits,\n protocol_version,\n status,\n created_at,\n updated_at\n )\n VALUES\n ($1, $2, $3, $4, $5, 'waiting_for_proofs', NOW(), NOW())\n ON CONFLICT (l1_batch_number, circuit_id) DO\n UPDATE\n SET\n updated_at = NOW()\n " }, - "b3c0070f22ab78bf148aade48f860934c53130e4c88cdb4670d5f57defedd919": { + "b321c5ba22358cbb1fd9c627f1e7b56187686173327498ac75424593547c19c5": { "describe": { "columns": [ { - "name": "id", + "name": "attempts", "ordinal": 0, - "type_info": "Int8" - }, + "type_info": "Int2" + } + ], + "nullable": [ + false + ], + "parameters": { + "Left": [ + "Int8" + ] + } + }, + "query": "\n SELECT\n attempts\n FROM\n scheduler_witness_jobs_fri\n WHERE\n l1_batch_number = $1\n " + }, + "b33e8da69281efe7750043e409d9871731c41cef01da3d6aaf2c53f7b17c47b2": { + "describe": { + "columns": [ { - "name": "circuit_input_blob_url", - "ordinal": 1, - "type_info": "Text" + "name": "value", + "ordinal": 0, + "type_info": "Bytea" } ], "nullable": [ - false, - true + false ], "parameters": { "Left": [ + "Bytea", "Int8" ] } }, - "query": "\n SELECT id, circuit_input_blob_url FROM prover_jobs\n WHERE status='successful'\n AND circuit_input_blob_url is NOT NULL\n AND updated_at < NOW() - INTERVAL '30 days'\n LIMIT $1;\n " + "query": "\n SELECT\n value\n FROM\n storage_logs\n WHERE\n storage_logs.hashed_key = $1\n AND storage_logs.miniblock_number <= $2\n ORDER BY\n storage_logs.miniblock_number DESC,\n storage_logs.operation_number DESC\n LIMIT\n 1\n " }, - "b4a3c902646725188f7c79ebac992cdce5896fc6fcc9f485c0cba9d90c4c982c": { + "b367ecb1ebee86ec598c4079591f8c12deeca6b8843fe3869cc2b02b30da5de6": { "describe": { "columns": [ { - "name": "id", + "name": "attempts", "ordinal": 0, - "type_info": "Int4" + "type_info": "Int2" + } + ], + "nullable": [ + false + ], + "parameters": { + "Left": [ + "Int8" + ] + } + }, + "query": "\n SELECT\n attempts\n FROM\n proof_compression_jobs_fri\n WHERE\n l1_batch_number = $1\n " + }, + "b3d71dbe14bcd94131b29b64dcb49b6370c211a7fc24ad03a5f0e327f9d18040": { + "describe": { + "columns": [ + { + "name": "attempts", + "ordinal": 0, + "type_info": "Int2" + } + ], + "nullable": [ + false + ], + "parameters": { + "Left": [ + "Int8" + ] + } + }, + "query": "\n SELECT\n attempts\n FROM\n witness_inputs_fri\n WHERE\n l1_batch_number = $1\n " + }, + "b4304b9afb9f838eee1fe95af5fd964d4bb39b9dcd18fb03bc11ce2fb32b7fb3": { + "describe": { + "columns": [ + { + "name": "l1_batch_number", + "ordinal": 0, + "type_info": "Int8" }, { - "name": "nonce", + "name": "scheduler_partial_input_blob_url", "ordinal": 1, - "type_info": "Int8" + "type_info": "Text" }, { - "name": "raw_tx", + "name": "status", "ordinal": 2, - "type_info": "Bytea" + "type_info": "Text" }, { - "name": "contract_address", + "name": "processing_started_at", "ordinal": 3, - "type_info": "Text" + "type_info": "Timestamp" }, { - "name": "tx_type", + "name": "time_taken", "ordinal": 4, - "type_info": "Text" + "type_info": "Time" }, { - "name": "gas_used", + "name": "error", "ordinal": 5, - "type_info": "Int8" + "type_info": "Text" }, { "name": "created_at", @@ -9163,136 +8899,87 @@ "type_info": "Timestamp" }, { - "name": "has_failed", + "name": "attempts", "ordinal": 8, - "type_info": "Bool" + "type_info": "Int2" }, { - "name": "sent_at_block", + "name": "protocol_version", "ordinal": 9, "type_info": "Int4" }, { - "name": "confirmed_eth_tx_history_id", + "name": "picked_by", "ordinal": 10, - "type_info": "Int4" - }, - { - "name": "predicted_gas_cost", - "ordinal": 11, - "type_info": "Int8" + "type_info": "Text" } ], "nullable": [ - false, - false, false, false, false, true, + true, + true, false, false, false, true, - true, - false + true ], "parameters": { "Left": [ - "Int8" + "Int4Array", + "Text" ] } }, - "query": "SELECT * FROM eth_txs WHERE id > (SELECT COALESCE(MAX(eth_tx_id), 0) FROM eth_txs_history) ORDER BY id LIMIT $1" + "query": "\n UPDATE scheduler_witness_jobs_fri\n SET\n status = 'in_progress',\n attempts = attempts + 1,\n updated_at = NOW(),\n processing_started_at = NOW(),\n picked_by = $2\n WHERE\n l1_batch_number = (\n SELECT\n l1_batch_number\n FROM\n scheduler_witness_jobs_fri\n WHERE\n status = 'queued'\n AND protocol_version = ANY ($1)\n ORDER BY\n l1_batch_number ASC\n LIMIT\n 1\n FOR UPDATE\n SKIP LOCKED\n )\n RETURNING\n scheduler_witness_jobs_fri.*\n " }, - "b4c576db7c762103dc6700ded458e996d2e9ef670d7b58b181dbfab02fa426ce": { + "b452354c888bfc19b5f4012582061b86b1abd915739533f9982fea9d8e21b9e9": { "describe": { "columns": [], "nullable": [], "parameters": { "Left": [ - "Bytea", - "Bytea", - "Numeric", - "Numeric", - "Numeric", - "Jsonb", - "Int8", - "Numeric", - "Numeric", - "Bytea", - "Int4", - "Numeric", - "Bytea", - "Bytea", - "Int4", - "Numeric", - "Bytea", - "Timestamp" + "Int8" ] } }, - "query": "\n INSERT INTO transactions\n (\n hash,\n is_priority,\n initiator_address,\n\n gas_limit,\n max_fee_per_gas,\n gas_per_pubdata_limit,\n\n data,\n priority_op_id,\n full_fee,\n layer_2_tip_fee,\n contract_address,\n l1_block_number,\n value,\n\n paymaster,\n paymaster_input,\n tx_format,\n\n l1_tx_mint,\n l1_tx_refund_recipient,\n\n received_at,\n created_at,\n updated_at\n )\n VALUES\n (\n $1, TRUE, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12,\n $13, $14, $15, $16, $17, $18, now(), now()\n )\n ON CONFLICT (hash) DO NOTHING\n " - }, - "b4da918ee3b36b56d95c8834edebe65eb48ebb8270fa1e6ccf73ad354fd71134": { - "describe": { - "columns": [ - { - "name": "l1_address", - "ordinal": 0, - "type_info": "Bytea" - }, - { - "name": "l2_address", - "ordinal": 1, - "type_info": "Bytea" - } - ], - "nullable": [ - false, - false - ], - "parameters": { - "Left": [] - } - }, - "query": "SELECT l1_address, l2_address FROM tokens WHERE well_known = true" + "query": "\n DELETE FROM factory_deps\n WHERE\n miniblock_number > $1\n " }, - "b6f9874059c57e5e59f3021936437e9ff71a68065dfc19c295d806d7a9aafc93": { + "b4794e6a0c2366d5d95ab373c310103263af3ff5cb6c9dc5df59d3cd2a5e56b4": { "describe": { "columns": [], "nullable": [], "parameters": { "Left": [ + "Text", + "Text", "Int4", - "Int8", - "Bytea", - "Bytea", - "Bytea", - "Bytea", - "Bytea" + "Text" ] } }, - "query": "INSERT INTO prover_protocol_versions\n (id, timestamp, recursion_scheduler_level_vk_hash, recursion_node_level_vk_hash,\n recursion_leaf_level_vk_hash, recursion_circuits_set_vks_hash, verifier_address, created_at)\n VALUES ($1, $2, $3, $4, $5, $6, $7, now())\n " + "query": "\n UPDATE gpu_prover_queue_fri\n SET\n instance_status = $1,\n updated_at = NOW()\n WHERE\n instance_host = $2::TEXT::inet\n AND instance_port = $3\n AND zone = $4\n " }, - "b707b6247c76a50bda3be8076aafb77de60cfc5a0cc61c7dd60e4330eabc28d7": { + "b49478150dbc8731c531ef3eddc0c2cfff08e6fef3c3824d20dfdf2d0f73e671": { "describe": { "columns": [ { - "name": "l1_batch_number", + "name": "hash", "ordinal": 0, - "type_info": "Int8" + "type_info": "Bytea" }, { - "name": "factory_deps_filepath", + "name": "number", "ordinal": 1, - "type_info": "Text" + "type_info": "Int8" }, { - "name": "storage_logs_filepaths", + "name": "timestamp", "ordinal": 2, - "type_info": "TextArray" + "type_info": "Int8" } ], "nullable": [ @@ -9301,381 +8988,375 @@ false ], "parameters": { - "Left": [] + "Left": [ + "Int8" + ] } }, - "query": "SELECT l1_batch_number, factory_deps_filepath, storage_logs_filepaths FROM snapshots" + "query": "\n SELECT\n hash,\n number,\n timestamp\n FROM\n miniblocks\n WHERE\n number > $1\n ORDER BY\n number ASC\n " }, - "b944df7af612ec911170a43be846eb2f6e27163b0d3983672de2b8d5d60af640": { + "b4a0444897b60c7061363a48b2b5386a2fd53492f3df05545edbfb0ec0f059d2": { "describe": { - "columns": [ - { - "name": "l1_batch_number", - "ordinal": 0, - "type_info": "Int8" - } - ], - "nullable": [ - false - ], + "columns": [], + "nullable": [], "parameters": { "Left": [ - "Interval" + "Int4", + "Int4" ] } }, - "query": "UPDATE proof_generation_details SET status = 'picked_by_prover', updated_at = now(), prover_taken_at = now() WHERE l1_batch_number = ( SELECT l1_batch_number FROM proof_generation_details WHERE status = 'ready_to_be_proven' OR (status = 'picked_by_prover' AND prover_taken_at < now() - $1::interval) ORDER BY l1_batch_number ASC LIMIT 1 FOR UPDATE SKIP LOCKED ) RETURNING proof_generation_details.l1_batch_number" + "query": "\n UPDATE eth_txs\n SET\n confirmed_eth_tx_history_id = $1\n WHERE\n id = $2\n " }, - "bc4433cdfa499830fe6a6a95759c9fbe343ac25b371c7fa980bfd1b0afc86629": { + "b5fd77f515fe168908cc90e44d0697e36b3c2a997038c30553f7727cdfa17361": { "describe": { - "columns": [ - { - "name": "l1_batch_number", - "ordinal": 0, - "type_info": "Int8" - } - ], - "nullable": [ - false - ], + "columns": [], + "nullable": [], "parameters": { "Left": [ - "Text", - "Text", - "Text" + "Int8", + "ByteaArray", + "Int4Array", + "VarcharArray", + "JsonbArray", + "Int8Array", + "NumericArray" ] } }, - "query": "UPDATE proof_compression_jobs_fri SET status = $1, attempts = attempts + 1, updated_at = now(), processing_started_at = now(), picked_by = $3 WHERE l1_batch_number = ( SELECT l1_batch_number FROM proof_compression_jobs_fri WHERE status = $2 ORDER BY l1_batch_number ASC LIMIT 1 FOR UPDATE SKIP LOCKED ) RETURNING proof_compression_jobs_fri.l1_batch_number" + "query": "\n UPDATE transactions\n SET\n miniblock_number = $1,\n index_in_block = data_table.index_in_block,\n error = NULLIF(data_table.error, ''),\n in_mempool = FALSE,\n execution_info = execution_info || data_table.new_execution_info,\n refunded_gas = data_table.refunded_gas,\n effective_gas_price = data_table.effective_gas_price,\n updated_at = NOW()\n FROM\n (\n SELECT\n UNNEST($2::bytea[]) AS hash,\n UNNEST($3::INTEGER[]) AS index_in_block,\n UNNEST($4::VARCHAR[]) AS error,\n UNNEST($5::jsonb[]) AS new_execution_info,\n UNNEST($6::BIGINT[]) AS refunded_gas,\n UNNEST($7::NUMERIC[]) AS effective_gas_price\n ) AS data_table\n WHERE\n transactions.hash = data_table.hash\n " }, - "be824de76050461afe29dfd229e524bdf113eab3ca24208782c200531db1c940": { + "b678edd9f6ea97b8f086566811f651aa072f030c70a5e6de38843a1d9afdf329": { "describe": { - "columns": [ - { - "name": "id", - "ordinal": 0, - "type_info": "Int8" - } - ], - "nullable": [ - false - ], + "columns": [], + "nullable": [], "parameters": { - "Left": [ - "Int8", - "Int2", - "Int2", - "Int4" + "Left": [ + "Int8", + "Bytea", + "Bytea" ] } }, - "query": "\n SELECT id from prover_jobs_fri\n WHERE l1_batch_number = $1\n AND circuit_id = $2\n AND aggregation_round = $3\n AND depth = $4\n AND status = 'successful'\n ORDER BY sequence_number ASC;\n " + "query": "\n INSERT INTO\n commitments (l1_batch_number, events_queue_commitment, bootloader_initial_content_commitment)\n VALUES\n ($1, $2, $3)\n ON CONFLICT (l1_batch_number) DO NOTHING\n " }, - "bef58e581dd0b658350dcdc15ebf7cf350cf088b60c916a15889e31ee7534907": { + "b75e3d2fecbf5d85e93848b7a35180abbd76956e073432af8d8500327b74e488": { "describe": { "columns": [ { - "name": "bytecode", + "name": "version", "ordinal": 0, - "type_info": "Bytea" - }, - { - "name": "bytecode_hash", - "ordinal": 1, - "type_info": "Bytea" + "type_info": "Text" } ], "nullable": [ - false, false ], "parameters": { "Left": [ - "ByteaArray" + "Text" ] } }, - "query": "SELECT bytecode, bytecode_hash FROM factory_deps WHERE bytecode_hash = ANY($1)" + "query": "\n SELECT\n VERSION\n FROM\n compiler_versions\n WHERE\n compiler = $1\n ORDER BY\n VERSION\n " }, - "c0904ee4179531cfb9d458a17f753085dc2ed957b30a89119d7534112add3876": { + "b7bf6999002dd89dc1224468ca79c9a85e3c24fca1bf87905f7fc68fe2ce3276": { "describe": { "columns": [], "nullable": [], "parameters": { "Left": [ - "Int8", - "Bytea", - "Bytea" + "Int4Array", + "ByteaArray", + "Int8" ] } }, - "query": "UPDATE l1_batches SET commitment = $2, aux_data_hash = $3, updated_at = now() WHERE number = $1" + "query": "\n UPDATE transactions\n SET\n l1_batch_number = $3,\n l1_batch_tx_index = data_table.l1_batch_tx_index,\n updated_at = NOW()\n FROM\n (\n SELECT\n UNNEST($1::INT[]) AS l1_batch_tx_index,\n UNNEST($2::bytea[]) AS hash\n ) AS data_table\n WHERE\n transactions.hash = data_table.hash\n " }, - "c178e1574d2a16cb90bcc5d5333a4f8dd2a69e0c12b4e7e108a8dcc6000669a5": { + "bd51c9d93b103292f5acbdb266ba4b4e2af48907fa9321064ddb24ac02ab17cd": { "describe": { "columns": [ { - "name": "protocol_version", + "name": "number", "ordinal": 0, - "type_info": "Int4" + "type_info": "Int8" + } + ], + "nullable": [ + false + ], + "parameters": { + "Left": [] + } + }, + "query": "\n SELECT\n number\n FROM\n l1_batches\n LEFT JOIN eth_txs_history AS commit_tx ON (l1_batches.eth_commit_tx_id = commit_tx.eth_tx_id)\n WHERE\n commit_tx.confirmed_at IS NOT NULL\n ORDER BY\n number DESC\n LIMIT\n 1\n " + }, + "bd74435dc6dba3f4173858682ee5661d1df4ec053797d75cfd32272be4f485e7": { + "describe": { + "columns": [ + { + "name": "key!", + "ordinal": 0, + "type_info": "Bytea" + }, + { + "name": "value!", + "ordinal": 1, + "type_info": "Bytea" + }, + { + "name": "address!", + "ordinal": 2, + "type_info": "Bytea" + }, + { + "name": "miniblock_number!", + "ordinal": 3, + "type_info": "Int8" + }, + { + "name": "l1_batch_number!", + "ordinal": 4, + "type_info": "Int8" + }, + { + "name": "index", + "ordinal": 5, + "type_info": "Int8" } ], "nullable": [ + true, + true, + true, + true, + true, true ], "parameters": { "Left": [ - "Int8" + "Int8", + "Bytea", + "Bytea" ] } }, - "query": "SELECT protocol_version FROM miniblocks WHERE number = $1" + "query": "\n SELECT\n storage_logs.key AS \"key!\",\n storage_logs.value AS \"value!\",\n storage_logs.address AS \"address!\",\n storage_logs.miniblock_number AS \"miniblock_number!\",\n initial_writes.l1_batch_number AS \"l1_batch_number!\",\n initial_writes.index\n FROM\n (\n SELECT\n hashed_key,\n MAX(ARRAY[miniblock_number, operation_number]::INT[]) AS op\n FROM\n storage_logs\n WHERE\n miniblock_number <= $1\n AND hashed_key >= $2\n AND hashed_key < $3\n GROUP BY\n hashed_key\n ORDER BY\n hashed_key\n ) AS keys\n INNER JOIN storage_logs ON keys.hashed_key = storage_logs.hashed_key\n AND storage_logs.miniblock_number = keys.op[1]\n AND storage_logs.operation_number = keys.op[2]\n INNER JOIN initial_writes ON keys.hashed_key = initial_writes.hashed_key;\n " }, - "c1e5f85be88ef0b6ab81daf8dec2011797086a7ec5aeaffe5665ebf9584bf84a": { + "be16d820c124dba9f4a272f54f0b742349e78e6e4ce3e7c9a0dcf6447eedc6d8": { "describe": { "columns": [ { - "name": "l1_batch_number", + "name": "miniblock_number", "ordinal": 0, "type_info": "Int8" }, { - "name": "scheduler_partial_input_blob_url", + "name": "log_index_in_miniblock", "ordinal": 1, - "type_info": "Text" + "type_info": "Int4" }, { - "name": "status", + "name": "log_index_in_tx", "ordinal": 2, - "type_info": "Text" + "type_info": "Int4" }, { - "name": "processing_started_at", + "name": "tx_hash", "ordinal": 3, - "type_info": "Timestamp" + "type_info": "Bytea" }, { - "name": "time_taken", + "name": "block_hash", "ordinal": 4, - "type_info": "Time" + "type_info": "Bytea" }, { - "name": "error", + "name": "l1_batch_number?", "ordinal": 5, - "type_info": "Text" + "type_info": "Int8" }, { - "name": "created_at", + "name": "shard_id", "ordinal": 6, - "type_info": "Timestamp" + "type_info": "Int4" }, { - "name": "updated_at", + "name": "is_service", "ordinal": 7, - "type_info": "Timestamp" + "type_info": "Bool" }, { - "name": "attempts", + "name": "tx_index_in_miniblock", "ordinal": 8, - "type_info": "Int2" + "type_info": "Int4" }, { - "name": "protocol_version", + "name": "tx_index_in_l1_batch", "ordinal": 9, "type_info": "Int4" }, { - "name": "picked_by", + "name": "sender", "ordinal": 10, - "type_info": "Text" + "type_info": "Bytea" + }, + { + "name": "key", + "ordinal": 11, + "type_info": "Bytea" + }, + { + "name": "value", + "ordinal": 12, + "type_info": "Bytea" } ], "nullable": [ false, false, false, - true, - true, - true, false, + null, + null, false, false, - true, - true + false, + false, + false, + false, + false ], "parameters": { "Left": [ - "Int4Array", - "Text" + "Bytea" ] } }, - "query": "\n UPDATE scheduler_witness_jobs_fri\n SET status = 'in_progress', attempts = attempts + 1,\n updated_at = now(), processing_started_at = now(),\n picked_by = $2\n WHERE l1_batch_number = (\n SELECT l1_batch_number\n FROM scheduler_witness_jobs_fri\n WHERE status = 'queued'\n AND protocol_version = ANY($1)\n ORDER BY l1_batch_number ASC\n LIMIT 1\n FOR UPDATE\n SKIP LOCKED\n )\n RETURNING scheduler_witness_jobs_fri.*\n " + "query": "\n SELECT\n miniblock_number,\n log_index_in_miniblock,\n log_index_in_tx,\n tx_hash,\n NULL::bytea AS \"block_hash\",\n NULL::BIGINT AS \"l1_batch_number?\",\n shard_id,\n is_service,\n tx_index_in_miniblock,\n tx_index_in_l1_batch,\n sender,\n key,\n value\n FROM\n l2_to_l1_logs\n WHERE\n tx_hash = $1\n ORDER BY\n log_index_in_tx ASC\n " }, - "c289a50ec67dcab5a5c84ddfa17b924c1fefe151c887b3f08f54306f1bde47a2": { + "bfb80956a18eabf266f5b5a9d62912d57f8eb2a38bdb7884fc812a2897a3a660": { "describe": { "columns": [ { - "name": "hashed_key?", + "name": "l1_batch_number", "ordinal": 0, - "type_info": "Bytea" + "type_info": "Int8" }, { - "name": "value?", + "name": "status", "ordinal": 1, - "type_info": "Bytea" + "type_info": "Text" }, { - "name": "index", + "name": "attempts", "ordinal": 2, - "type_info": "Int8" + "type_info": "Int2" } ], "nullable": [ - null, - null, - true + false, + false, + false ], "parameters": { "Left": [ - "Int8", - "ByteaArray", - "ByteaArray" - ] - } - }, - "query": "WITH sl AS ( SELECT ( SELECT ARRAY[hashed_key, value] AS kv FROM storage_logs WHERE storage_logs.miniblock_number = $1 AND storage_logs.hashed_key >= u.start_key AND storage_logs.hashed_key <= u.end_key ORDER BY storage_logs.hashed_key LIMIT 1 ) FROM UNNEST($2::bytea[], $3::bytea[]) AS u(start_key, end_key) ) SELECT sl.kv[1] AS \"hashed_key?\", sl.kv[2] AS \"value?\", initial_writes.index FROM sl LEFT OUTER JOIN initial_writes ON initial_writes.hashed_key = sl.kv[1]" - }, - "c2cf96a9eb6893c5ba7d9e5418d9f24084ccd87980cb6ee05de1b3bde5c654bd": { - "describe": { - "columns": [], - "nullable": [], - "parameters": { - "Left": [ - "ByteaArray", - "ByteaArray" + "Interval", + "Int2" ] } }, - "query": "\n INSERT INTO call_traces (tx_hash, call_trace)\n SELECT u.tx_hash, u.call_trace\n FROM UNNEST($1::bytea[], $2::bytea[])\n AS u(tx_hash, call_trace)\n " + "query": "\n UPDATE witness_inputs_fri\n SET\n status = 'queued',\n updated_at = NOW(),\n processing_started_at = NOW()\n WHERE\n (\n status = 'in_progress'\n AND processing_started_at <= NOW() - $1::INTERVAL\n AND attempts < $2\n )\n OR (\n status = 'in_gpu_proof'\n AND processing_started_at <= NOW() - $1::INTERVAL\n AND attempts < $2\n )\n OR (\n status = 'failed'\n AND attempts < $2\n )\n RETURNING\n l1_batch_number,\n status,\n attempts\n " }, - "c3724d96ed4e1c31dd575b911b254ed5a4af4d5b6ad1243c812b37ebde0f6090": { + "bfc84bcf0985446b337467dd1da709dbee508ad6d1cae43e477cf1bef8cb4aa9": { "describe": { "columns": [ { - "name": "storage_refunds", + "name": "hashed_key", "ordinal": 0, - "type_info": "Int8Array" + "type_info": "Bytea" } ], "nullable": [ - true + false ], "parameters": { "Left": [ + "Int8", "Int8" ] } }, - "query": "SELECT storage_refunds FROM l1_batches WHERE number = $1" + "query": "\n SELECT DISTINCT\n hashed_key\n FROM\n storage_logs\n WHERE\n miniblock_number BETWEEN $1 AND $2\n " }, - "c59d052f89ddfc3d2c07be84d6d9837adfbe2cefb10d01e09d31aa5e3364e281": { + "c038cecd8184e5e8d9f498116bff995b654adfe328cb825a44ad36b4bf9ec8f2": { "describe": { "columns": [ { - "name": "number", + "name": "address", "ordinal": 0, - "type_info": "Int8" + "type_info": "Bytea" }, { - "name": "l1_tx_count", + "name": "topic1", "ordinal": 1, - "type_info": "Int4" + "type_info": "Bytea" }, { - "name": "l2_tx_count", + "name": "topic2", "ordinal": 2, - "type_info": "Int4" + "type_info": "Bytea" }, { - "name": "timestamp", + "name": "topic3", "ordinal": 3, - "type_info": "Int8" + "type_info": "Bytea" }, { - "name": "is_finished", + "name": "topic4", "ordinal": 4, - "type_info": "Bool" + "type_info": "Bytea" }, { - "name": "fee_account_address", + "name": "value", "ordinal": 5, "type_info": "Bytea" }, { - "name": "l2_to_l1_logs", + "name": "block_hash", "ordinal": 6, - "type_info": "ByteaArray" + "type_info": "Bytea" }, { - "name": "l2_to_l1_messages", + "name": "l1_batch_number?", "ordinal": 7, - "type_info": "ByteaArray" + "type_info": "Int8" }, { - "name": "bloom", + "name": "miniblock_number", "ordinal": 8, - "type_info": "Bytea" + "type_info": "Int8" }, { - "name": "priority_ops_onchain_data", + "name": "tx_hash", "ordinal": 9, - "type_info": "ByteaArray" + "type_info": "Bytea" }, { - "name": "used_contract_hashes", + "name": "tx_index_in_block", "ordinal": 10, - "type_info": "Jsonb" + "type_info": "Int4" }, { - "name": "base_fee_per_gas", + "name": "event_index_in_block", "ordinal": 11, - "type_info": "Numeric" - }, - { - "name": "l1_gas_price", - "ordinal": 12, - "type_info": "Int8" - }, - { - "name": "l2_fair_gas_price", - "ordinal": 13, - "type_info": "Int8" - }, - { - "name": "bootloader_code_hash", - "ordinal": 14, - "type_info": "Bytea" - }, - { - "name": "default_aa_code_hash", - "ordinal": 15, - "type_info": "Bytea" - }, - { - "name": "protocol_version", - "ordinal": 16, "type_info": "Int4" }, { - "name": "compressed_state_diffs", - "ordinal": 17, - "type_info": "Bytea" - }, - { - "name": "system_logs", - "ordinal": 18, - "type_info": "ByteaArray" + "name": "event_index_in_tx", + "ordinal": 12, + "type_info": "Int4" } ], "nullable": [ @@ -9685,51 +9366,27 @@ false, false, false, + null, + null, false, false, false, false, - false, - false, - false, - false, - true, - true, - true, - true, false ], "parameters": { "Left": [ - "Int8" - ] - } - }, - "query": "SELECT number, l1_tx_count, l2_tx_count, timestamp, is_finished, fee_account_address, l2_to_l1_logs, l2_to_l1_messages, bloom, priority_ops_onchain_data, used_contract_hashes, base_fee_per_gas, l1_gas_price, l2_fair_gas_price, bootloader_code_hash, default_aa_code_hash, protocol_version, compressed_state_diffs, system_logs FROM l1_batches WHERE number = $1" - }, - "c604ee1dd86ac154d67ddb339da5f65ca849887d6a1068623e874f9df00cfdd1": { - "describe": { - "columns": [], - "nullable": [], - "parameters": { - "Left": [ - "Int8", - "ByteaArray", - "Int4Array", - "VarcharArray", - "JsonbArray", - "Int8Array", - "NumericArray" + "Bytea" ] } }, - "query": "\n UPDATE transactions\n SET\n miniblock_number = $1,\n index_in_block = data_table.index_in_block,\n error = NULLIF(data_table.error, ''),\n in_mempool=FALSE,\n execution_info = execution_info || data_table.new_execution_info,\n refunded_gas = data_table.refunded_gas,\n effective_gas_price = data_table.effective_gas_price,\n updated_at = now()\n FROM\n (\n SELECT\n UNNEST($2::bytea[]) AS hash,\n UNNEST($3::integer[]) AS index_in_block,\n UNNEST($4::varchar[]) AS error,\n UNNEST($5::jsonb[]) AS new_execution_info,\n UNNEST($6::bigint[]) as refunded_gas,\n UNNEST($7::numeric[]) as effective_gas_price\n ) AS data_table\n WHERE transactions.hash = data_table.hash\n " + "query": "\n SELECT\n address,\n topic1,\n topic2,\n topic3,\n topic4,\n value,\n NULL::bytea AS \"block_hash\",\n NULL::BIGINT AS \"l1_batch_number?\",\n miniblock_number,\n tx_hash,\n tx_index_in_block,\n event_index_in_block,\n event_index_in_tx\n FROM\n events\n WHERE\n tx_hash = $1\n ORDER BY\n miniblock_number ASC,\n event_index_in_block ASC\n " }, - "c6aadc4ec78e30f5775f7a9f866ad02984b78de3e3d1f34c144a4057ff44ea6a": { + "c03df29f4661fa47c1412bd82ba379f3b2e9ff1bc6e8e38f473fb4950c8e4b77": { "describe": { "columns": [ { - "name": "count", + "name": "count!", "ordinal": 0, "type_info": "Int8" } @@ -9741,22 +9398,45 @@ "Left": [] } }, - "query": "SELECT COUNT(*) FROM eth_txs WHERE has_failed = TRUE" + "query": "\n SELECT\n COUNT(*) AS \"count!\"\n FROM\n contract_verification_requests\n WHERE\n status = 'queued'\n " }, - "c6cdc9ef18fe20ef530b653c0c24c674dd74aef3701bfb5c6db23d649115f1d4": { + "c10cf20825de4d24300c7ec50d4a653852f7e43670076eb2ebcd49542a870539": { + "describe": { + "columns": [], + "nullable": [], + "parameters": { + "Left": [ + "Int8" + ] + } + }, + "query": "\n INSERT INTO\n scheduler_dependency_tracker_fri (l1_batch_number, status, created_at, updated_at)\n VALUES\n ($1, 'waiting_for_proofs', NOW(), NOW())\n ON CONFLICT (l1_batch_number) DO\n UPDATE\n SET\n updated_at = NOW()\n " + }, + "c139df45a977290d1c2c7987fb9c1d66aeaeb6e2d36fddcf96775f01716a8a74": { "describe": { "columns": [], "nullable": [], "parameters": { "Left": [ - "Time", "Int8" ] } }, - "query": "\n UPDATE witness_inputs_fri\n SET status = 'successful', updated_at = now(), time_taken = $1\n WHERE l1_batch_number = $2\n " + "query": "\n DELETE FROM storage_logs\n WHERE\n miniblock_number > $1\n " + }, + "c14837e92dbb02f2fde7109f524432d865852afe0c60e11a2c1800d30599aa61": { + "describe": { + "columns": [], + "nullable": [], + "parameters": { + "Left": [ + "Text" + ] + } + }, + "query": "\n DELETE FROM compiler_versions\n WHERE\n compiler = $1\n " }, - "c8125b30eb64eebfa4500dc623972bf8771a83b218bd18a51e633d4cf4bf8eb3": { + "c192377c08abab9306c5b0844368aa0f8525832cb4075e831c0d4b23c5675b99": { "describe": { "columns": [ { @@ -9776,9 +9456,22 @@ ] } }, - "query": "\n SELECT bytecode FROM (\n SELECT * FROM storage_logs\n WHERE\n storage_logs.hashed_key = $1 AND\n storage_logs.miniblock_number <= $2\n ORDER BY\n storage_logs.miniblock_number DESC, storage_logs.operation_number DESC\n LIMIT 1\n ) t\n JOIN factory_deps ON value = factory_deps.bytecode_hash\n WHERE value != $3\n " + "query": "\n SELECT\n bytecode\n FROM\n (\n SELECT\n *\n FROM\n storage_logs\n WHERE\n storage_logs.hashed_key = $1\n AND storage_logs.miniblock_number <= $2\n ORDER BY\n storage_logs.miniblock_number DESC,\n storage_logs.operation_number DESC\n LIMIT\n 1\n ) t\n JOIN factory_deps ON value = factory_deps.bytecode_hash\n WHERE\n value != $3\n " + }, + "c23d5ff919ade5898c6a912780ae899e360650afccb34f5cc301b5cbac4a3d36": { + "describe": { + "columns": [], + "nullable": [], + "parameters": { + "Left": [ + "Text", + "Int8" + ] + } + }, + "query": "\n UPDATE prover_jobs_fri\n SET\n status = $1,\n updated_at = NOW()\n WHERE\n id = $2\n " }, - "c881cd7018a9f714cdc3388936e363d49bd6ae52467d382d2f2250ab4f11acf9": { + "c36abacc705a2244d423599779e38d60d6e93bcb34fd20422e227714fccbf6b7": { "describe": { "columns": [ { @@ -9790,9 +9483,15 @@ "name": "key", "ordinal": 1, "type_info": "Bytea" + }, + { + "name": "value", + "ordinal": 2, + "type_info": "Bytea" } ], "nullable": [ + false, false, false ], @@ -9802,216 +9501,211 @@ ] } }, - "query": "SELECT address, key FROM protective_reads WHERE l1_batch_number = $1" + "query": "\n SELECT\n address,\n key,\n value\n FROM\n storage_logs\n WHERE\n miniblock_number BETWEEN (\n SELECT\n MIN(number)\n FROM\n miniblocks\n WHERE\n l1_batch_number = $1\n ) AND (\n SELECT\n MAX(number)\n FROM\n miniblocks\n WHERE\n l1_batch_number = $1\n )\n ORDER BY\n miniblock_number,\n operation_number\n " }, - "c891770305cb3aba4021738e60567d977eac54435c871b5178de7c3c96d2f721": { + "c3b76b8030d4b5266242619f091c5cffe6869add3e43c71390a9a921b8ff48c5": { "describe": { "columns": [ { - "name": "usd_price", + "name": "id", "ordinal": 0, - "type_info": "Numeric" - }, - { - "name": "usd_price_updated_at", - "ordinal": 1, - "type_info": "Timestamp" + "type_info": "Int4" } ], "nullable": [ - true, - true + false ], "parameters": { "Left": [ + "Bytea", + "Bytea", + "Bytea", "Bytea" ] } }, - "query": "SELECT usd_price, usd_price_updated_at FROM tokens WHERE l2_address = $1" + "query": "\n SELECT\n id\n FROM\n prover_protocol_versions\n WHERE\n recursion_circuits_set_vks_hash = $1\n AND recursion_leaf_level_vk_hash = $2\n AND recursion_node_level_vk_hash = $3\n AND recursion_scheduler_level_vk_hash = $4\n " }, - "ca0697232d98066834184318985e6960e180c4f5b98b46ca67ab191b66d343bf": { + "c41312e01aa66897552e8be9acc8d43c31ec7441a7f6c5040e120810ebbb72f7": { "describe": { "columns": [], "nullable": [], "parameters": { "Left": [ + "Int8", + "Int2", + "Text", + "Int2", + "Int4", "Int4", + "Bool", "Int4" ] } }, - "query": "UPDATE eth_txs_history SET sent_at_block = $2, sent_at = now() WHERE id = $1 AND sent_at_block IS NULL" + "query": "\n INSERT INTO\n prover_jobs_fri (\n l1_batch_number,\n circuit_id,\n circuit_blob_url,\n aggregation_round,\n sequence_number,\n depth,\n is_node_final_proof,\n protocol_version,\n status,\n created_at,\n updated_at\n )\n VALUES\n ($1, $2, $3, $4, $5, $6, $7, $8, 'queued', NOW(), NOW())\n ON CONFLICT (l1_batch_number, aggregation_round, circuit_id, depth, sequence_number) DO\n UPDATE\n SET\n updated_at = NOW()\n " }, - "ca8fa3521dab5ee985a837572e8625bd5b26bf79f58950698218b28110c29d1f": { + "c5656667e5610ffb33e7b977ac92b7c4d79cbd404e0267794ec203df0cbb169d": { "describe": { - "columns": [], - "nullable": [], + "columns": [ + { + "name": "number!", + "ordinal": 0, + "type_info": "Int8" + } + ], + "nullable": [ + null + ], "parameters": { - "Left": [ - "Text", - "Int4", - "Int4", - "Int2", - "Text", - "Text", - "Int2" - ] + "Left": [] } }, - "query": "\n INSERT INTO gpu_prover_queue (instance_host, instance_port, queue_capacity, queue_free_slots, instance_status, specialized_prover_group_id, region, zone, num_gpu, created_at, updated_at)\n VALUES (cast($1::text as inet), $2, $3, $3, 'available', $4, $5, $6, $7, now(), now())\n ON CONFLICT(instance_host, instance_port, region, zone)\n DO UPDATE SET instance_status='available', queue_capacity=$3, queue_free_slots=$3, specialized_prover_group_id=$4, region=$5, zone=$6, num_gpu=$7, updated_at=now()" + "query": "\n SELECT\n COALESCE(MAX(number), 0) AS \"number!\"\n FROM\n l1_batches\n WHERE\n eth_prove_tx_id IS NOT NULL\n " }, - "cc20350af9e837ae6b6160be65f88e6b675f62e207252f91f2ce7dcaaddb12b1": { + "c5d6e1d5d834409bd793c8ce1fb2c212918b31dabebf08a84efdfe1feee85765": { "describe": { - "columns": [], - "nullable": [], + "columns": [ + { + "name": "l1_batch_number", + "ordinal": 0, + "type_info": "Int8" + } + ], + "nullable": [ + false + ], "parameters": { - "Left": [ - "Int4", - "Int8", - "Bytea", - "Bytea", - "Bytea", - "Bytea", - "Bytea", - "Bytea", - "Bytea", - "Bytea" - ] + "Left": [] } }, - "query": "INSERT INTO protocol_versions (id, timestamp, recursion_scheduler_level_vk_hash, recursion_node_level_vk_hash, recursion_leaf_level_vk_hash, recursion_circuits_set_vks_hash, bootloader_code_hash, default_account_code_hash, verifier_address, upgrade_tx_hash, created_at) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, now())" + "query": "\n UPDATE scheduler_dependency_tracker_fri\n SET\n status = 'queuing'\n WHERE\n l1_batch_number IN (\n SELECT\n l1_batch_number\n FROM\n scheduler_dependency_tracker_fri\n WHERE\n status != 'queued'\n AND circuit_1_final_prover_job_id IS NOT NULL\n AND circuit_2_final_prover_job_id IS NOT NULL\n AND circuit_3_final_prover_job_id IS NOT NULL\n AND circuit_4_final_prover_job_id IS NOT NULL\n AND circuit_5_final_prover_job_id IS NOT NULL\n AND circuit_6_final_prover_job_id IS NOT NULL\n AND circuit_7_final_prover_job_id IS NOT NULL\n AND circuit_8_final_prover_job_id IS NOT NULL\n AND circuit_9_final_prover_job_id IS NOT NULL\n AND circuit_10_final_prover_job_id IS NOT NULL\n AND circuit_11_final_prover_job_id IS NOT NULL\n AND circuit_12_final_prover_job_id IS NOT NULL\n AND circuit_13_final_prover_job_id IS NOT NULL\n )\n RETURNING\n l1_batch_number;\n " }, - "cd2f668e3febead6b8c5c5dacaf95f0840b9c40f6c8585df93b0541f9b5b1548": { + "c689a86a40c882a0d990a17ecc32290b2a47043fc88d4a2232461434a3f4a57d": { "describe": { "columns": [ { - "name": "attempts", + "name": "count!", "ordinal": 0, - "type_info": "Int2" + "type_info": "Int8" + }, + { + "name": "status!", + "ordinal": 1, + "type_info": "Text" } ], "nullable": [ + null, false ], "parameters": { - "Left": [ - "Int8" - ] + "Left": [] } }, - "query": "SELECT attempts FROM proof_compression_jobs_fri WHERE l1_batch_number = $1" + "query": "\n SELECT\n COUNT(*) AS \"count!\",\n status AS \"status!\"\n FROM\n prover_jobs\n GROUP BY\n status\n " }, - "ce3666b149f7fc62a68139a8efb83ed149c7deace17b8968817941763e45a147": { + "c6d523c6ae857022318350a2f210d7eaeeb4549ed59b58f8d984be2a22a80355": { "describe": { - "columns": [], - "nullable": [], + "columns": [ + { + "name": "max", + "ordinal": 0, + "type_info": "Int8" + } + ], + "nullable": [ + null + ], "parameters": { "Left": [ - "Bytea", - "Int8", - "Bytea" + "Numeric" ] } }, - "query": "\n DELETE FROM tokens \n WHERE l2_address IN\n (\n SELECT substring(key, 12, 20) FROM storage_logs \n WHERE storage_logs.address = $1 AND miniblock_number > $2 AND NOT EXISTS (\n SELECT 1 FROM storage_logs as s\n WHERE\n s.hashed_key = storage_logs.hashed_key AND\n (s.miniblock_number, s.operation_number) >= (storage_logs.miniblock_number, storage_logs.operation_number) AND\n s.value = $3\n )\n )\n " + "query": "\n SELECT\n MAX(l1_batches.number)\n FROM\n l1_batches\n JOIN eth_txs ON (l1_batches.eth_commit_tx_id = eth_txs.id)\n JOIN eth_txs_history AS commit_tx ON (eth_txs.confirmed_eth_tx_history_id = commit_tx.id)\n WHERE\n commit_tx.confirmed_at IS NOT NULL\n AND eth_prove_tx_id IS NOT NULL\n AND eth_execute_tx_id IS NULL\n AND EXTRACT(\n epoch\n FROM\n commit_tx.confirmed_at\n ) < $1\n " }, - "cea77fbe02853a7a9b1f7b5ddf2957cb23212ae5ef0f889834d796c35b583542": { + "c706a49ff54f6b424e24d061fe7ac429aac3c030f7e226a1264243d8cdae038d": { "describe": { "columns": [], "nullable": [], "parameters": { "Left": [ + "Text", + "Time", + "Text", "Int8" ] } }, - "query": "DELETE FROM miniblocks WHERE number > $1" + "query": "\n UPDATE proof_compression_jobs_fri\n SET\n status = $1,\n updated_at = NOW(),\n time_taken = $2,\n l1_proof_blob_url = $3\n WHERE\n l1_batch_number = $4\n " }, - "cfd2ce8eb6997b7609090b4400e1bc42db577fdd3758248be69d3b5d9d132bf1": { + "c809f42a221b18a767e9dd0286503d8bd356f2f9cc249cd8b90caa5a8b5918e3": { "describe": { "columns": [ { "name": "count!", "ordinal": 0, "type_info": "Int8" - }, - { - "name": "circuit_type!", - "ordinal": 1, - "type_info": "Text" - }, - { - "name": "status!", - "ordinal": 2, - "type_info": "Text" } ], "nullable": [ - null, - false, - false + null ], "parameters": { - "Left": [] + "Left": [ + "Bytea", + "Bytea" + ] } }, - "query": "\n SELECT COUNT(*) as \"count!\", circuit_type as \"circuit_type!\", status as \"status!\"\n FROM prover_jobs\n WHERE status <> 'skipped' and status <> 'successful' \n GROUP BY circuit_type, status\n " + "query": "\n SELECT\n COUNT(*) AS \"count!\"\n FROM\n (\n SELECT\n *\n FROM\n storage_logs\n WHERE\n storage_logs.hashed_key = $1\n ORDER BY\n storage_logs.miniblock_number DESC,\n storage_logs.operation_number DESC\n LIMIT\n 1\n ) sl\n WHERE\n sl.value != $2\n " }, - "cfeab91d8551e3bba086bc17534ac195a110a2c7f7f829b69e6519977a98267f": { + "ca9d06141265b8524ee28c55569cb21a635037d89ce24dd3ad58ffaadb59594a": { "describe": { "columns": [ { - "name": "protocol_version", + "name": "l1_batch_number", "ordinal": 0, - "type_info": "Int4" + "type_info": "Int8" } ], "nullable": [ - true + false ], "parameters": { "Left": [] } }, - "query": "SELECT protocol_version FROM l1_batches ORDER BY number DESC LIMIT 1" + "query": "\n SELECT\n l1_batch_number\n FROM\n proof_compression_jobs_fri\n WHERE\n status <> 'successful'\n ORDER BY\n l1_batch_number ASC\n LIMIT\n 1\n " }, - "d0ff67e7c59684a0e4409726544cf850dbdbb36d038ebbc6a1c5bf0e76b0358c": { + "cb98d84fc34af1e4a4c2f427c5bb4afd384063ae394a847b26304dd18d490ab4": { "describe": { "columns": [ { - "name": "count!", + "name": "timestamp", "ordinal": 0, "type_info": "Int8" + }, + { + "name": "hash", + "ordinal": 1, + "type_info": "Bytea" } ], "nullable": [ - null + false, + true ], - "parameters": { - "Left": [] - } - }, - "query": "SELECT COUNT(*) as \"count!\" FROM l1_batches" - }, - "d11ff84327058721c3c36bc3371c3139f41e2a2255f64bbc5108c1876848d8bb": { - "describe": { - "columns": [], - "nullable": [], "parameters": { "Left": [ - "Text", - "Text", - "Int4", - "Int4", - "Text", - "Text" + "Int8" ] } }, - "query": "\n UPDATE gpu_prover_queue\n SET instance_status = $1, updated_at = now(), queue_free_slots = $4\n WHERE instance_host = $2::text::inet\n AND instance_port = $3\n AND region = $5\n AND zone = $6\n " + "query": "\n SELECT\n timestamp,\n hash\n FROM\n l1_batches\n WHERE\n number = $1\n " }, - "d12724ae2bda6214b68e19dc290281907383926abf5ad471eef89529908b2673": { + "cd76f54e1b9b4c0cf3044d3b767714e290f88ea1f20092a0278718fecda63caf": { "describe": { "columns": [ { @@ -10020,34 +9714,89 @@ "type_info": "Int8" }, { - "name": "l1_batch_number", - "ordinal": 1, - "type_info": "Int8" + "name": "l1_batch_number", + "ordinal": 1, + "type_info": "Int8" + }, + { + "name": "circuit_type", + "ordinal": 2, + "type_info": "Text" + }, + { + "name": "prover_input", + "ordinal": 3, + "type_info": "Bytea" + }, + { + "name": "status", + "ordinal": 4, + "type_info": "Text" + }, + { + "name": "error", + "ordinal": 5, + "type_info": "Text" + }, + { + "name": "processing_started_at", + "ordinal": 6, + "type_info": "Timestamp" + }, + { + "name": "created_at", + "ordinal": 7, + "type_info": "Timestamp" + }, + { + "name": "updated_at", + "ordinal": 8, + "type_info": "Timestamp" }, { - "name": "circuit_id", - "ordinal": 2, - "type_info": "Int2" + "name": "time_taken", + "ordinal": 9, + "type_info": "Time" }, { "name": "aggregation_round", - "ordinal": 3, - "type_info": "Int2" + "ordinal": 10, + "type_info": "Int4" + }, + { + "name": "result", + "ordinal": 11, + "type_info": "Bytea" }, { "name": "sequence_number", - "ordinal": 4, + "ordinal": 12, "type_info": "Int4" }, { - "name": "depth", - "ordinal": 5, + "name": "attempts", + "ordinal": 13, "type_info": "Int4" }, { - "name": "is_node_final_proof", - "ordinal": 6, + "name": "circuit_input_blob_url", + "ordinal": 14, + "type_info": "Text" + }, + { + "name": "proccesed_by", + "ordinal": 15, + "type_info": "Text" + }, + { + "name": "is_blob_cleaned", + "ordinal": 16, "type_info": "Bool" + }, + { + "name": "protocol_version", + "ordinal": 17, + "type_info": "Int4" } ], "nullable": [ @@ -10056,125 +9805,91 @@ false, false, false, + true, + true, + false, + false, false, - false + false, + true, + false, + false, + true, + true, + false, + true ], "parameters": { "Left": [ - "Int4Array", - "Text" + "TextArray", + "Int4Array" ] } }, - "query": "\n UPDATE prover_jobs_fri\n SET status = 'in_progress', attempts = attempts + 1,\n updated_at = now(), processing_started_at = now(),\n picked_by = $2\n WHERE id = (\n SELECT id\n FROM prover_jobs_fri\n WHERE status = 'queued'\n AND protocol_version = ANY($1)\n ORDER BY aggregation_round DESC, l1_batch_number ASC, id ASC\n LIMIT 1\n FOR UPDATE\n SKIP LOCKED\n )\n RETURNING prover_jobs_fri.id, prover_jobs_fri.l1_batch_number, prover_jobs_fri.circuit_id,\n prover_jobs_fri.aggregation_round, prover_jobs_fri.sequence_number, prover_jobs_fri.depth,\n prover_jobs_fri.is_node_final_proof\n " + "query": "\n UPDATE prover_jobs\n SET\n status = 'in_progress',\n attempts = attempts + 1,\n updated_at = NOW(),\n processing_started_at = NOW()\n WHERE\n id = (\n SELECT\n id\n FROM\n prover_jobs\n WHERE\n circuit_type = ANY ($1)\n AND status = 'queued'\n AND protocol_version = ANY ($2)\n ORDER BY\n aggregation_round DESC,\n l1_batch_number ASC,\n id ASC\n LIMIT\n 1\n FOR UPDATE\n SKIP LOCKED\n )\n RETURNING\n prover_jobs.*\n " }, - "d1c82bd0b3c010569937ad7600760fa0c3aca7c9585bbf9598a5c0515b431b26": { + "ce5779092feb8a3d3e2c5e395783e67f08f2ead5f55bfb6594e50346bf9cf2ef": { "describe": { "columns": [ { - "name": "hashed_key", + "name": "l1_batch_number!", "ordinal": 0, - "type_info": "Bytea" + "type_info": "Int8" }, { - "name": "l1_batch_number", + "name": "circuit_id", "ordinal": 1, - "type_info": "Int8" + "type_info": "Int2" }, { - "name": "index", + "name": "aggregation_round", "ordinal": 2, - "type_info": "Int8" + "type_info": "Int2" } ], "nullable": [ - false, + null, false, false ], "parameters": { - "Left": [ - "ByteaArray" - ] - } - }, - "query": "SELECT hashed_key, l1_batch_number, index FROM initial_writes WHERE hashed_key = ANY($1::bytea[])" - }, - "d6709f3ce8f08f988e10a0e0fb5c06db9488834a85066babaf3d56cf212b4ea0": { - "describe": { - "columns": [], - "nullable": [], - "parameters": { - "Left": [ - "Bytea", - "Varchar", - "Varchar", - "Int4" - ] + "Left": [] } }, - "query": "UPDATE tokens SET token_list_name = $2, token_list_symbol = $3,\n token_list_decimals = $4, well_known = true, updated_at = now()\n WHERE l1_address = $1\n " + "query": "\n SELECT\n MIN(l1_batch_number) AS \"l1_batch_number!\",\n circuit_id,\n aggregation_round\n FROM\n prover_jobs_fri\n WHERE\n status IN ('queued', 'in_gpu_proof', 'in_progress', 'failed')\n GROUP BY\n circuit_id,\n aggregation_round\n " }, - "d7060880fe56fd99af7b7ed3f4c7fb9d0858cee30f44c5197821aae83c6c9666": { + "cea9fe027a6a0ada827f23b48ac32432295b2f7ee40bf13522a6edbd236f1970": { "describe": { "columns": [ { - "name": "id", + "name": "hashed_key!", "ordinal": 0, - "type_info": "Int4" - } - ], - "nullable": [ - false - ], - "parameters": { - "Left": [ - "Bytea", - "Bytea", - "Bytea", - "Bytea" - ] - } - }, - "query": "\n SELECT id\n FROM prover_protocol_versions\n WHERE recursion_circuits_set_vks_hash = $1\n AND recursion_leaf_level_vk_hash = $2\n AND recursion_node_level_vk_hash = $3\n AND recursion_scheduler_level_vk_hash = $4\n " - }, - "d8515595d34dca53e50bbd4ed396f6208e33f596195a5ed02fba9e8364ceb33c": { - "describe": { - "columns": [ + "type_info": "Bytea" + }, { - "name": "bytecode", - "ordinal": 0, + "name": "value?", + "ordinal": 1, "type_info": "Bytea" } ], "nullable": [ - false + null, + null ], "parameters": { "Left": [ - "Bytea" - ] - } - }, - "query": "SELECT bytecode FROM factory_deps WHERE bytecode_hash = $1" - }, - "d8e0bb1a349523077356be101808340eab078979390af7d26c71489b5f303d1b": { - "describe": { - "columns": [], - "nullable": [], - "parameters": { - "Left": [ + "ByteaArray", "Int8" ] } }, - "query": "UPDATE l1_batches SET skip_proof = TRUE WHERE number = $1" + "query": "\n SELECT\n u.hashed_key AS \"hashed_key!\",\n (\n SELECT\n value\n FROM\n storage_logs\n WHERE\n hashed_key = u.hashed_key\n AND miniblock_number <= $2\n ORDER BY\n miniblock_number DESC,\n operation_number DESC\n LIMIT\n 1\n ) AS \"value?\"\n FROM\n UNNEST($1::bytea[]) AS u (hashed_key)\n " }, - "dba127c0f3023586217bfb214c5d3749e8e7ec3edc0c99cfd970332e31f81cb7": { + "d14b52df2cd9f9e484c60ba00383b438f14b68535111cf2cedd363fc646aac99": { "describe": { "columns": [ { - "name": "virtual_blocks", + "name": "timestamp", "ordinal": 0, "type_info": "Int8" } @@ -10183,36 +9898,138 @@ false ], "parameters": { - "Left": [ - "Int8" - ] + "Left": [] } }, - "query": "SELECT virtual_blocks FROM miniblocks WHERE number = $1" + "query": "\n SELECT\n timestamp\n FROM\n l1_batches\n WHERE\n eth_commit_tx_id IS NULL\n AND number > 0\n ORDER BY\n number\n LIMIT\n 1\n " }, - "dc16d0fac093a52480b66dfcb5976fb01e6629e8c982c265f2af1d5000090572": { + "d17221312e645b0287ff9238954512b528e7928087351a32c96b44d538dfb9ee": { "describe": { "columns": [ { - "name": "count", + "name": "id", "ordinal": 0, "type_info": "Int8" + }, + { + "name": "l1_batch_number", + "ordinal": 1, + "type_info": "Int8" + }, + { + "name": "circuit_type", + "ordinal": 2, + "type_info": "Text" + }, + { + "name": "prover_input", + "ordinal": 3, + "type_info": "Bytea" + }, + { + "name": "status", + "ordinal": 4, + "type_info": "Text" + }, + { + "name": "error", + "ordinal": 5, + "type_info": "Text" + }, + { + "name": "processing_started_at", + "ordinal": 6, + "type_info": "Timestamp" + }, + { + "name": "created_at", + "ordinal": 7, + "type_info": "Timestamp" + }, + { + "name": "updated_at", + "ordinal": 8, + "type_info": "Timestamp" + }, + { + "name": "time_taken", + "ordinal": 9, + "type_info": "Time" + }, + { + "name": "aggregation_round", + "ordinal": 10, + "type_info": "Int4" + }, + { + "name": "result", + "ordinal": 11, + "type_info": "Bytea" + }, + { + "name": "sequence_number", + "ordinal": 12, + "type_info": "Int4" + }, + { + "name": "attempts", + "ordinal": 13, + "type_info": "Int4" + }, + { + "name": "circuit_input_blob_url", + "ordinal": 14, + "type_info": "Text" + }, + { + "name": "proccesed_by", + "ordinal": 15, + "type_info": "Text" + }, + { + "name": "is_blob_cleaned", + "ordinal": 16, + "type_info": "Bool" + }, + { + "name": "protocol_version", + "ordinal": 17, + "type_info": "Int4" } ], "nullable": [ - null + false, + false, + false, + false, + false, + true, + true, + false, + false, + false, + false, + true, + false, + false, + true, + true, + false, + true ], "parameters": { - "Left": [] + "Left": [ + "Int4Array" + ] } }, - "query": "SELECT COUNT(miniblocks.number) FROM miniblocks WHERE l1_batch_number IS NULL" + "query": "\n UPDATE prover_jobs\n SET\n status = 'in_progress',\n attempts = attempts + 1,\n updated_at = NOW(),\n processing_started_at = NOW()\n WHERE\n id = (\n SELECT\n id\n FROM\n prover_jobs\n WHERE\n status = 'queued'\n AND protocol_version = ANY ($1)\n ORDER BY\n aggregation_round DESC,\n l1_batch_number ASC,\n id ASC\n LIMIT\n 1\n FOR UPDATE\n SKIP LOCKED\n )\n RETURNING\n prover_jobs.*\n " }, - "dd330bc075a163974c59ec55ecfddd769d05801963b3e0e840e7f11e7bc6d3e9": { + "d3b09cbcddf6238b358d32d57678242aad3e9a47400f6d6837a35f4c54a216b9": { "describe": { "columns": [ { - "name": "l1_batch_number", + "name": "number", "ordinal": 0, "type_info": "Int8" } @@ -10221,48 +10038,88 @@ false ], "parameters": { - "Left": [ - "Int8" - ] + "Left": [] } }, - "query": "SELECT l1_batch_number FROM witness_inputs WHERE length(merkle_tree_paths) <> 0 ORDER BY l1_batch_number DESC LIMIT $1" + "query": "\n SELECT\n number\n FROM\n l1_batches\n LEFT JOIN eth_txs_history AS execute_tx ON (l1_batches.eth_execute_tx_id = execute_tx.eth_tx_id)\n WHERE\n execute_tx.confirmed_at IS NOT NULL\n ORDER BY\n number DESC\n LIMIT\n 1\n " }, - "dd650c06788a1c47b201e768382320fded2b8950ab836b2e5660f15b71dd11a0": { + "d70cfc158e31dd2d5c942d24f81fd17f833fb15b58b0110c7cc566946db98e76": { "describe": { "columns": [ { - "name": "key!", + "name": "block_hash?", "ordinal": 0, "type_info": "Bytea" }, { - "name": "value!", + "name": "address!", "ordinal": 1, "type_info": "Bytea" }, { - "name": "address!", + "name": "topic1!", "ordinal": 2, "type_info": "Bytea" }, { - "name": "miniblock_number!", + "name": "topic2!", "ordinal": 3, - "type_info": "Int8" + "type_info": "Bytea" }, { - "name": "l1_batch_number!", + "name": "topic3!", "ordinal": 4, - "type_info": "Int8" + "type_info": "Bytea" }, { - "name": "index", + "name": "topic4!", "ordinal": 5, + "type_info": "Bytea" + }, + { + "name": "value!", + "ordinal": 6, + "type_info": "Bytea" + }, + { + "name": "miniblock_number!", + "ordinal": 7, "type_info": "Int8" + }, + { + "name": "l1_batch_number?", + "ordinal": 8, + "type_info": "Int8" + }, + { + "name": "tx_hash!", + "ordinal": 9, + "type_info": "Bytea" + }, + { + "name": "tx_index_in_block!", + "ordinal": 10, + "type_info": "Int4" + }, + { + "name": "event_index_in_block!", + "ordinal": 11, + "type_info": "Int4" + }, + { + "name": "event_index_in_tx!", + "ordinal": 12, + "type_info": "Int4" } ], "nullable": [ + true, + true, + true, + true, + true, + true, + true, true, true, true, @@ -10272,264 +10129,271 @@ ], "parameters": { "Left": [ - "Int8", - "Bytea", - "Bytea" + "Int8" ] } }, - "query": "\n SELECT storage_logs.key as \"key!\",\n storage_logs.value as \"value!\",\n storage_logs.address as \"address!\",\n storage_logs.miniblock_number as \"miniblock_number!\",\n initial_writes.l1_batch_number as \"l1_batch_number!\",\n initial_writes.index\n FROM (SELECT hashed_key,\n max(ARRAY [miniblock_number, operation_number]::int[]) AS op\n FROM storage_logs\n WHERE miniblock_number <= $1 and hashed_key >= $2 and hashed_key < $3\n GROUP BY hashed_key\n ORDER BY hashed_key) AS keys\n INNER JOIN storage_logs ON keys.hashed_key = storage_logs.hashed_key\n AND storage_logs.miniblock_number = keys.op[1]\n AND storage_logs.operation_number = keys.op[2]\n INNER JOIN initial_writes ON keys.hashed_key = initial_writes.hashed_key;\n " + "query": "\n WITH\n events_select AS (\n SELECT\n address,\n topic1,\n topic2,\n topic3,\n topic4,\n value,\n miniblock_number,\n tx_hash,\n tx_index_in_block,\n event_index_in_block,\n event_index_in_tx\n FROM\n events\n WHERE\n miniblock_number > $1\n ORDER BY\n miniblock_number ASC,\n event_index_in_block ASC\n )\n SELECT\n miniblocks.hash AS \"block_hash?\",\n address AS \"address!\",\n topic1 AS \"topic1!\",\n topic2 AS \"topic2!\",\n topic3 AS \"topic3!\",\n topic4 AS \"topic4!\",\n value AS \"value!\",\n miniblock_number AS \"miniblock_number!\",\n miniblocks.l1_batch_number AS \"l1_batch_number?\",\n tx_hash AS \"tx_hash!\",\n tx_index_in_block AS \"tx_index_in_block!\",\n event_index_in_block AS \"event_index_in_block!\",\n event_index_in_tx AS \"event_index_in_tx!\"\n FROM\n events_select\n INNER JOIN miniblocks ON events_select.miniblock_number = miniblocks.number\n ORDER BY\n miniblock_number ASC,\n event_index_in_block ASC\n " }, - "dd8aa1c9d4dcea22c9a13cca5ae45e951cf963b0608046b88be40309d7379ec2": { + "d712707e47e143c52330ea6e0513d2839f0f928c06b8020eecec38e895f99b42": { "describe": { - "columns": [], - "nullable": [], + "columns": [ + { + "name": "address", + "ordinal": 0, + "type_info": "Bytea" + }, + { + "name": "key", + "ordinal": 1, + "type_info": "Bytea" + } + ], + "nullable": [ + false, + false + ], "parameters": { "Left": [ - "Varchar", - "Bytea" + "Int8" ] } }, - "query": "UPDATE transactions\n SET error = $1, updated_at = now()\n WHERE hash = $2" + "query": "\n SELECT\n address,\n key\n FROM\n protective_reads\n WHERE\n l1_batch_number = $1\n " }, - "dd8f0bbabcd646457a9174a590c79a45d4f744624a74f79017eacbab6b4f9b0a": { + "d7e8eabd7b43ff62838fbc847e4813d2b2d411bd5faf8306cd48db500532b711": { "describe": { "columns": [ { - "name": "id", + "name": "l1_batch_number", "ordinal": 0, - "type_info": "Int4" + "type_info": "Int8" + }, + { + "name": "status", + "ordinal": 1, + "type_info": "Text" } ], "nullable": [ + false, false ], - "parameters": { - "Left": [] - } - }, - "query": "SELECT id FROM protocol_versions" - }, - "ddd8b105f5e5cf9db40b14ea47e4ba2b3875f89280019464be34f51605833f1b": { - "describe": { - "columns": [], - "nullable": [], "parameters": { "Left": [ "Text", - "Text", - "Int4", "Text" ] } }, - "query": "UPDATE gpu_prover_queue_fri SET instance_status = $1, updated_at = now() WHERE instance_host = $2::text::inet AND instance_port = $3 AND zone = $4\n " + "query": "\n SELECT\n l1_batch_number,\n status\n FROM\n proof_compression_jobs_fri\n WHERE\n l1_batch_number = (\n SELECT\n MIN(l1_batch_number)\n FROM\n proof_compression_jobs_fri\n WHERE\n status = $1\n OR status = $2\n )\n " }, - "de960625b0fa0b766aacab74473fcd0332a3f7dc356648452a6a63189a8b7cc3": { + "d7ed82f0d012f72374edb2ebcec33c83477d65a6f8cb2673f67b3148cd95b436": { "describe": { "columns": [ { - "name": "protocol_version", + "name": "count", "ordinal": 0, - "type_info": "Int4" + "type_info": "Int8" } ], "nullable": [ - true + null ], "parameters": { - "Left": [ - "Int8" - ] - } - }, - "query": "SELECT protocol_version FROM witness_inputs_fri WHERE l1_batch_number = $1" - }, - "deaf3789ac968e299fe0e5a7f1c72494af8ecd664da9c901ec9c0c5e7c29bb65": { - "describe": { - "columns": [], - "nullable": [], - "parameters": { - "Left": [ - "ByteaArray", - "ByteaArray", - "ByteaArray", - "ByteaArray", - "ByteaArray" - ] + "Left": [] } }, - "query": "INSERT INTO storage (hashed_key, address, key, value, tx_hash, created_at, updated_at) SELECT u.hashed_key, u.address, u.key, u.value, u.tx_hash, now(), now() FROM UNNEST ($1::bytea[], $2::bytea[], $3::bytea[], $4::bytea[], $5::bytea[]) AS u(hashed_key, address, key, value, tx_hash) ON CONFLICT (hashed_key) DO UPDATE SET tx_hash = excluded.tx_hash, value = excluded.value, updated_at = now()" + "query": "\n SELECT\n COUNT(*)\n FROM\n eth_txs\n WHERE\n has_failed = TRUE\n " }, - "e05a8c74653afc78c892ddfd08e60ab040d2b2f7c4b5ee110988eac2dd0dd90d": { + "d8e3ee346375e4b6a8b2c73a3827e88abd0f8164c2413dc83c91c29665ca645e": { "describe": { "columns": [ { - "name": "timestamp", + "name": "id", "ordinal": 0, "type_info": "Int8" }, { - "name": "virtual_blocks", + "name": "status", "ordinal": 1, - "type_info": "Int8" + "type_info": "Text" + }, + { + "name": "attempts", + "ordinal": 2, + "type_info": "Int2" } ], "nullable": [ + false, false, false ], + "parameters": { + "Left": [ + "Interval", + "Int2" + ] + } + }, + "query": "\n UPDATE leaf_aggregation_witness_jobs_fri\n SET\n status = 'queued',\n updated_at = NOW(),\n processing_started_at = NOW()\n WHERE\n (\n status = 'in_progress'\n AND processing_started_at <= NOW() - $1::INTERVAL\n AND attempts < $2\n )\n OR (\n status = 'failed'\n AND attempts < $2\n )\n RETURNING\n id,\n status,\n attempts\n " + }, + "d90ed4c0f67c1826f9be90bb5566aba34bfab67494fee578613b03ef7255324d": { + "describe": { + "columns": [], + "nullable": [], "parameters": { "Left": [ "Int8", + "Jsonb" + ] + } + }, + "query": "\n UPDATE miniblocks\n SET\n consensus = $2\n WHERE\n number = $1\n " + }, + "da51a5220c2b964303292592c34e8ee5e54b170de9da863bbdbc79e3f206640b": { + "describe": { + "columns": [], + "nullable": [], + "parameters": { + "Left": [ + "ByteaArray" + ] + } + }, + "query": "\n DELETE FROM storage\n WHERE\n hashed_key = ANY ($1)\n " + }, + "db3e74f0e83ffbf84a6d61e560f2060fbea775dc185f639139fbfd23e4d5f3c6": { + "describe": { + "columns": [], + "nullable": [], + "parameters": { + "Left": [ + "Time", "Int8" ] } }, - "query": "SELECT timestamp, virtual_blocks FROM miniblocks WHERE number BETWEEN $1 AND $2 ORDER BY number" + "query": "\n UPDATE node_aggregation_witness_jobs_fri\n SET\n status = 'successful',\n updated_at = NOW(),\n time_taken = $1\n WHERE\n id = $2\n " }, - "e3ed9f56d316ac95123df3831ce6e6a1552be8e280ac1f3caf5aa1539275905e": { + "dc16d0fac093a52480b66dfcb5976fb01e6629e8c982c265f2af1d5000090572": { "describe": { "columns": [ { - "name": "id", + "name": "count", "ordinal": 0, "type_info": "Int8" } ], "nullable": [ - false + null ], "parameters": { - "Left": [ - "Bytea", - "Text", - "Text", - "Text", - "Text", - "Bool", - "Text", - "Bytea", - "Bool" - ] + "Left": [] } }, - "query": "INSERT INTO contract_verification_requests ( contract_address, source_code, contract_name, zk_compiler_version, compiler_version, optimization_used, optimizer_mode, constructor_arguments, is_system, status, created_at, updated_at )\n VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, 'queued', now(), now()) RETURNING id" + "query": "SELECT COUNT(miniblocks.number) FROM miniblocks WHERE l1_batch_number IS NULL" }, - "e429061bd0f67910ad8676a34f2b89a051a6df3097c8afde81a491c342a10e3a": { + "dc481f59aae632ff6f5fa23f5c5c82627a936f7ea9f6c354eca4bea76fac6b10": { "describe": { "columns": [ { - "name": "l1_batch_number", + "name": "number", "ordinal": 0, "type_info": "Int8" } ], "nullable": [ - false + null ], "parameters": { - "Left": [ - { - "Custom": { - "kind": { - "Enum": [ - "Queued", - "ManuallySkipped", - "InProgress", - "Successful", - "Failed" - ] - }, - "name": "basic_witness_input_producer_job_status" - } - }, - { - "Custom": { - "kind": { - "Enum": [ - "Queued", - "ManuallySkipped", - "InProgress", - "Successful", - "Failed" - ] - }, - "name": "basic_witness_input_producer_job_status" - } - }, - { - "Custom": { - "kind": { - "Enum": [ - "Queued", - "ManuallySkipped", - "InProgress", - "Successful", - "Failed" - ] - }, - "name": "basic_witness_input_producer_job_status" - } - }, - "Interval", - "Int2" - ] + "Left": [] } }, - "query": "UPDATE basic_witness_input_producer_jobs SET status = $1, attempts = attempts + 1, updated_at = now(), processing_started_at = now() WHERE l1_batch_number = ( SELECT l1_batch_number FROM basic_witness_input_producer_jobs WHERE status = $2 OR (status = $1 AND processing_started_at < now() - $4::interval) OR (status = $3 AND attempts < $5) ORDER BY l1_batch_number ASC LIMIT 1 FOR UPDATE SKIP LOCKED ) RETURNING basic_witness_input_producer_jobs.l1_batch_number" + "query": "\n SELECT\n MAX(number) AS \"number\"\n FROM\n l1_batches\n WHERE\n hash IS NOT NULL\n " }, - "e577743852337c926e1566c46f4cbab5e6ab1409921fa8e25c9dfa7dfa03daae": { + "dc764e1636c4e958753c1fd54562e2ca92fdfdf01cfd0b11f5ce24f0458a5e48": { "describe": { "columns": [], "nullable": [], "parameters": { "Left": [ - "Jsonb" + "Bytea", + "Bytea", + "Bytea", + "Bytea", + "Bytea", + "Bytea", + "Bool", + "Bytea", + "Int8", + "Bytea", + "Bytea", + "Bytea", + "Int8" ] } }, - "query": "INSERT INTO consensus_replica_state(fake_key,state) VALUES(true,$1) ON CONFLICT (fake_key) DO UPDATE SET state = excluded.state" + "query": "\n UPDATE l1_batches\n SET\n hash = $1,\n merkle_root_hash = $2,\n compressed_repeated_writes = $3,\n compressed_initial_writes = $4,\n l2_l1_compressed_messages = $5,\n l2_l1_merkle_root = $6,\n zkporter_is_available = $7,\n parent_hash = $8,\n rollup_last_leaf_index = $9,\n pass_through_data_hash = $10,\n meta_parameters_hash = $11,\n compressed_state_diffs = $12,\n updated_at = NOW()\n WHERE\n number = $13\n AND hash IS NULL\n " }, - "e626aa2efb6ba875a12f2b4e37b0ba8052810e73fa5e2d3280f747f7b89b956f": { + "dd55e46dfa5ba3692d9620088a3550b8db817630d1a9341db4a1f453f12e64fb": { "describe": { - "columns": [], - "nullable": [], + "columns": [ + { + "name": "status", + "ordinal": 0, + "type_info": "Text" + }, + { + "name": "error", + "ordinal": 1, + "type_info": "Text" + }, + { + "name": "compilation_errors", + "ordinal": 2, + "type_info": "Jsonb" + } + ], + "nullable": [ + false, + true, + true + ], "parameters": { "Left": [ - "Text", "Int8" ] } }, - "query": "UPDATE proof_generation_details SET status='generated', proof_blob_url = $1, updated_at = now() WHERE l1_batch_number = $2" + "query": "\n SELECT\n status,\n error,\n compilation_errors\n FROM\n contract_verification_requests\n WHERE\n id = $1\n " }, - "e793a57147bbf31334e9471fa2fd82cc138124c2c34df6d10997556f41ae6bc0": { + "dea22358feed1418430505767d03aa4239d3a8be71b47178b4b8fb11fe898b31": { "describe": { "columns": [], "nullable": [], "parameters": { "Left": [ - "Int8", "Int4", - "Int4" + "Int8", + "Int8" ] } }, - "query": "UPDATE eth_txs SET gas_used = $1, confirmed_eth_tx_history_id = $2 WHERE id = $3" + "query": "\n UPDATE l1_batches\n SET\n eth_execute_tx_id = $1,\n updated_at = NOW()\n WHERE\n number BETWEEN $2 AND $3\n " }, - "e8629da5d4269a565f1043969d29df2ccfbebafdce96d58c601860f30d61b4a0": { + "df00e33809768120e395d8f740770a4e629b2a1cde641e74e4e55bb100df809f": { "describe": { "columns": [ { - "name": "count!", + "name": "attempts", "ordinal": 0, - "type_info": "Int8" + "type_info": "Int2" } ], "nullable": [ - null + false ], "parameters": { "Left": [ @@ -10537,594 +10401,711 @@ ] } }, - "query": "SELECT COUNT(*) as \"count!\" FROM miniblocks WHERE number = $1 AND consensus IS NOT NULL" + "query": "\n SELECT\n attempts\n FROM\n prover_jobs_fri\n WHERE\n id = $1\n " }, - "e8988deed66ad9d10be89e89966082aeb920c5dc91eb5fad16bd0d3118708c2e": { + "e073cfdc7a00559994ce04eca15f35d55901fb1e6805f23413ea43e3637540a0": { "describe": { "columns": [ { - "name": "id", + "name": "bytecode", "ordinal": 0, - "type_info": "Int8" + "type_info": "Bytea" }, { - "name": "status", + "name": "bytecode_hash", "ordinal": 1, - "type_info": "Text" - }, - { - "name": "attempts", - "ordinal": 2, - "type_info": "Int4" + "type_info": "Bytea" } ], "nullable": [ - false, false, false ], - "parameters": { - "Left": [ - "Interval", - "Int4" - ] - } - }, - "query": "\n UPDATE prover_jobs\n SET status = 'queued', updated_at = now(), processing_started_at = now()\n WHERE (status = 'in_progress' AND processing_started_at <= now() - $1::interval AND attempts < $2)\n OR (status = 'in_gpu_proof' AND processing_started_at <= now() - $1::interval AND attempts < $2)\n OR (status = 'failed' AND attempts < $2)\n RETURNING id, status, attempts\n " - }, - "e900682a160af90d532da47a1222fc1d7c9962ee8996dbd9b9bb63f13820cf2b": { - "describe": { - "columns": [], - "nullable": [], "parameters": { "Left": [ "ByteaArray" ] } }, - "query": "DELETE FROM transactions WHERE in_mempool = TRUE AND initiator_address = ANY($1)" + "query": "\n SELECT\n bytecode,\n bytecode_hash\n FROM\n factory_deps\n WHERE\n bytecode_hash = ANY ($1)\n " }, - "e9b03a0d79eb40a67eab9bdaac8447fc17922bea89bcc6a89eb8eadf147835fe": { - "describe": { - "columns": [], - "nullable": [], - "parameters": { - "Left": [ - "Int8", - "Text", - "Int4" - ] - } - }, - "query": "\n INSERT INTO scheduler_witness_jobs_fri\n (l1_batch_number, scheduler_partial_input_blob_url, protocol_version, status, created_at, updated_at)\n VALUES ($1, $2, $3, 'waiting_for_proofs', now(), now())\n ON CONFLICT(l1_batch_number)\n DO UPDATE SET updated_at=now()\n " - }, - "ea17481cab38d370e06e7cf8598daa39faf4414152456aab89695e3133477d3e": { + "e3479d12d9dc97001cf03dc42d9b957e92cd375ec33fe16f855f319ffc0b208e": { "describe": { "columns": [ { - "name": "hash", + "name": "l1_batch_number", "ordinal": 0, - "type_info": "Bytea" + "type_info": "Int8" }, { - "name": "is_priority", + "name": "status", "ordinal": 1, - "type_info": "Bool" + "type_info": "Text" }, { - "name": "full_fee", + "name": "circuit_1_final_prover_job_id", "ordinal": 2, - "type_info": "Numeric" + "type_info": "Int8" }, { - "name": "layer_2_tip_fee", + "name": "circuit_2_final_prover_job_id", "ordinal": 3, - "type_info": "Numeric" + "type_info": "Int8" }, { - "name": "initiator_address", + "name": "circuit_3_final_prover_job_id", "ordinal": 4, - "type_info": "Bytea" + "type_info": "Int8" }, { - "name": "nonce", + "name": "circuit_4_final_prover_job_id", "ordinal": 5, "type_info": "Int8" }, { - "name": "signature", + "name": "circuit_5_final_prover_job_id", "ordinal": 6, - "type_info": "Bytea" + "type_info": "Int8" }, { - "name": "input", + "name": "circuit_6_final_prover_job_id", "ordinal": 7, - "type_info": "Bytea" + "type_info": "Int8" }, { - "name": "data", + "name": "circuit_7_final_prover_job_id", "ordinal": 8, - "type_info": "Jsonb" + "type_info": "Int8" }, { - "name": "received_at", + "name": "circuit_8_final_prover_job_id", "ordinal": 9, - "type_info": "Timestamp" + "type_info": "Int8" }, { - "name": "priority_op_id", + "name": "circuit_9_final_prover_job_id", "ordinal": 10, "type_info": "Int8" }, { - "name": "l1_batch_number", + "name": "circuit_10_final_prover_job_id", "ordinal": 11, "type_info": "Int8" }, { - "name": "index_in_block", + "name": "circuit_11_final_prover_job_id", "ordinal": 12, - "type_info": "Int4" + "type_info": "Int8" }, { - "name": "error", + "name": "circuit_12_final_prover_job_id", "ordinal": 13, - "type_info": "Varchar" + "type_info": "Int8" }, { - "name": "gas_limit", + "name": "circuit_13_final_prover_job_id", "ordinal": 14, - "type_info": "Numeric" - }, - { - "name": "gas_per_storage_limit", - "ordinal": 15, - "type_info": "Numeric" - }, - { - "name": "gas_per_pubdata_limit", - "ordinal": 16, - "type_info": "Numeric" - }, - { - "name": "tx_format", - "ordinal": 17, - "type_info": "Int4" + "type_info": "Int8" }, { "name": "created_at", - "ordinal": 18, + "ordinal": 15, "type_info": "Timestamp" }, { "name": "updated_at", - "ordinal": 19, + "ordinal": 16, "type_info": "Timestamp" - }, + } + ], + "nullable": [ + false, + false, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + false, + false + ], + "parameters": { + "Left": [ + "Int8" + ] + } + }, + "query": "\n SELECT\n *\n FROM\n scheduler_dependency_tracker_fri\n WHERE\n l1_batch_number = $1\n " + }, + "e5a90d17b2c25744df4585b53678c7ffd9a04eae27afbdf37a6ba8ff7ac85f3b": { + "describe": { + "columns": [ { - "name": "execution_info", - "ordinal": 20, + "name": "serialized_events_queue", + "ordinal": 0, "type_info": "Jsonb" - }, + } + ], + "nullable": [ + false + ], + "parameters": { + "Left": [ + "Int8" + ] + } + }, + "query": "\n SELECT\n serialized_events_queue\n FROM\n events_queue\n WHERE\n l1_batch_number = $1\n " + }, + "e63cc86a8d527dae2905b2af6a66bc6419ba51514519652e055c769b096015f6": { + "describe": { + "columns": [ { - "name": "contract_address", - "ordinal": 21, + "name": "hash", + "ordinal": 0, "type_info": "Bytea" - }, + } + ], + "nullable": [ + false + ], + "parameters": { + "Left": [ + "Interval" + ] + } + }, + "query": "\n DELETE FROM transactions\n WHERE\n miniblock_number IS NULL\n AND received_at < NOW() - $1::INTERVAL\n AND is_priority = FALSE\n AND error IS NULL\n RETURNING\n hash\n " + }, + "e6a3efeffe1b3520cc9b1751e2c842c27546b3fd41f7d8a784ca58579856621b": { + "describe": { + "columns": [ { - "name": "in_mempool", - "ordinal": 22, - "type_info": "Bool" + "name": "l1_batch_number", + "ordinal": 0, + "type_info": "Int8" }, { - "name": "l1_block_number", - "ordinal": 23, + "name": "attempts", + "ordinal": 1, "type_info": "Int4" - }, - { - "name": "value", - "ordinal": 24, - "type_info": "Numeric" - }, - { - "name": "paymaster", - "ordinal": 25, - "type_info": "Bytea" - }, - { - "name": "paymaster_input", - "ordinal": 26, - "type_info": "Bytea" - }, + } + ], + "nullable": [ + false, + false + ], + "parameters": { + "Left": [ + "Text", + "Int8" + ] + } + }, + "query": "\n UPDATE prover_jobs\n SET\n status = 'failed',\n error = $1,\n updated_at = NOW()\n WHERE\n id = $2\n RETURNING\n l1_batch_number,\n attempts\n " + }, + "e71c39b93ceba5416ff3d988290cb35d4d07d47f33fe1a5b9e9fe1f0ae09b705": { + "describe": { + "columns": [ { - "name": "max_fee_per_gas", - "ordinal": 27, + "name": "usd_price", + "ordinal": 0, "type_info": "Numeric" }, { - "name": "max_priority_fee_per_gas", - "ordinal": 28, - "type_info": "Numeric" - }, + "name": "usd_price_updated_at", + "ordinal": 1, + "type_info": "Timestamp" + } + ], + "nullable": [ + true, + true + ], + "parameters": { + "Left": [ + "Bytea" + ] + } + }, + "query": "\n SELECT\n usd_price,\n usd_price_updated_at\n FROM\n tokens\n WHERE\n l2_address = $1\n " + }, + "e74a34a59e6afda689b0ec9e19071ababa66e4a443fbefbfffca72b7540b075b": { + "describe": { + "columns": [], + "nullable": [], + "parameters": { + "Left": [ + "Int8", + "Text" + ] + } + }, + "query": "\n INSERT INTO\n proof_compression_jobs_fri (l1_batch_number, status, created_at, updated_at)\n VALUES\n ($1, $2, NOW(), NOW())\n ON CONFLICT (l1_batch_number) DO NOTHING\n " + }, + "e76217231b4d896118e9630de9485b19e1294b3aa6e084d2051bb532408672be": { + "describe": { + "columns": [], + "nullable": [], + "parameters": { + "Left": [] + } + }, + "query": "\n UPDATE transactions\n SET\n in_mempool = FALSE\n WHERE\n in_mempool = TRUE\n " + }, + "e9adf5b5a1ab84c20a514a7775f91a9984685eaaaa0a8b223410d560a15a3034": { + "describe": { + "columns": [ { - "name": "effective_gas_price", - "ordinal": 29, - "type_info": "Numeric" + "name": "id", + "ordinal": 0, + "type_info": "Int8" }, { - "name": "miniblock_number", - "ordinal": 30, + "name": "l1_batch_number", + "ordinal": 1, "type_info": "Int8" }, { - "name": "l1_batch_tx_index", - "ordinal": 31, - "type_info": "Int4" + "name": "circuit_id", + "ordinal": 2, + "type_info": "Int2" }, { - "name": "refunded_gas", - "ordinal": 32, - "type_info": "Int8" + "name": "aggregation_round", + "ordinal": 3, + "type_info": "Int2" }, { - "name": "l1_tx_mint", - "ordinal": 33, - "type_info": "Numeric" + "name": "sequence_number", + "ordinal": 4, + "type_info": "Int4" }, { - "name": "l1_tx_refund_recipient", - "ordinal": 34, - "type_info": "Bytea" + "name": "depth", + "ordinal": 5, + "type_info": "Int4" }, { - "name": "upgrade_id", - "ordinal": 35, - "type_info": "Int4" + "name": "is_node_final_proof", + "ordinal": 6, + "type_info": "Bool" } ], "nullable": [ false, false, - true, - true, - false, - true, - true, - true, - false, - false, - true, - true, - true, - true, - true, - true, - true, - true, - false, - false, - false, - true, - false, - true, false, false, false, - true, - true, - true, - true, - true, false, - true, - true, - true + false ], "parameters": { "Left": [ - "Bytea" + "Int2Array", + "Int2Array", + "Int4Array", + "Text" ] } }, - "query": "\n SELECT * FROM transactions\n WHERE hash = $1\n " + "query": "\n UPDATE prover_jobs_fri\n SET\n status = 'in_progress',\n attempts = attempts + 1,\n processing_started_at = NOW(),\n updated_at = NOW(),\n picked_by = $4\n WHERE\n id = (\n SELECT\n pj.id\n FROM\n (\n SELECT\n *\n FROM\n UNNEST($1::SMALLINT[], $2::SMALLINT[])\n ) AS tuple (circuit_id, ROUND)\n JOIN LATERAL (\n SELECT\n *\n FROM\n prover_jobs_fri AS pj\n WHERE\n pj.status = 'queued'\n AND pj.protocol_version = ANY ($3)\n AND pj.circuit_id = tuple.circuit_id\n AND pj.aggregation_round = tuple.round\n ORDER BY\n pj.l1_batch_number ASC,\n pj.id ASC\n LIMIT\n 1\n ) AS pj ON TRUE\n ORDER BY\n pj.l1_batch_number ASC,\n pj.aggregation_round DESC,\n pj.id ASC\n LIMIT\n 1\n FOR UPDATE\n SKIP LOCKED\n )\n RETURNING\n prover_jobs_fri.id,\n prover_jobs_fri.l1_batch_number,\n prover_jobs_fri.circuit_id,\n prover_jobs_fri.aggregation_round,\n prover_jobs_fri.sequence_number,\n prover_jobs_fri.depth,\n prover_jobs_fri.is_node_final_proof\n " }, - "eb95c3daeffd23d35d4e047e3bb8dc44e93492a6d41cf0fd1624d3ea4a2267c9": { + "e9ca863d6e77edd39a9fc55700a6686e655206601854799139c22c017a214744": { "describe": { "columns": [], "nullable": [], "parameters": { "Left": [ "Int8", - "Int8" + "Int2", + "Int4", + "Text", + "Int4", + "Int4" ] } }, - "query": "UPDATE l1_batches SET predicted_commit_gas_cost = $2, updated_at = now() WHERE number = $1" + "query": "\n INSERT INTO\n node_aggregation_witness_jobs_fri (\n l1_batch_number,\n circuit_id,\n depth,\n aggregations_url,\n number_of_dependent_jobs,\n protocol_version,\n status,\n created_at,\n updated_at\n )\n VALUES\n ($1, $2, $3, $4, $5, $6, 'waiting_for_proofs', NOW(), NOW())\n ON CONFLICT (l1_batch_number, circuit_id, depth) DO\n UPDATE\n SET\n updated_at = NOW()\n " }, - "ed50c609371b4588964e29f8757c41973706710090a80eb025ec263ce3d019b4": { + "ea904aa930d602d33b6fbc1bf1178a8a0ec739f4ddec8ffeb3a87253aeb18d30": { "describe": { "columns": [], "nullable": [], "parameters": { "Left": [ - "Text", - "Int4", - "Int2", - "Text" + "Int8" ] } }, - "query": "INSERT INTO gpu_prover_queue_fri (instance_host, instance_port, instance_status, specialized_prover_group_id, zone, created_at, updated_at) VALUES (cast($1::text as inet), $2, 'available', $3, $4, now(), now()) ON CONFLICT(instance_host, instance_port, zone) DO UPDATE SET instance_status='available', specialized_prover_group_id=$3, zone=$4, updated_at=now()" + "query": "\n DELETE FROM miniblocks\n WHERE\n number > $1\n " }, - "eda61fd8012aadc27a2952e96d4238bccb21ec47a17e326a7ae9182d5358d733": { + "ec04b89218111a5dc8d5ade506ac3465e2211ef3013386feb12d4cc04e0eade9": { "describe": { "columns": [ { - "name": "timestamp", + "name": "id", "ordinal": 0, "type_info": "Int8" + }, + { + "name": "l1_batch_number", + "ordinal": 1, + "type_info": "Int8" + }, + { + "name": "circuit_id", + "ordinal": 2, + "type_info": "Int2" + }, + { + "name": "aggregation_round", + "ordinal": 3, + "type_info": "Int2" + }, + { + "name": "sequence_number", + "ordinal": 4, + "type_info": "Int4" + }, + { + "name": "depth", + "ordinal": 5, + "type_info": "Int4" + }, + { + "name": "is_node_final_proof", + "ordinal": 6, + "type_info": "Bool" } ], "nullable": [ + false, + false, + false, + false, + false, + false, false ], "parameters": { - "Left": [] + "Left": [ + "Time", + "Text", + "Int8" + ] } }, - "query": "SELECT timestamp FROM l1_batches WHERE eth_prove_tx_id IS NULL AND number > 0 ORDER BY number LIMIT 1" + "query": "\n UPDATE prover_jobs_fri\n SET\n status = 'successful',\n updated_at = NOW(),\n time_taken = $1,\n proof_blob_url = $2\n WHERE\n id = $3\n RETURNING\n prover_jobs_fri.id,\n prover_jobs_fri.l1_batch_number,\n prover_jobs_fri.circuit_id,\n prover_jobs_fri.aggregation_round,\n prover_jobs_fri.sequence_number,\n prover_jobs_fri.depth,\n prover_jobs_fri.is_node_final_proof\n " }, - "ee74b42d1a6a52784124751dae6c7eca3fd36f5a3bb26de56efc2b810da7033a": { + "edc61e1285bf6d3837acc67af4f15aaade450980719933089824eb8c494d64a4": { "describe": { - "columns": [ - { - "name": "initial_bootloader_heap_content", - "ordinal": 0, - "type_info": "Jsonb" - } - ], - "nullable": [ - false - ], + "columns": [], + "nullable": [], "parameters": { "Left": [ + "Time", "Int8" ] } }, - "query": "SELECT initial_bootloader_heap_content FROM l1_batches WHERE number = $1" + "query": "\n UPDATE witness_inputs_fri\n SET\n status = 'successful',\n updated_at = NOW(),\n time_taken = $1\n WHERE\n l1_batch_number = $2\n " }, - "ee7bd820bf35c5c714092494c386eccff25457cff6dc00eb81d9809eaeb95670": { + "ee17d2b3edfe705d14811e3938d4312b2b780563a9fde48bae5e51650475670f": { "describe": { "columns": [ { - "name": "is_replaced!", + "name": "id", "ordinal": 0, - "type_info": "Bool" + "type_info": "Int4" + }, + { + "name": "eth_tx_id", + "ordinal": 1, + "type_info": "Int4" + }, + { + "name": "tx_hash", + "ordinal": 2, + "type_info": "Text" + }, + { + "name": "created_at", + "ordinal": 3, + "type_info": "Timestamp" + }, + { + "name": "updated_at", + "ordinal": 4, + "type_info": "Timestamp" + }, + { + "name": "base_fee_per_gas", + "ordinal": 5, + "type_info": "Int8" + }, + { + "name": "priority_fee_per_gas", + "ordinal": 6, + "type_info": "Int8" + }, + { + "name": "confirmed_at", + "ordinal": 7, + "type_info": "Timestamp" + }, + { + "name": "signed_raw_tx", + "ordinal": 8, + "type_info": "Bytea" + }, + { + "name": "sent_at_block", + "ordinal": 9, + "type_info": "Int4" + }, + { + "name": "sent_at", + "ordinal": 10, + "type_info": "Timestamp" } ], "nullable": [ - null + false, + false, + false, + false, + false, + false, + false, + true, + true, + true, + true ], "parameters": { "Left": [ - "Bytea", - "Bytea", - "Int8", - "Bytea", - "Numeric", - "Numeric", - "Numeric", - "Numeric", - "Bytea", - "Jsonb", - "Int4", - "Bytea", - "Numeric", - "Bytea", - "Bytea", - "Int8", - "Int4", - "Int4", - "Timestamp" + "Int4" ] } }, - "query": "\n INSERT INTO transactions\n (\n hash,\n is_priority,\n initiator_address,\n nonce,\n signature,\n gas_limit,\n max_fee_per_gas,\n max_priority_fee_per_gas,\n gas_per_pubdata_limit,\n input,\n data,\n tx_format,\n contract_address,\n value,\n paymaster,\n paymaster_input,\n execution_info,\n received_at,\n created_at,\n updated_at\n )\n VALUES\n (\n $1, FALSE, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15,\n jsonb_build_object('gas_used', $16::bigint, 'storage_writes', $17::int, 'contracts_used', $18::int),\n $19, now(), now()\n )\n ON CONFLICT\n (initiator_address, nonce)\n DO UPDATE\n SET hash=$1,\n signature=$4,\n gas_limit=$5,\n max_fee_per_gas=$6,\n max_priority_fee_per_gas=$7,\n gas_per_pubdata_limit=$8,\n input=$9,\n data=$10,\n tx_format=$11,\n contract_address=$12,\n value=$13,\n paymaster=$14,\n paymaster_input=$15,\n execution_info=jsonb_build_object('gas_used', $16::bigint, 'storage_writes', $17::int, 'contracts_used', $18::int),\n in_mempool=FALSE,\n received_at=$19,\n created_at=now(),\n updated_at=now(),\n error = NULL\n WHERE transactions.is_priority = FALSE AND transactions.miniblock_number IS NULL\n RETURNING (SELECT hash FROM transactions WHERE transactions.initiator_address = $2 AND transactions.nonce = $3) IS NOT NULL as \"is_replaced!\"\n " + "query": "\n SELECT\n *\n FROM\n eth_txs_history\n WHERE\n eth_tx_id = $1\n ORDER BY\n created_at DESC\n LIMIT\n 1\n " }, - "ee87b42383cd6b4f1445e2aa152369fee31a7fea436db8b3b9925a60ac60cd1a": { + "ee5111f1b616434587e2079ae676e36a4b2d7905bb60573df362063f7b007edb": { "describe": { "columns": [ { - "name": "hash", + "name": "number", "ordinal": 0, - "type_info": "Bytea" + "type_info": "Int8" }, { - "name": "is_priority", + "name": "timestamp", "ordinal": 1, - "type_info": "Bool" + "type_info": "Int8" }, { - "name": "full_fee", + "name": "is_finished", "ordinal": 2, - "type_info": "Numeric" + "type_info": "Bool" }, { - "name": "layer_2_tip_fee", + "name": "l1_tx_count", "ordinal": 3, - "type_info": "Numeric" + "type_info": "Int4" }, { - "name": "initiator_address", + "name": "l2_tx_count", "ordinal": 4, - "type_info": "Bytea" + "type_info": "Int4" }, { - "name": "nonce", + "name": "fee_account_address", "ordinal": 5, - "type_info": "Int8" + "type_info": "Bytea" }, { - "name": "signature", + "name": "bloom", "ordinal": 6, "type_info": "Bytea" }, { - "name": "input", + "name": "priority_ops_onchain_data", "ordinal": 7, - "type_info": "Bytea" + "type_info": "ByteaArray" }, { - "name": "data", + "name": "hash", "ordinal": 8, - "type_info": "Jsonb" + "type_info": "Bytea" }, { - "name": "received_at", + "name": "parent_hash", "ordinal": 9, - "type_info": "Timestamp" + "type_info": "Bytea" }, { - "name": "priority_op_id", + "name": "commitment", "ordinal": 10, - "type_info": "Int8" + "type_info": "Bytea" }, { - "name": "l1_batch_number", + "name": "compressed_write_logs", "ordinal": 11, - "type_info": "Int8" + "type_info": "Bytea" }, { - "name": "index_in_block", + "name": "compressed_contracts", "ordinal": 12, - "type_info": "Int4" + "type_info": "Bytea" }, { - "name": "error", + "name": "eth_prove_tx_id", "ordinal": 13, - "type_info": "Varchar" + "type_info": "Int4" }, { - "name": "gas_limit", + "name": "eth_commit_tx_id", "ordinal": 14, - "type_info": "Numeric" + "type_info": "Int4" }, { - "name": "gas_per_storage_limit", + "name": "eth_execute_tx_id", "ordinal": 15, - "type_info": "Numeric" + "type_info": "Int4" }, { - "name": "gas_per_pubdata_limit", + "name": "merkle_root_hash", "ordinal": 16, - "type_info": "Numeric" + "type_info": "Bytea" }, { - "name": "tx_format", + "name": "l2_to_l1_logs", "ordinal": 17, - "type_info": "Int4" + "type_info": "ByteaArray" }, { - "name": "created_at", + "name": "l2_to_l1_messages", "ordinal": 18, - "type_info": "Timestamp" + "type_info": "ByteaArray" }, { - "name": "updated_at", + "name": "used_contract_hashes", "ordinal": 19, - "type_info": "Timestamp" + "type_info": "Jsonb" }, { - "name": "execution_info", + "name": "compressed_initial_writes", "ordinal": 20, - "type_info": "Jsonb" + "type_info": "Bytea" }, { - "name": "contract_address", + "name": "compressed_repeated_writes", "ordinal": 21, "type_info": "Bytea" }, { - "name": "in_mempool", + "name": "l2_l1_compressed_messages", "ordinal": 22, - "type_info": "Bool" + "type_info": "Bytea" }, { - "name": "l1_block_number", + "name": "l2_l1_merkle_root", "ordinal": 23, - "type_info": "Int4" + "type_info": "Bytea" }, { - "name": "value", + "name": "l1_gas_price", "ordinal": 24, - "type_info": "Numeric" + "type_info": "Int8" }, { - "name": "paymaster", + "name": "l2_fair_gas_price", "ordinal": 25, - "type_info": "Bytea" + "type_info": "Int8" }, { - "name": "paymaster_input", + "name": "rollup_last_leaf_index", "ordinal": 26, - "type_info": "Bytea" + "type_info": "Int8" }, { - "name": "max_fee_per_gas", + "name": "zkporter_is_available", "ordinal": 27, - "type_info": "Numeric" + "type_info": "Bool" }, { - "name": "max_priority_fee_per_gas", + "name": "bootloader_code_hash", "ordinal": 28, - "type_info": "Numeric" + "type_info": "Bytea" }, { - "name": "effective_gas_price", + "name": "default_aa_code_hash", "ordinal": 29, - "type_info": "Numeric" + "type_info": "Bytea" }, { - "name": "miniblock_number", + "name": "base_fee_per_gas", "ordinal": 30, - "type_info": "Int8" + "type_info": "Numeric" }, { - "name": "l1_batch_tx_index", + "name": "aux_data_hash", "ordinal": 31, - "type_info": "Int4" + "type_info": "Bytea" }, { - "name": "refunded_gas", + "name": "pass_through_data_hash", "ordinal": 32, - "type_info": "Int8" + "type_info": "Bytea" }, { - "name": "l1_tx_mint", + "name": "meta_parameters_hash", "ordinal": 33, - "type_info": "Numeric" + "type_info": "Bytea" }, { - "name": "l1_tx_refund_recipient", + "name": "protocol_version", "ordinal": 34, - "type_info": "Bytea" + "type_info": "Int4" }, { - "name": "upgrade_id", + "name": "compressed_state_diffs", "ordinal": 35, - "type_info": "Int4" + "type_info": "Bytea" + }, + { + "name": "system_logs", + "ordinal": 36, + "type_info": "ByteaArray" + }, + { + "name": "events_queue_commitment", + "ordinal": 37, + "type_info": "Bytea" + }, + { + "name": "bootloader_initial_content_commitment", + "ordinal": 38, + "type_info": "Bytea" } ], "nullable": [ false, false, - true, - true, false, - true, - true, - true, + false, + false, + false, false, false, true, @@ -11135,14 +11116,20 @@ true, true, true, + true, false, false, false, true, - false, + true, + true, true, false, false, + true, + true, + true, + true, false, true, true, @@ -11151,27 +11138,6 @@ true, false, true, - true, - true - ], - "parameters": { - "Left": [ - "Int8" - ] - } - }, - "query": "SELECT * FROM transactions WHERE miniblock_number = $1 ORDER BY index_in_block" - }, - "efc83e42f5d0238b8996a5b311746527289a5a002ff659531a076680127e8eb4": { - "describe": { - "columns": [ - { - "name": "hash", - "ordinal": 0, - "type_info": "Bytea" - } - ], - "nullable": [ true ], "parameters": { @@ -11180,235 +11146,214 @@ ] } }, - "query": "SELECT hash FROM l1_batches WHERE number = $1" + "query": "\n SELECT\n number,\n timestamp,\n is_finished,\n l1_tx_count,\n l2_tx_count,\n fee_account_address,\n bloom,\n priority_ops_onchain_data,\n hash,\n parent_hash,\n commitment,\n compressed_write_logs,\n compressed_contracts,\n eth_prove_tx_id,\n eth_commit_tx_id,\n eth_execute_tx_id,\n merkle_root_hash,\n l2_to_l1_logs,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_compressed_messages,\n l2_l1_merkle_root,\n l1_gas_price,\n l2_fair_gas_price,\n rollup_last_leaf_index,\n zkporter_is_available,\n bootloader_code_hash,\n default_aa_code_hash,\n base_fee_per_gas,\n aux_data_hash,\n pass_through_data_hash,\n meta_parameters_hash,\n protocol_version,\n compressed_state_diffs,\n system_logs,\n events_queue_commitment,\n bootloader_initial_content_commitment\n FROM\n l1_batches\n LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number\n WHERE\n eth_prove_tx_id IS NOT NULL\n AND eth_execute_tx_id IS NULL\n ORDER BY\n number\n LIMIT\n $1\n " }, - "f15f0848cfd830ec5d5b479fdcdd36c6a4439495b7680614ac1b0e4d73fb992f": { + "eebfc56a12abe6ac2219a239c8138c83e59b73003c832a418b55433f469392bc": { "describe": { "columns": [ { - "name": "l1_batch_number", + "name": "number", "ordinal": 0, "type_info": "Int8" - } - ], - "nullable": [ - false - ], - "parameters": { - "Left": [] - } - }, - "query": "SELECT l1_batch_number FROM proof_compression_jobs_fri WHERE status <> 'successful' ORDER BY l1_batch_number ASC LIMIT 1" - }, - "f1defa140e20b9c250d3212602dc259c0a35598c2e69d1c42746a8fab6dd8d3e": { - "describe": { - "columns": [], - "nullable": [], - "parameters": { - "Left": [ - "Text", - "Int4", - "Int4", - "Text", - "Text" - ] - } - }, - "query": "\n UPDATE gpu_prover_queue\n SET instance_status = 'available', updated_at = now(), queue_free_slots = $3\n WHERE instance_host = $1::text::inet\n AND instance_port = $2\n AND instance_status = 'full'\n AND region = $4\n AND zone = $5\n " - }, - "f365ada84c576a9049551a28f800ca8cb1d0096f3ba1c9edec725e11892a5a6c": { - "describe": { - "columns": [ - { - "name": "hash", - "ordinal": 0, - "type_info": "Bytea" }, { - "name": "is_priority", + "name": "timestamp", "ordinal": 1, - "type_info": "Bool" + "type_info": "Int8" }, { - "name": "full_fee", + "name": "is_finished", "ordinal": 2, - "type_info": "Numeric" + "type_info": "Bool" }, { - "name": "layer_2_tip_fee", + "name": "l1_tx_count", "ordinal": 3, - "type_info": "Numeric" + "type_info": "Int4" }, { - "name": "initiator_address", + "name": "l2_tx_count", "ordinal": 4, - "type_info": "Bytea" + "type_info": "Int4" }, { - "name": "nonce", + "name": "fee_account_address", "ordinal": 5, - "type_info": "Int8" + "type_info": "Bytea" }, { - "name": "signature", + "name": "bloom", "ordinal": 6, "type_info": "Bytea" }, { - "name": "input", + "name": "priority_ops_onchain_data", "ordinal": 7, - "type_info": "Bytea" + "type_info": "ByteaArray" }, { - "name": "data", + "name": "hash", "ordinal": 8, - "type_info": "Jsonb" + "type_info": "Bytea" }, { - "name": "received_at", + "name": "parent_hash", "ordinal": 9, - "type_info": "Timestamp" + "type_info": "Bytea" }, { - "name": "priority_op_id", + "name": "commitment", "ordinal": 10, - "type_info": "Int8" + "type_info": "Bytea" }, { - "name": "l1_batch_number", + "name": "compressed_write_logs", "ordinal": 11, - "type_info": "Int8" + "type_info": "Bytea" }, { - "name": "index_in_block", + "name": "compressed_contracts", "ordinal": 12, - "type_info": "Int4" + "type_info": "Bytea" }, { - "name": "error", + "name": "eth_prove_tx_id", "ordinal": 13, - "type_info": "Varchar" + "type_info": "Int4" }, { - "name": "gas_limit", + "name": "eth_commit_tx_id", "ordinal": 14, - "type_info": "Numeric" + "type_info": "Int4" }, { - "name": "gas_per_storage_limit", + "name": "eth_execute_tx_id", "ordinal": 15, - "type_info": "Numeric" + "type_info": "Int4" }, { - "name": "gas_per_pubdata_limit", + "name": "merkle_root_hash", "ordinal": 16, - "type_info": "Numeric" + "type_info": "Bytea" }, { - "name": "tx_format", + "name": "l2_to_l1_logs", "ordinal": 17, - "type_info": "Int4" + "type_info": "ByteaArray" }, { - "name": "created_at", + "name": "l2_to_l1_messages", "ordinal": 18, - "type_info": "Timestamp" + "type_info": "ByteaArray" }, { - "name": "updated_at", + "name": "used_contract_hashes", "ordinal": 19, - "type_info": "Timestamp" + "type_info": "Jsonb" }, { - "name": "execution_info", + "name": "compressed_initial_writes", "ordinal": 20, - "type_info": "Jsonb" + "type_info": "Bytea" }, { - "name": "contract_address", + "name": "compressed_repeated_writes", "ordinal": 21, "type_info": "Bytea" }, { - "name": "in_mempool", + "name": "l2_l1_compressed_messages", "ordinal": 22, - "type_info": "Bool" + "type_info": "Bytea" }, { - "name": "l1_block_number", + "name": "l2_l1_merkle_root", "ordinal": 23, - "type_info": "Int4" + "type_info": "Bytea" }, { - "name": "value", + "name": "l1_gas_price", "ordinal": 24, - "type_info": "Numeric" + "type_info": "Int8" }, { - "name": "paymaster", + "name": "l2_fair_gas_price", "ordinal": 25, - "type_info": "Bytea" + "type_info": "Int8" }, { - "name": "paymaster_input", + "name": "rollup_last_leaf_index", "ordinal": 26, - "type_info": "Bytea" + "type_info": "Int8" }, { - "name": "max_fee_per_gas", + "name": "zkporter_is_available", "ordinal": 27, - "type_info": "Numeric" + "type_info": "Bool" }, { - "name": "max_priority_fee_per_gas", + "name": "bootloader_code_hash", "ordinal": 28, - "type_info": "Numeric" + "type_info": "Bytea" }, { - "name": "effective_gas_price", + "name": "default_aa_code_hash", "ordinal": 29, - "type_info": "Numeric" + "type_info": "Bytea" }, { - "name": "miniblock_number", + "name": "base_fee_per_gas", "ordinal": 30, - "type_info": "Int8" + "type_info": "Numeric" }, { - "name": "l1_batch_tx_index", + "name": "aux_data_hash", "ordinal": 31, - "type_info": "Int4" + "type_info": "Bytea" }, { - "name": "refunded_gas", + "name": "pass_through_data_hash", "ordinal": 32, - "type_info": "Int8" + "type_info": "Bytea" }, { - "name": "l1_tx_mint", + "name": "meta_parameters_hash", "ordinal": 33, - "type_info": "Numeric" + "type_info": "Bytea" }, { - "name": "l1_tx_refund_recipient", + "name": "system_logs", "ordinal": 34, - "type_info": "Bytea" + "type_info": "ByteaArray" }, { - "name": "upgrade_id", + "name": "compressed_state_diffs", "ordinal": 35, + "type_info": "Bytea" + }, + { + "name": "protocol_version", + "ordinal": 36, "type_info": "Int4" + }, + { + "name": "events_queue_commitment", + "ordinal": 37, + "type_info": "Bytea" + }, + { + "name": "bootloader_initial_content_commitment", + "ordinal": 38, + "type_info": "Bytea" } ], "nullable": [ false, false, - true, - true, false, - true, - true, - true, + false, + false, + false, false, false, true, @@ -11419,34 +11364,40 @@ true, true, true, + true, false, false, false, true, - false, + true, + true, true, false, false, - false, true, true, true, true, + false, + true, + true, true, false, true, true, + true, true ], "parameters": { "Left": [ + "Int8", "Int8" ] } }, - "query": "SELECT * FROM transactions WHERE l1_batch_number = $1 ORDER BY miniblock_number, index_in_block" + "query": "\n SELECT\n number,\n timestamp,\n is_finished,\n l1_tx_count,\n l2_tx_count,\n fee_account_address,\n bloom,\n priority_ops_onchain_data,\n hash,\n parent_hash,\n commitment,\n compressed_write_logs,\n compressed_contracts,\n eth_prove_tx_id,\n eth_commit_tx_id,\n eth_execute_tx_id,\n merkle_root_hash,\n l2_to_l1_logs,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_compressed_messages,\n l2_l1_merkle_root,\n l1_gas_price,\n l2_fair_gas_price,\n rollup_last_leaf_index,\n zkporter_is_available,\n bootloader_code_hash,\n default_aa_code_hash,\n base_fee_per_gas,\n aux_data_hash,\n pass_through_data_hash,\n meta_parameters_hash,\n system_logs,\n compressed_state_diffs,\n protocol_version,\n events_queue_commitment,\n bootloader_initial_content_commitment\n FROM\n (\n SELECT\n l1_batches.*,\n ROW_NUMBER() OVER (\n ORDER BY\n number ASC\n ) AS ROW_NUMBER\n FROM\n l1_batches\n WHERE\n eth_commit_tx_id IS NOT NULL\n AND l1_batches.skip_proof = TRUE\n AND l1_batches.number > $1\n ORDER BY\n number\n LIMIT\n $2\n ) inn\n LEFT JOIN commitments ON commitments.l1_batch_number = inn.number\n WHERE\n number - ROW_NUMBER = $1\n " }, - "f39893caa0ad524eda13ab89539fd61804c9190b3d62f4416de83159c2c189e4": { + "ef331469f78c6ff68a254a15b55d056cc9bae25bc070c5de8424f88fab20e5ea": { "describe": { "columns": [ { @@ -11455,69 +11406,146 @@ "type_info": "Int8" }, { - "name": "status", + "name": "l1_batch_tx_index", "ordinal": 1, - "type_info": "Text" - }, - { - "name": "attempts", - "ordinal": 2, - "type_info": "Int2" + "type_info": "Int4" } ], "nullable": [ - false, - false, - false + true, + true ], "parameters": { "Left": [ - "Interval", + "Bytea" + ] + } + }, + "query": "\n SELECT\n l1_batch_number,\n l1_batch_tx_index\n FROM\n transactions\n WHERE\n hash = $1\n " + }, + "ef687be83e496d6647e4dfef9eabae63443c51deb818dd0affd1a0949b161737": { + "describe": { + "columns": [], + "nullable": [], + "parameters": { + "Left": [ + "Int8", + "Text", + "Text" + ] + } + }, + "query": "\n INSERT INTO\n proof_compression_jobs_fri (l1_batch_number, fri_proof_blob_url, status, created_at, updated_at)\n VALUES\n ($1, $2, $3, NOW(), NOW())\n ON CONFLICT (l1_batch_number) DO NOTHING\n " + }, + "efe2a4ce4ba09e40ac7401f19ac5a42a0d521ffa33594c7861d786741d303f30": { + "describe": { + "columns": [], + "nullable": [], + "parameters": { + "Left": [ + "Text", + "Int4", + "Int4", + "Int2", + "Text", + "Text", "Int2" ] } }, - "query": "UPDATE proof_compression_jobs_fri SET status = 'queued', updated_at = now(), processing_started_at = now() WHERE (status = 'in_progress' AND processing_started_at <= now() - $1::interval AND attempts < $2) OR (status = 'failed' AND attempts < $2) RETURNING l1_batch_number, status, attempts" + "query": "\n INSERT INTO\n gpu_prover_queue (\n instance_host,\n instance_port,\n queue_capacity,\n queue_free_slots,\n instance_status,\n specialized_prover_group_id,\n region,\n zone,\n num_gpu,\n created_at,\n updated_at\n )\n VALUES\n (CAST($1::TEXT AS inet), $2, $3, $3, 'available', $4, $5, $6, $7, NOW(), NOW())\n ON CONFLICT (instance_host, instance_port, region, zone) DO\n UPDATE\n SET\n instance_status = 'available',\n queue_capacity = $3,\n queue_free_slots = $3,\n specialized_prover_group_id = $4,\n region = $5,\n zone = $6,\n num_gpu = $7,\n updated_at = NOW()\n " }, - "f5e3c4b23fa0d0686b400b64c42cf78b2219f0cbcf1c9240b77e4132513e36ef": { + "f012d0922265269746396dac8f25ff66f2c3b2b83d45360818a8782e56aa3d66": { "describe": { "columns": [ { - "name": "address", + "name": "hashed_key?", "ordinal": 0, "type_info": "Bytea" }, { - "name": "key", + "name": "value?", "ordinal": 1, "type_info": "Bytea" }, { - "name": "value", + "name": "index", "ordinal": 2, - "type_info": "Bytea" + "type_info": "Int8" + } + ], + "nullable": [ + null, + null, + true + ], + "parameters": { + "Left": [ + "Int8", + "ByteaArray", + "ByteaArray" + ] + } + }, + "query": "\n WITH\n sl AS (\n SELECT\n (\n SELECT\n ARRAY[hashed_key, value] AS kv\n FROM\n storage_logs\n WHERE\n storage_logs.miniblock_number = $1\n AND storage_logs.hashed_key >= u.start_key\n AND storage_logs.hashed_key <= u.end_key\n ORDER BY\n storage_logs.hashed_key\n LIMIT\n 1\n )\n FROM\n UNNEST($2::bytea[], $3::bytea[]) AS u (start_key, end_key)\n )\n SELECT\n sl.kv[1] AS \"hashed_key?\",\n sl.kv[2] AS \"value?\",\n initial_writes.index\n FROM\n sl\n LEFT OUTER JOIN initial_writes ON initial_writes.hashed_key = sl.kv[1]\n " + }, + "f1478830e5f95cbcd0da01d3457cbb9cb8da439c7ab28fa865f53908621dc4c5": { + "describe": { + "columns": [ + { + "name": "region", + "ordinal": 0, + "type_info": "Text" + }, + { + "name": "zone", + "ordinal": 1, + "type_info": "Text" + }, + { + "name": "total_gpus", + "ordinal": 2, + "type_info": "Int8" + } + ], + "nullable": [ + false, + false, + null + ], + "parameters": { + "Left": [] + } + }, + "query": "\n SELECT\n region,\n zone,\n SUM(num_gpu) AS total_gpus\n FROM\n gpu_prover_queue\n GROUP BY\n region,\n zone\n " + }, + "f1a90090c192d68367e799188356efe8d41759bbdcdd6d39db93208f2664f03a": { + "describe": { + "columns": [ + { + "name": "index", + "ordinal": 0, + "type_info": "Int8" } ], "nullable": [ - false, - false, false ], "parameters": { "Left": [ - "Int8" + "Bytea" ] } }, - "query": "SELECT address, key, value FROM storage_logs WHERE miniblock_number BETWEEN (SELECT MIN(number) FROM miniblocks WHERE l1_batch_number = $1) AND (SELECT MAX(number) FROM miniblocks WHERE l1_batch_number = $1) ORDER BY miniblock_number, operation_number" + "query": "\n SELECT\n INDEX\n FROM\n initial_writes\n WHERE\n hashed_key = $1\n " }, - "f69542ca7e27a74d3703f359d9be33cf11c1f066c42754b92fced2af410c4558": { + "f22c5d136fe68bbfcee60beb304cfdc050b85e6d773b13f9699f15c335d42593": { "describe": { "columns": [ { - "name": "attempts", + "name": "l1_address", "ordinal": 0, - "type_info": "Int2" + "type_info": "Bytea" } ], "nullable": [ @@ -11525,137 +11553,72 @@ ], "parameters": { "Left": [ - { - "Custom": { - "kind": { - "Enum": [ - "Queued", - "ManuallySkipped", - "InProgress", - "Successful", - "Failed" - ] - }, - "name": "basic_witness_input_producer_job_status" - } - }, - "Int8", - "Time", - "Text", - { - "Custom": { - "kind": { - "Enum": [ - "Queued", - "ManuallySkipped", - "InProgress", - "Successful", - "Failed" - ] - }, - "name": "basic_witness_input_producer_job_status" - } - } - ] - } - }, - "query": "UPDATE basic_witness_input_producer_jobs SET status = $1, updated_at = now(), time_taken = $3, error = $4 WHERE l1_batch_number = $2 AND status != $5 RETURNING basic_witness_input_producer_jobs.attempts" - }, - "f78960549e6201527454d060d5b483db032f4df80b4269a624f0309ed9a6a38e": { - "describe": { - "columns": [], - "nullable": [], - "parameters": { - "Left": [ - "Text", - "Int8" + "Numeric" ] } }, - "query": "\n UPDATE witness_inputs_fri SET status ='failed', error= $1, updated_at = now()\n WHERE l1_batch_number = $2\n " + "query": "\n SELECT\n l1_address\n FROM\n tokens\n WHERE\n market_volume > $1\n " }, - "fa006dda8f56abb70afc5ba8b6da631747d17ebd03a37ddb72914c4ed2aeb2f5": { + "f303c53843a58fac4fcdedbfe2b2b33ad609b7df8e55a0cf214ea1ec6421e57a": { "describe": { "columns": [ { - "name": "trace", + "name": "id", "ordinal": 0, - "type_info": "Jsonb" + "type_info": "Int8" + }, + { + "name": "status", + "ordinal": 1, + "type_info": "Text" + }, + { + "name": "attempts", + "ordinal": 2, + "type_info": "Int4" } ], "nullable": [ + false, + false, false ], "parameters": { "Left": [ - "Bytea" + "Interval", + "Int4" ] } }, - "query": "SELECT trace FROM transaction_traces WHERE tx_hash = $1" + "query": "\n UPDATE prover_jobs\n SET\n status = 'queued',\n updated_at = NOW(),\n processing_started_at = NOW()\n WHERE\n (\n status = 'in_progress'\n AND processing_started_at <= NOW() - $1::INTERVAL\n AND attempts < $2\n )\n OR (\n status = 'in_gpu_proof'\n AND processing_started_at <= NOW() - $1::INTERVAL\n AND attempts < $2\n )\n OR (\n status = 'failed'\n AND attempts < $2\n )\n RETURNING\n id,\n status,\n attempts\n " }, - "fa177254ba516ad1588f4f6960be96706d1f43c23ff1d57ba2bc7bc7148bdcac": { + "f39372e37160df4897f62a800694867ed765dcb9dc60754df9df8700d4244bfb": { "describe": { "columns": [ { - "name": "number", + "name": "l1_address", "ordinal": 0, - "type_info": "Int8" + "type_info": "Bytea" }, { - "name": "timestamp", + "name": "l2_address", "ordinal": 1, - "type_info": "Int8" + "type_info": "Bytea" }, { - "name": "hash", + "name": "name", "ordinal": 2, - "type_info": "Bytea" + "type_info": "Varchar" }, { - "name": "l1_tx_count", + "name": "symbol", "ordinal": 3, - "type_info": "Int4" + "type_info": "Varchar" }, { - "name": "l2_tx_count", + "name": "decimals", "ordinal": 4, "type_info": "Int4" - }, - { - "name": "base_fee_per_gas", - "ordinal": 5, - "type_info": "Numeric" - }, - { - "name": "l1_gas_price", - "ordinal": 6, - "type_info": "Int8" - }, - { - "name": "l2_fair_gas_price", - "ordinal": 7, - "type_info": "Int8" - }, - { - "name": "bootloader_code_hash", - "ordinal": 8, - "type_info": "Bytea" - }, - { - "name": "default_aa_code_hash", - "ordinal": 9, - "type_info": "Bytea" - }, - { - "name": "protocol_version", - "ordinal": 10, - "type_info": "Int4" - }, - { - "name": "virtual_blocks", - "ordinal": 11, - "type_info": "Int8" } ], "nullable": [ @@ -11663,224 +11626,235 @@ false, false, false, - false, - false, - false, - false, - true, - true, - true, false ], "parameters": { "Left": [] } }, - "query": "SELECT number, timestamp, hash, l1_tx_count, l2_tx_count, base_fee_per_gas, l1_gas_price, l2_fair_gas_price, bootloader_code_hash, default_aa_code_hash, protocol_version, virtual_blocks\n FROM miniblocks ORDER BY number DESC LIMIT 1" + "query": "\n SELECT\n l1_address,\n l2_address,\n NAME,\n symbol,\n decimals\n FROM\n tokens\n WHERE\n well_known = TRUE\n ORDER BY\n symbol\n " + }, + "f4362a61ab05af3d71a3232d2f017db60405a887f9f7fa0ca60aa7fc879ce630": { + "describe": { + "columns": [], + "nullable": [], + "parameters": { + "Left": [ + "Text", + "Text", + "Int8" + ] + } + }, + "query": "\n UPDATE proof_compression_jobs_fri\n SET\n status = $1,\n error = $2,\n updated_at = NOW()\n WHERE\n l1_batch_number = $3\n " }, - "fa2b4316aaef09e96d93b70f96b129ed123951732e01d63f30b4b292d441ea39": { + "f63586d59264eab7388ad1de823227ecaa45d76d1ba260074898fe57c059a15a": { "describe": { "columns": [ { - "name": "l1_batch_number", + "name": "hash", "ordinal": 0, - "type_info": "Int8" + "type_info": "Bytea" }, { - "name": "status", + "name": "is_priority", "ordinal": 1, - "type_info": "Text" + "type_info": "Bool" }, { - "name": "circuit_1_final_prover_job_id", + "name": "full_fee", "ordinal": 2, - "type_info": "Int8" + "type_info": "Numeric" }, { - "name": "circuit_2_final_prover_job_id", + "name": "layer_2_tip_fee", "ordinal": 3, - "type_info": "Int8" + "type_info": "Numeric" }, { - "name": "circuit_3_final_prover_job_id", + "name": "initiator_address", "ordinal": 4, - "type_info": "Int8" + "type_info": "Bytea" }, { - "name": "circuit_4_final_prover_job_id", + "name": "nonce", "ordinal": 5, "type_info": "Int8" }, { - "name": "circuit_5_final_prover_job_id", + "name": "signature", "ordinal": 6, - "type_info": "Int8" + "type_info": "Bytea" }, { - "name": "circuit_6_final_prover_job_id", + "name": "input", "ordinal": 7, - "type_info": "Int8" + "type_info": "Bytea" }, { - "name": "circuit_7_final_prover_job_id", + "name": "data", "ordinal": 8, - "type_info": "Int8" + "type_info": "Jsonb" }, { - "name": "circuit_8_final_prover_job_id", + "name": "received_at", "ordinal": 9, - "type_info": "Int8" + "type_info": "Timestamp" }, { - "name": "circuit_9_final_prover_job_id", + "name": "priority_op_id", "ordinal": 10, "type_info": "Int8" }, { - "name": "circuit_10_final_prover_job_id", + "name": "l1_batch_number", "ordinal": 11, "type_info": "Int8" - }, - { - "name": "circuit_11_final_prover_job_id", - "ordinal": 12, - "type_info": "Int8" - }, - { - "name": "circuit_12_final_prover_job_id", - "ordinal": 13, - "type_info": "Int8" - }, - { - "name": "circuit_13_final_prover_job_id", - "ordinal": 14, - "type_info": "Int8" - }, - { - "name": "created_at", - "ordinal": 15, - "type_info": "Timestamp" - }, - { - "name": "updated_at", - "ordinal": 16, - "type_info": "Timestamp" - } - ], - "nullable": [ - false, - false, - true, - true, - true, - true, - true, - true, - true, - true, - true, - true, - true, - true, - true, - false, - false - ], - "parameters": { - "Left": [ - "Int8" - ] - } - }, - "query": "\n SELECT * FROM scheduler_dependency_tracker_fri\n WHERE l1_batch_number = $1\n " - }, - "fa33d51f8627376832b11bb174354e65e645ee2fb81564a97725518f47ae6f57": { - "describe": { - "columns": [ - { - "name": "number", - "ordinal": 0, - "type_info": "Int8" - } - ], - "nullable": [ - null - ], - "parameters": { - "Left": [] - } - }, - "query": "SELECT MAX(number) as \"number\" FROM l1_batches" - }, - "fa6ef06edd04d20ddbdf22a63092222e89bb84d6093b07bda16407811d9c33c0": { - "describe": { - "columns": [ + }, { - "name": "id", - "ordinal": 0, + "name": "index_in_block", + "ordinal": 12, "type_info": "Int4" }, { - "name": "nonce", - "ordinal": 1, - "type_info": "Int8" + "name": "error", + "ordinal": 13, + "type_info": "Varchar" }, { - "name": "raw_tx", - "ordinal": 2, - "type_info": "Bytea" + "name": "gas_limit", + "ordinal": 14, + "type_info": "Numeric" }, { - "name": "contract_address", - "ordinal": 3, - "type_info": "Text" + "name": "gas_per_storage_limit", + "ordinal": 15, + "type_info": "Numeric" }, { - "name": "tx_type", - "ordinal": 4, - "type_info": "Text" + "name": "gas_per_pubdata_limit", + "ordinal": 16, + "type_info": "Numeric" }, { - "name": "gas_used", - "ordinal": 5, - "type_info": "Int8" + "name": "tx_format", + "ordinal": 17, + "type_info": "Int4" }, { "name": "created_at", - "ordinal": 6, + "ordinal": 18, "type_info": "Timestamp" }, { "name": "updated_at", - "ordinal": 7, + "ordinal": 19, "type_info": "Timestamp" }, { - "name": "has_failed", - "ordinal": 8, + "name": "execution_info", + "ordinal": 20, + "type_info": "Jsonb" + }, + { + "name": "contract_address", + "ordinal": 21, + "type_info": "Bytea" + }, + { + "name": "in_mempool", + "ordinal": 22, "type_info": "Bool" }, { - "name": "sent_at_block", - "ordinal": 9, + "name": "l1_block_number", + "ordinal": 23, "type_info": "Int4" }, { - "name": "confirmed_eth_tx_history_id", - "ordinal": 10, + "name": "value", + "ordinal": 24, + "type_info": "Numeric" + }, + { + "name": "paymaster", + "ordinal": 25, + "type_info": "Bytea" + }, + { + "name": "paymaster_input", + "ordinal": 26, + "type_info": "Bytea" + }, + { + "name": "max_fee_per_gas", + "ordinal": 27, + "type_info": "Numeric" + }, + { + "name": "max_priority_fee_per_gas", + "ordinal": 28, + "type_info": "Numeric" + }, + { + "name": "effective_gas_price", + "ordinal": 29, + "type_info": "Numeric" + }, + { + "name": "miniblock_number", + "ordinal": 30, + "type_info": "Int8" + }, + { + "name": "l1_batch_tx_index", + "ordinal": 31, "type_info": "Int4" }, { - "name": "predicted_gas_cost", - "ordinal": 11, + "name": "refunded_gas", + "ordinal": 32, "type_info": "Int8" + }, + { + "name": "l1_tx_mint", + "ordinal": 33, + "type_info": "Numeric" + }, + { + "name": "l1_tx_refund_recipient", + "ordinal": 34, + "type_info": "Bytea" + }, + { + "name": "upgrade_id", + "ordinal": 35, + "type_info": "Int4" } ], "nullable": [ false, false, + true, + true, + false, + true, + true, + true, + false, + false, + true, + true, + true, + true, + true, + true, + true, + true, + false, false, false, + true, false, true, false, @@ -11888,50 +11862,45 @@ false, true, true, - false + true, + true, + true, + false, + true, + true, + true ], "parameters": { "Left": [ - "Int4" - ] - } - }, - "query": "SELECT * FROM eth_txs WHERE id = $1" - }, - "fcca1961f34082f7186de607b922fd608166c5af98031e4dcc8a056b89696dbe": { - "describe": { - "columns": [], - "nullable": [], - "parameters": { - "Left": [ - "Int8", - "Jsonb" + "Int8" ] } }, - "query": "UPDATE miniblocks SET consensus = $2 WHERE number = $1" + "query": "\n SELECT\n *\n FROM\n transactions\n WHERE\n l1_batch_number = $1\n ORDER BY\n miniblock_number,\n index_in_block\n " }, - "ff7ff36b86b0e8d1cd7280aa447baef172cb054ffe7e1d742c59bf09b4f414cb": { + "f717ca5d0890759496739a678955e6f8b7f88a0894a7f9e27fc26f93997d37c7": { "describe": { "columns": [ { - "name": "count!", + "name": "l1_batch_number", "ordinal": 0, "type_info": "Int8" } ], "nullable": [ - null + false ], "parameters": { "Left": [ - "Int4" + "Text", + "Text", + "Text" ] } }, - "query": "SELECT COUNT(*) as \"count!\" FROM prover_protocol_versions WHERE id = $1" + "query": "\n UPDATE proof_compression_jobs_fri\n SET\n status = $1,\n attempts = attempts + 1,\n updated_at = NOW(),\n processing_started_at = NOW(),\n picked_by = $3\n WHERE\n l1_batch_number = (\n SELECT\n l1_batch_number\n FROM\n proof_compression_jobs_fri\n WHERE\n status = $2\n ORDER BY\n l1_batch_number ASC\n LIMIT\n 1\n FOR UPDATE\n SKIP LOCKED\n )\n RETURNING\n proof_compression_jobs_fri.l1_batch_number\n " }, - "ff9c6a53717f0455089e27018e069809891249555e7ee38393927b2b25555fea": { + "f89d5b65ce2c1a82acec40776bc9bab706512f234c0bb50be89b33cc85b66d41": { "describe": { "columns": [ { @@ -12020,14 +11989,14 @@ "type_info": "Int4" }, { - "name": "compressed_state_diffs", + "name": "system_logs", "ordinal": 17, - "type_info": "Bytea" + "type_info": "ByteaArray" }, { - "name": "system_logs", + "name": "compressed_state_diffs", "ordinal": 18, - "type_info": "ByteaArray" + "type_info": "Bytea" } ], "nullable": [ @@ -12048,26 +12017,116 @@ true, true, true, - true, - false + false, + true ], "parameters": { - "Left": [] + "Left": [ + "Int4" + ] + } + }, + "query": "\n SELECT\n number,\n l1_tx_count,\n l2_tx_count,\n timestamp,\n is_finished,\n fee_account_address,\n l2_to_l1_logs,\n l2_to_l1_messages,\n bloom,\n priority_ops_onchain_data,\n used_contract_hashes,\n base_fee_per_gas,\n l1_gas_price,\n l2_fair_gas_price,\n bootloader_code_hash,\n default_aa_code_hash,\n protocol_version,\n system_logs,\n compressed_state_diffs\n FROM\n l1_batches\n WHERE\n eth_commit_tx_id = $1\n OR eth_prove_tx_id = $1\n OR eth_execute_tx_id = $1\n " + }, + "f922c0718c9dda2f285f09cbabad425bac8ed3d2780c60c9b63afbcea131f9a0": { + "describe": { + "columns": [], + "nullable": [], + "parameters": { + "Left": [ + "Bytea", + "Jsonb" + ] + } + }, + "query": "\n INSERT INTO\n transaction_traces (tx_hash, trace, created_at, updated_at)\n VALUES\n ($1, $2, NOW(), NOW())\n " + }, + "fcc108fd59203644ff86ded0505c7dfb7aad7261e5fc402d845aedc3b91a4e99": { + "describe": { + "columns": [ + { + "name": "nonce!", + "ordinal": 0, + "type_info": "Int8" + } + ], + "nullable": [ + true + ], + "parameters": { + "Left": [ + "Bytea", + "Int8" + ] } }, - "query": "SELECT number, l1_tx_count, l2_tx_count, timestamp, is_finished, fee_account_address, l2_to_l1_logs, l2_to_l1_messages, bloom, priority_ops_onchain_data, used_contract_hashes, base_fee_per_gas, l1_gas_price, l2_fair_gas_price, bootloader_code_hash, default_aa_code_hash, protocol_version, compressed_state_diffs, system_logs FROM l1_batches ORDER BY number DESC LIMIT 1" + "query": "\n SELECT\n nonce AS \"nonce!\"\n FROM\n transactions\n WHERE\n initiator_address = $1\n AND nonce >= $2\n AND is_priority = FALSE\n AND (\n miniblock_number IS NOT NULL\n OR error IS NULL\n )\n ORDER BY\n nonce\n " }, - "ffc30c35b713dbde170c0369d5b9f741523778a3f396bd6fa9bfd1705fb4c8ac": { + "fcddeb96dcd1611dedb2091c1be304e8a35fd65bf37e976b7106f57c57e70b9b": { "describe": { "columns": [], "nullable": [], "parameters": { "Left": [ "Text", + "Int4", + "Text" + ] + } + }, + "query": "\n UPDATE gpu_prover_queue_fri\n SET\n instance_status = 'available',\n updated_at = NOW()\n WHERE\n instance_host = $1::TEXT::inet\n AND instance_port = $2\n AND instance_status = 'full'\n AND zone = $3\n " + }, + "fde16cd2d3de03f4b61625fa453a58f82acd817932415f04bcbd05442ad80c2b": { + "describe": { + "columns": [ + { + "name": "bytecode", + "ordinal": 0, + "type_info": "Bytea" + } + ], + "nullable": [ + false + ], + "parameters": { + "Left": [ + "Bytea", + "Int8" + ] + } + }, + "query": "\n SELECT\n bytecode\n FROM\n factory_deps\n WHERE\n bytecode_hash = $1\n AND miniblock_number <= $2\n " + }, + "fdffa5841554286a924b217b5885d9ec9b3f628c3a4cf5e10580ea6e5e3a2429": { + "describe": { + "columns": [], + "nullable": [], + "parameters": { + "Left": [ + "Int8" + ] + } + }, + "query": "\n UPDATE miniblocks\n SET\n l1_batch_number = $1\n WHERE\n l1_batch_number IS NULL\n " + }, + "fe501f86f4bf6c5b8ccc2e039a4eb09b538a67d1c39fda052c4f4ddb23ce0084": { + "describe": { + "columns": [ + { + "name": "l2_to_l1_logs", + "ordinal": 0, + "type_info": "ByteaArray" + } + ], + "nullable": [ + false + ], + "parameters": { + "Left": [ "Int8" ] } }, - "query": "UPDATE proof_compression_jobs_fri SET status = $1, updated_at = now() WHERE l1_batch_number = $2" + "query": "\n SELECT\n l2_to_l1_logs\n FROM\n l1_batches\n WHERE\n number = $1\n " } } diff --git a/core/lib/dal/src/accounts_dal.rs b/core/lib/dal/src/accounts_dal.rs index bbd43c80ac0b..a1323bf9517b 100644 --- a/core/lib/dal/src/accounts_dal.rs +++ b/core/lib/dal/src/accounts_dal.rs @@ -43,13 +43,24 @@ impl AccountsDal<'_, '_> { .collect(); let rows = sqlx::query!( r#" - SELECT storage.value as "value!", - tokens.l1_address as "l1_address!", tokens.l2_address as "l2_address!", - tokens.symbol as "symbol!", tokens.name as "name!", tokens.decimals as "decimals!", tokens.usd_price as "usd_price?" - FROM storage - INNER JOIN tokens ON - storage.address = tokens.l2_address OR (storage.address = $2 AND tokens.l2_address = $3) - WHERE storage.hashed_key = ANY($1) AND storage.value != $4 + SELECT + storage.value AS "value!", + tokens.l1_address AS "l1_address!", + tokens.l2_address AS "l2_address!", + tokens.symbol AS "symbol!", + tokens.name AS "name!", + tokens.decimals AS "decimals!", + tokens.usd_price AS "usd_price?" + FROM + storage + INNER JOIN tokens ON storage.address = tokens.l2_address + OR ( + storage.address = $2 + AND tokens.l2_address = $3 + ) + WHERE + storage.hashed_key = ANY ($1) + AND storage.value != $4 "#, &hashed_keys, L2_ETH_TOKEN_ADDRESS.as_bytes(), diff --git a/core/lib/dal/src/basic_witness_input_producer_dal.rs b/core/lib/dal/src/basic_witness_input_producer_dal.rs index cae640e94b83..c0d38516b161 100644 --- a/core/lib/dal/src/basic_witness_input_producer_dal.rs +++ b/core/lib/dal/src/basic_witness_input_producer_dal.rs @@ -51,10 +51,13 @@ impl BasicWitnessInputProducerDal<'_, '_> { l1_batch_number: L1BatchNumber, ) -> sqlx::Result<()> { sqlx::query!( - "INSERT INTO basic_witness_input_producer_jobs \ - (l1_batch_number, status, created_at, updated_at) \ - VALUES ($1, $2, now(), now()) \ - ON CONFLICT (l1_batch_number) DO NOTHING", + r#" + INSERT INTO + basic_witness_input_producer_jobs (l1_batch_number, status, created_at, updated_at) + VALUES + ($1, $2, NOW(), NOW()) + ON CONFLICT (l1_batch_number) DO NOTHING + "#, l1_batch_number.0 as i64, BasicWitnessInputProducerJobStatus::Queued as BasicWitnessInputProducerJobStatus, ) @@ -70,23 +73,39 @@ impl BasicWitnessInputProducerDal<'_, '_> { &mut self, ) -> sqlx::Result> { let l1_batch_number = sqlx::query!( - "UPDATE basic_witness_input_producer_jobs \ - SET status = $1, \ - attempts = attempts + 1, \ - updated_at = now(), \ - processing_started_at = now() \ - WHERE l1_batch_number = ( \ - SELECT l1_batch_number \ - FROM basic_witness_input_producer_jobs \ - WHERE status = $2 OR \ - (status = $1 AND processing_started_at < now() - $4::interval) OR \ - (status = $3 AND attempts < $5) \ - ORDER BY l1_batch_number ASC \ - LIMIT 1 \ - FOR UPDATE \ - SKIP LOCKED \ - ) \ - RETURNING basic_witness_input_producer_jobs.l1_batch_number", + r#" + UPDATE basic_witness_input_producer_jobs + SET + status = $1, + attempts = attempts + 1, + updated_at = NOW(), + processing_started_at = NOW() + WHERE + l1_batch_number = ( + SELECT + l1_batch_number + FROM + basic_witness_input_producer_jobs + WHERE + status = $2 + OR ( + status = $1 + AND processing_started_at < NOW() - $4::INTERVAL + ) + OR ( + status = $3 + AND attempts < $5 + ) + ORDER BY + l1_batch_number ASC + LIMIT + 1 + FOR UPDATE + SKIP LOCKED + ) + RETURNING + basic_witness_input_producer_jobs.l1_batch_number + "#, BasicWitnessInputProducerJobStatus::InProgress as BasicWitnessInputProducerJobStatus, BasicWitnessInputProducerJobStatus::Queued as BasicWitnessInputProducerJobStatus, BasicWitnessInputProducerJobStatus::Failed as BasicWitnessInputProducerJobStatus, @@ -107,8 +126,14 @@ impl BasicWitnessInputProducerDal<'_, '_> { l1_batch_number: L1BatchNumber, ) -> sqlx::Result> { let attempts = sqlx::query!( - "SELECT attempts FROM basic_witness_input_producer_jobs \ - WHERE l1_batch_number = $1", + r#" + SELECT + attempts + FROM + basic_witness_input_producer_jobs + WHERE + l1_batch_number = $1 + "#, l1_batch_number.0 as i64, ) .fetch_optional(self.storage.conn()) @@ -125,12 +150,16 @@ impl BasicWitnessInputProducerDal<'_, '_> { object_path: &str, ) -> sqlx::Result<()> { sqlx::query!( - "UPDATE basic_witness_input_producer_jobs \ - SET status = $1, \ - updated_at = now(), \ - time_taken = $3, \ - input_blob_url = $4 \ - WHERE l1_batch_number = $2", + r#" + UPDATE basic_witness_input_producer_jobs + SET + status = $1, + updated_at = NOW(), + time_taken = $3, + input_blob_url = $4 + WHERE + l1_batch_number = $2 + "#, BasicWitnessInputProducerJobStatus::Successful as BasicWitnessInputProducerJobStatus, l1_batch_number.0 as i64, duration_to_naive_time(started_at.elapsed()), @@ -151,13 +180,19 @@ impl BasicWitnessInputProducerDal<'_, '_> { error: String, ) -> sqlx::Result> { let attempts = sqlx::query!( - "UPDATE basic_witness_input_producer_jobs \ - SET status = $1, \ - updated_at = now(), \ - time_taken = $3, \ - error = $4 \ - WHERE l1_batch_number = $2 AND status != $5 \ - RETURNING basic_witness_input_producer_jobs.attempts", + r#" + UPDATE basic_witness_input_producer_jobs + SET + status = $1, + updated_at = NOW(), + time_taken = $3, + error = $4 + WHERE + l1_batch_number = $2 + AND status != $5 + RETURNING + basic_witness_input_producer_jobs.attempts + "#, BasicWitnessInputProducerJobStatus::Failed as BasicWitnessInputProducerJobStatus, l1_batch_number.0 as i64, duration_to_naive_time(started_at.elapsed()), @@ -177,9 +212,13 @@ impl BasicWitnessInputProducerDal<'_, '_> { /// These functions should only be used for tests. impl BasicWitnessInputProducerDal<'_, '_> { pub async fn delete_all_jobs(&mut self) -> sqlx::Result<()> { - sqlx::query!("DELETE FROM basic_witness_input_producer_jobs") - .execute(self.storage.conn()) - .await?; + sqlx::query!( + r#" + DELETE FROM basic_witness_input_producer_jobs + "# + ) + .execute(self.storage.conn()) + .await?; Ok(()) } } diff --git a/core/lib/dal/src/blocks_dal.rs b/core/lib/dal/src/blocks_dal.rs index 8eeb994fd586..555856c1bba3 100644 --- a/core/lib/dal/src/blocks_dal.rs +++ b/core/lib/dal/src/blocks_dal.rs @@ -29,16 +29,30 @@ pub struct BlocksDal<'a, 'c> { impl BlocksDal<'_, '_> { pub async fn is_genesis_needed(&mut self) -> sqlx::Result { - let count = sqlx::query!("SELECT COUNT(*) as \"count!\" FROM l1_batches") - .fetch_one(self.storage.conn()) - .await? - .count; + let count = sqlx::query!( + r#" + SELECT + COUNT(*) AS "count!" + FROM + l1_batches + "# + ) + .fetch_one(self.storage.conn()) + .await? + .count; Ok(count == 0) } pub async fn get_sealed_l1_batch_number(&mut self) -> anyhow::Result { let number = sqlx::query!( - "SELECT MAX(number) as \"number\" FROM l1_batches WHERE is_finished = TRUE" + r#" + SELECT + MAX(number) AS "number" + FROM + l1_batches + WHERE + is_finished = TRUE + "# ) .instrument("get_sealed_block_number") .report_latency() @@ -51,27 +65,42 @@ impl BlocksDal<'_, '_> { } pub async fn get_sealed_miniblock_number(&mut self) -> sqlx::Result { - let number: i64 = sqlx::query!("SELECT MAX(number) as \"number\" FROM miniblocks") - .instrument("get_sealed_miniblock_number") - .report_latency() - .fetch_one(self.storage.conn()) - .await? - .number - .unwrap_or(0); + let number: i64 = sqlx::query!( + r#" + SELECT + MAX(number) AS "number" + FROM + miniblocks + "# + ) + .instrument("get_sealed_miniblock_number") + .report_latency() + .fetch_one(self.storage.conn()) + .await? + .number + .unwrap_or(0); Ok(MiniblockNumber(number as u32)) } pub async fn get_last_l1_batch_number_with_metadata( &mut self, ) -> anyhow::Result { - let number: i64 = - sqlx::query!("SELECT MAX(number) as \"number\" FROM l1_batches WHERE hash IS NOT NULL") - .instrument("get_last_block_number_with_metadata") - .report_latency() - .fetch_one(self.storage.conn()) - .await? - .number - .context("DAL invocation before genesis")?; + let number: i64 = sqlx::query!( + r#" + SELECT + MAX(number) AS "number" + FROM + l1_batches + WHERE + hash IS NOT NULL + "# + ) + .instrument("get_last_block_number_with_metadata") + .report_latency() + .fetch_one(self.storage.conn()) + .await? + .number + .context("DAL invocation before genesis")?; Ok(L1BatchNumber(number as u32)) } @@ -81,16 +110,34 @@ impl BlocksDal<'_, '_> { ) -> sqlx::Result> { let l1_batches = sqlx::query_as!( StorageL1BatchHeader, - "SELECT number, l1_tx_count, l2_tx_count, \ - timestamp, is_finished, fee_account_address, l2_to_l1_logs, l2_to_l1_messages, \ - bloom, priority_ops_onchain_data, \ - used_contract_hashes, base_fee_per_gas, l1_gas_price, \ - l2_fair_gas_price, bootloader_code_hash, default_aa_code_hash, protocol_version, \ - system_logs, compressed_state_diffs \ - FROM l1_batches \ - WHERE eth_commit_tx_id = $1 \ - OR eth_prove_tx_id = $1 \ - OR eth_execute_tx_id = $1", + r#" + SELECT + number, + l1_tx_count, + l2_tx_count, + timestamp, + is_finished, + fee_account_address, + l2_to_l1_logs, + l2_to_l1_messages, + bloom, + priority_ops_onchain_data, + used_contract_hashes, + base_fee_per_gas, + l1_gas_price, + l2_fair_gas_price, + bootloader_code_hash, + default_aa_code_hash, + protocol_version, + system_logs, + compressed_state_diffs + FROM + l1_batches + WHERE + eth_commit_tx_id = $1 + OR eth_prove_tx_id = $1 + OR eth_execute_tx_id = $1 + "#, eth_tx_id as i32 ) .instrument("get_l1_batches_for_eth_tx_id") @@ -107,19 +154,53 @@ impl BlocksDal<'_, '_> { ) -> sqlx::Result> { sqlx::query_as!( StorageL1Batch, - "SELECT number, timestamp, is_finished, l1_tx_count, l2_tx_count, fee_account_address, \ - bloom, priority_ops_onchain_data, hash, parent_hash, commitment, compressed_write_logs, \ - compressed_contracts, eth_prove_tx_id, eth_commit_tx_id, eth_execute_tx_id, \ - merkle_root_hash, l2_to_l1_logs, l2_to_l1_messages, \ - used_contract_hashes, compressed_initial_writes, compressed_repeated_writes, \ - l2_l1_compressed_messages, l2_l1_merkle_root, l1_gas_price, l2_fair_gas_price, \ - rollup_last_leaf_index, zkporter_is_available, bootloader_code_hash, \ - default_aa_code_hash, base_fee_per_gas, aux_data_hash, pass_through_data_hash, \ - meta_parameters_hash, protocol_version, system_logs, compressed_state_diffs, \ - events_queue_commitment, bootloader_initial_content_commitment \ - FROM l1_batches \ - LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number \ - WHERE number = $1", + r#" + SELECT + number, + timestamp, + is_finished, + l1_tx_count, + l2_tx_count, + fee_account_address, + bloom, + priority_ops_onchain_data, + hash, + parent_hash, + commitment, + compressed_write_logs, + compressed_contracts, + eth_prove_tx_id, + eth_commit_tx_id, + eth_execute_tx_id, + merkle_root_hash, + l2_to_l1_logs, + l2_to_l1_messages, + used_contract_hashes, + compressed_initial_writes, + compressed_repeated_writes, + l2_l1_compressed_messages, + l2_l1_merkle_root, + l1_gas_price, + l2_fair_gas_price, + rollup_last_leaf_index, + zkporter_is_available, + bootloader_code_hash, + default_aa_code_hash, + base_fee_per_gas, + aux_data_hash, + pass_through_data_hash, + meta_parameters_hash, + protocol_version, + system_logs, + compressed_state_diffs, + events_queue_commitment, + bootloader_initial_content_commitment + FROM + l1_batches + LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number + WHERE + number = $1 + "#, number.0 as i64 ) .instrument("get_storage_l1_batch") @@ -134,14 +215,32 @@ impl BlocksDal<'_, '_> { ) -> sqlx::Result> { Ok(sqlx::query_as!( StorageL1BatchHeader, - "SELECT number, l1_tx_count, l2_tx_count, \ - timestamp, is_finished, fee_account_address, l2_to_l1_logs, l2_to_l1_messages, \ - bloom, priority_ops_onchain_data, \ - used_contract_hashes, base_fee_per_gas, l1_gas_price, \ - l2_fair_gas_price, bootloader_code_hash, default_aa_code_hash, protocol_version, \ - compressed_state_diffs, system_logs \ - FROM l1_batches \ - WHERE number = $1", + r#" + SELECT + number, + l1_tx_count, + l2_tx_count, + timestamp, + is_finished, + fee_account_address, + l2_to_l1_logs, + l2_to_l1_messages, + bloom, + priority_ops_onchain_data, + used_contract_hashes, + base_fee_per_gas, + l1_gas_price, + l2_fair_gas_price, + bootloader_code_hash, + default_aa_code_hash, + protocol_version, + compressed_state_diffs, + system_logs + FROM + l1_batches + WHERE + number = $1 + "#, number.0 as i64 ) .instrument("get_l1_batch_header") @@ -157,7 +256,14 @@ impl BlocksDal<'_, '_> { number: L1BatchNumber, ) -> anyhow::Result>> { let Some(row) = sqlx::query!( - "SELECT initial_bootloader_heap_content FROM l1_batches WHERE number = $1", + r#" + SELECT + initial_bootloader_heap_content + FROM + l1_batches + WHERE + number = $1 + "#, number.0 as i64 ) .instrument("get_initial_bootloader_heap") @@ -179,7 +285,14 @@ impl BlocksDal<'_, '_> { number: L1BatchNumber, ) -> anyhow::Result>> { let Some(row) = sqlx::query!( - "SELECT storage_refunds FROM l1_batches WHERE number = $1", + r#" + SELECT + storage_refunds + FROM + l1_batches + WHERE + number = $1 + "#, number.0 as i64 ) .instrument("get_storage_refunds") @@ -203,7 +316,14 @@ impl BlocksDal<'_, '_> { number: L1BatchNumber, ) -> anyhow::Result>> { let Some(row) = sqlx::query!( - "SELECT serialized_events_queue FROM events_queue WHERE l1_batch_number = $1", + r#" + SELECT + serialized_events_queue + FROM + events_queue + WHERE + l1_batch_number = $1 + "#, number.0 as i64 ) .instrument("get_events_queue") @@ -229,9 +349,14 @@ impl BlocksDal<'_, '_> { match aggregation_type { AggregatedActionType::Commit => { sqlx::query!( - "UPDATE l1_batches \ - SET eth_commit_tx_id = $1, updated_at = now() \ - WHERE number BETWEEN $2 AND $3", + r#" + UPDATE l1_batches + SET + eth_commit_tx_id = $1, + updated_at = NOW() + WHERE + number BETWEEN $2 AND $3 + "#, eth_tx_id as i32, number_range.start().0 as i64, number_range.end().0 as i64 @@ -241,9 +366,14 @@ impl BlocksDal<'_, '_> { } AggregatedActionType::PublishProofOnchain => { sqlx::query!( - "UPDATE l1_batches \ - SET eth_prove_tx_id = $1, updated_at = now() \ - WHERE number BETWEEN $2 AND $3", + r#" + UPDATE l1_batches + SET + eth_prove_tx_id = $1, + updated_at = NOW() + WHERE + number BETWEEN $2 AND $3 + "#, eth_tx_id as i32, number_range.start().0 as i64, number_range.end().0 as i64 @@ -253,9 +383,14 @@ impl BlocksDal<'_, '_> { } AggregatedActionType::Execute => { sqlx::query!( - "UPDATE l1_batches \ - SET eth_execute_tx_id = $1, updated_at = now() \ - WHERE number BETWEEN $2 AND $3", + r#" + UPDATE l1_batches + SET + eth_execute_tx_id = $1, + updated_at = NOW() + WHERE + number BETWEEN $2 AND $3 + "#, eth_tx_id as i32, number_range.start().0 as i64, number_range.end().0 as i64 @@ -305,15 +440,64 @@ impl BlocksDal<'_, '_> { let mut transaction = self.storage.start_transaction().await?; sqlx::query!( - "INSERT INTO l1_batches (\ - number, l1_tx_count, l2_tx_count, \ - timestamp, is_finished, fee_account_address, l2_to_l1_logs, l2_to_l1_messages, \ - bloom, priority_ops_onchain_data, \ - predicted_commit_gas_cost, predicted_prove_gas_cost, predicted_execute_gas_cost, \ - initial_bootloader_heap_content, used_contract_hashes, base_fee_per_gas, \ - l1_gas_price, l2_fair_gas_price, bootloader_code_hash, default_aa_code_hash, protocol_version, system_logs, \ - storage_refunds, created_at, updated_at \ - ) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, now(), now())", + r#" + INSERT INTO + l1_batches ( + number, + l1_tx_count, + l2_tx_count, + timestamp, + is_finished, + fee_account_address, + l2_to_l1_logs, + l2_to_l1_messages, + bloom, + priority_ops_onchain_data, + predicted_commit_gas_cost, + predicted_prove_gas_cost, + predicted_execute_gas_cost, + initial_bootloader_heap_content, + used_contract_hashes, + base_fee_per_gas, + l1_gas_price, + l2_fair_gas_price, + bootloader_code_hash, + default_aa_code_hash, + protocol_version, + system_logs, + storage_refunds, + created_at, + updated_at + ) + VALUES + ( + $1, + $2, + $3, + $4, + $5, + $6, + $7, + $8, + $9, + $10, + $11, + $12, + $13, + $14, + $15, + $16, + $17, + $18, + $19, + $20, + $21, + $22, + $23, + NOW(), + NOW() + ) + "#, header.number.0 as i64, header.l1_tx_count as i32, header.l2_tx_count as i32, @@ -332,14 +516,8 @@ impl BlocksDal<'_, '_> { base_fee_per_gas, header.l1_gas_price as i64, header.l2_fair_gas_price as i64, - header - .base_system_contracts_hashes - .bootloader - .as_bytes(), - header - .base_system_contracts_hashes - .default_aa - .as_bytes(), + header.base_system_contracts_hashes.bootloader.as_bytes(), + header.base_system_contracts_hashes.default_aa.as_bytes(), header.protocol_version.map(|v| v as i32), &system_logs, &storage_refunds, @@ -348,7 +526,12 @@ impl BlocksDal<'_, '_> { .await?; sqlx::query!( - "INSERT INTO events_queue (l1_batch_number, serialized_events_queue) VALUES ($1, $2)", + r#" + INSERT INTO + events_queue (l1_batch_number, serialized_events_queue) + VALUES + ($1, $2) + "#, header.number.0 as i64, events_queue ) @@ -366,12 +549,28 @@ impl BlocksDal<'_, '_> { let base_fee_per_gas = BigDecimal::from_u64(miniblock_header.base_fee_per_gas) .context("base_fee_per_gas should fit in u64")?; sqlx::query!( - "INSERT INTO miniblocks ( \ - number, timestamp, hash, l1_tx_count, l2_tx_count, \ - base_fee_per_gas, l1_gas_price, l2_fair_gas_price, gas_per_pubdata_limit, \ - bootloader_code_hash, default_aa_code_hash, protocol_version, \ - virtual_blocks, created_at, updated_at \ - ) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, now(), now())", + r#" + INSERT INTO + miniblocks ( + number, + timestamp, + hash, + l1_tx_count, + l2_tx_count, + base_fee_per_gas, + l1_gas_price, + l2_fair_gas_price, + gas_per_pubdata_limit, + bootloader_code_hash, + default_aa_code_hash, + protocol_version, + virtual_blocks, + created_at, + updated_at + ) + VALUES + ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, NOW(), NOW()) + "#, miniblock_header.number.0 as i64, miniblock_header.timestamp as i64, miniblock_header.hash.as_bytes(), @@ -406,18 +605,46 @@ impl BlocksDal<'_, '_> { pub async fn get_last_miniblock_number_with_consensus_fields( &mut self, ) -> anyhow::Result> { - let Some(row) = sqlx::query!("SELECT number FROM miniblocks WHERE consensus IS NOT NULL ORDER BY number DESC LIMIT 1") - .fetch_optional(self.storage.conn()) - .await? else { return Ok(None) }; + let Some(row) = sqlx::query!( + r#" + SELECT + number + FROM + miniblocks + WHERE + consensus IS NOT NULL + ORDER BY + number DESC + LIMIT + 1 + "# + ) + .fetch_optional(self.storage.conn()) + .await? + else { + return Ok(None); + }; Ok(Some(MiniblockNumber(row.number.try_into()?))) } /// Checks whether the specified miniblock has consensus field set. pub async fn has_consensus_fields(&mut self, number: MiniblockNumber) -> sqlx::Result { - Ok(sqlx::query!("SELECT COUNT(*) as \"count!\" FROM miniblocks WHERE number = $1 AND consensus IS NOT NULL", number.0 as i64) - .fetch_one(self.storage.conn()) - .await? - .count > 0) + Ok(sqlx::query!( + r#" + SELECT + COUNT(*) AS "count!" + FROM + miniblocks + WHERE + number = $1 + AND consensus IS NOT NULL + "#, + number.0 as i64 + ) + .fetch_one(self.storage.conn()) + .await? + .count + > 0) } /// Sets consensus-related fields for the specified miniblock. @@ -427,7 +654,13 @@ impl BlocksDal<'_, '_> { consensus: &ConsensusBlockFields, ) -> anyhow::Result<()> { let result = sqlx::query!( - "UPDATE miniblocks SET consensus = $2 WHERE number = $1", + r#" + UPDATE miniblocks + SET + consensus = $2 + WHERE + number = $1 + "#, miniblock_number.0 as i64, zksync_protobuf::serde::serialize(consensus, serde_json::value::Serializer).unwrap(), ) @@ -446,13 +679,27 @@ impl BlocksDal<'_, '_> { ) -> sqlx::Result> { Ok(sqlx::query_as!( StorageMiniblockHeader, - "SELECT number, timestamp, hash, l1_tx_count, l2_tx_count, \ - base_fee_per_gas, l1_gas_price, l2_fair_gas_price, \ - bootloader_code_hash, default_aa_code_hash, protocol_version, \ + r#" + SELECT + number, + timestamp, + hash, + l1_tx_count, + l2_tx_count, + base_fee_per_gas, + l1_gas_price, + l2_fair_gas_price, + bootloader_code_hash, + default_aa_code_hash, + protocol_version, virtual_blocks - FROM miniblocks \ - ORDER BY number DESC \ - LIMIT 1", + FROM + miniblocks + ORDER BY + number DESC + LIMIT + 1 + "#, ) .fetch_optional(self.storage.conn()) .await? @@ -465,12 +712,25 @@ impl BlocksDal<'_, '_> { ) -> sqlx::Result> { Ok(sqlx::query_as!( StorageMiniblockHeader, - "SELECT number, timestamp, hash, l1_tx_count, l2_tx_count, \ - base_fee_per_gas, l1_gas_price, l2_fair_gas_price, \ - bootloader_code_hash, default_aa_code_hash, protocol_version, \ + r#" + SELECT + number, + timestamp, + hash, + l1_tx_count, + l2_tx_count, + base_fee_per_gas, + l1_gas_price, + l2_fair_gas_price, + bootloader_code_hash, + default_aa_code_hash, + protocol_version, virtual_blocks - FROM miniblocks \ - WHERE number = $1", + FROM + miniblocks + WHERE + number = $1 + "#, miniblock_number.0 as i64, ) .fetch_optional(self.storage.conn()) @@ -483,9 +743,13 @@ impl BlocksDal<'_, '_> { l1_batch_number: L1BatchNumber, ) -> sqlx::Result<()> { sqlx::query!( - "UPDATE miniblocks \ - SET l1_batch_number = $1 \ - WHERE l1_batch_number IS NULL", + r#" + UPDATE miniblocks + SET + l1_batch_number = $1 + WHERE + l1_batch_number IS NULL + "#, l1_batch_number.0 as i32, ) .execute(self.storage.conn()) @@ -498,14 +762,28 @@ impl BlocksDal<'_, '_> { metadata: &L1BatchMetadata, ) -> sqlx::Result<()> { sqlx::query!( - "UPDATE l1_batches \ - SET hash = $1, merkle_root_hash = $2, commitment = $3, default_aa_code_hash = $4, \ - compressed_repeated_writes = $5, compressed_initial_writes = $6, \ - l2_l1_compressed_messages = $7, l2_l1_merkle_root = $8, \ - zkporter_is_available = $9, bootloader_code_hash = $10, rollup_last_leaf_index = $11, \ - aux_data_hash = $12, pass_through_data_hash = $13, meta_parameters_hash = $14, \ - compressed_state_diffs = $15, updated_at = now() \ - WHERE number = $16", + r#" + UPDATE l1_batches + SET + hash = $1, + merkle_root_hash = $2, + commitment = $3, + default_aa_code_hash = $4, + compressed_repeated_writes = $5, + compressed_initial_writes = $6, + l2_l1_compressed_messages = $7, + l2_l1_merkle_root = $8, + zkporter_is_available = $9, + bootloader_code_hash = $10, + rollup_last_leaf_index = $11, + aux_data_hash = $12, + pass_through_data_hash = $13, + meta_parameters_hash = $14, + compressed_state_diffs = $15, + updated_at = NOW() + WHERE + number = $16 + "#, metadata.root_hash.as_bytes(), metadata.merkle_root_hash.as_bytes(), metadata.commitment.as_bytes(), @@ -538,14 +816,26 @@ impl BlocksDal<'_, '_> { let mut transaction = self.storage.start_transaction().await?; let update_result = sqlx::query!( - "UPDATE l1_batches \ - SET hash = $1, merkle_root_hash = $2, \ - compressed_repeated_writes = $3, compressed_initial_writes = $4, \ - l2_l1_compressed_messages = $5, l2_l1_merkle_root = $6, \ - zkporter_is_available = $7, parent_hash = $8, rollup_last_leaf_index = $9, \ - pass_through_data_hash = $10, meta_parameters_hash = $11, \ - compressed_state_diffs = $12, updated_at = now() \ - WHERE number = $13 AND hash IS NULL", + r#" + UPDATE l1_batches + SET + hash = $1, + merkle_root_hash = $2, + compressed_repeated_writes = $3, + compressed_initial_writes = $4, + l2_l1_compressed_messages = $5, + l2_l1_merkle_root = $6, + zkporter_is_available = $7, + parent_hash = $8, + rollup_last_leaf_index = $9, + pass_through_data_hash = $10, + meta_parameters_hash = $11, + compressed_state_diffs = $12, + updated_at = NOW() + WHERE + number = $13 + AND hash IS NULL + "#, metadata.root_hash.as_bytes(), metadata.merkle_root_hash.as_bytes(), metadata.repeated_writes_compressed, @@ -569,9 +859,13 @@ impl BlocksDal<'_, '_> { if metadata.events_queue_commitment.is_some() || is_pre_boojum { // Save `commitment`, `aux_data_hash`, `events_queue_commitment`, `bootloader_initial_content_commitment`. sqlx::query!( - "INSERT INTO commitments (l1_batch_number, events_queue_commitment, bootloader_initial_content_commitment) \ - VALUES ($1, $2, $3) \ - ON CONFLICT (l1_batch_number) DO NOTHING", + r#" + INSERT INTO + commitments (l1_batch_number, events_queue_commitment, bootloader_initial_content_commitment) + VALUES + ($1, $2, $3) + ON CONFLICT (l1_batch_number) DO NOTHING + "#, number.0 as i64, metadata.events_queue_commitment.map(|h| h.0.to_vec()), metadata @@ -585,9 +879,15 @@ impl BlocksDal<'_, '_> { .await?; sqlx::query!( - "UPDATE l1_batches \ - SET commitment = $2, aux_data_hash = $3, updated_at = now() \ - WHERE number = $1", + r#" + UPDATE l1_batches + SET + commitment = $2, + aux_data_hash = $3, + updated_at = NOW() + WHERE + number = $1 + "#, number.0 as i64, metadata.commitment.as_bytes(), metadata.aux_data_hash.as_bytes(), @@ -613,10 +913,18 @@ impl BlocksDal<'_, '_> { // block was already processed. Verify that existing hashes match let matched: i64 = sqlx::query!( - "SELECT COUNT(*) as \"count!\" \ - FROM l1_batches \ - WHERE number = $1 AND hash = $2 AND merkle_root_hash = $3 \ - AND parent_hash = $4 AND l2_l1_merkle_root = $5", + r#" + SELECT + COUNT(*) AS "count!" + FROM + l1_batches + WHERE + number = $1 + AND hash = $2 + AND merkle_root_hash = $3 + AND parent_hash = $4 + AND l2_l1_merkle_root = $5 + "#, number.0 as i64, metadata.root_hash.as_bytes(), metadata.merkle_root_hash.as_bytes(), @@ -648,21 +956,59 @@ impl BlocksDal<'_, '_> { // We can get 0 block for the first transaction let block = sqlx::query_as!( StorageL1Batch, - "SELECT number, timestamp, is_finished, l1_tx_count, l2_tx_count, fee_account_address, \ - bloom, priority_ops_onchain_data, hash, parent_hash, commitment, compressed_write_logs, \ - compressed_contracts, eth_prove_tx_id, eth_commit_tx_id, eth_execute_tx_id, \ - merkle_root_hash, l2_to_l1_logs, l2_to_l1_messages, \ - used_contract_hashes, compressed_initial_writes, compressed_repeated_writes, \ - l2_l1_compressed_messages, l2_l1_merkle_root, l1_gas_price, l2_fair_gas_price, \ - rollup_last_leaf_index, zkporter_is_available, bootloader_code_hash, \ - default_aa_code_hash, base_fee_per_gas, aux_data_hash, pass_through_data_hash, \ - meta_parameters_hash, protocol_version, compressed_state_diffs, \ - system_logs, events_queue_commitment, bootloader_initial_content_commitment - FROM l1_batches \ - LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number \ - WHERE number = 0 OR eth_commit_tx_id IS NOT NULL AND commitment IS NOT NULL \ - ORDER BY number DESC \ - LIMIT 1", + r#" + SELECT + number, + timestamp, + is_finished, + l1_tx_count, + l2_tx_count, + fee_account_address, + bloom, + priority_ops_onchain_data, + hash, + parent_hash, + commitment, + compressed_write_logs, + compressed_contracts, + eth_prove_tx_id, + eth_commit_tx_id, + eth_execute_tx_id, + merkle_root_hash, + l2_to_l1_logs, + l2_to_l1_messages, + used_contract_hashes, + compressed_initial_writes, + compressed_repeated_writes, + l2_l1_compressed_messages, + l2_l1_merkle_root, + l1_gas_price, + l2_fair_gas_price, + rollup_last_leaf_index, + zkporter_is_available, + bootloader_code_hash, + default_aa_code_hash, + base_fee_per_gas, + aux_data_hash, + pass_through_data_hash, + meta_parameters_hash, + protocol_version, + compressed_state_diffs, + system_logs, + events_queue_commitment, + bootloader_initial_content_commitment + FROM + l1_batches + LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number + WHERE + number = 0 + OR eth_commit_tx_id IS NOT NULL + AND commitment IS NOT NULL + ORDER BY + number DESC + LIMIT + 1 + "#, ) .instrument("get_last_committed_to_eth_l1_batch") .fetch_one(self.storage.conn()) @@ -682,11 +1028,19 @@ impl BlocksDal<'_, '_> { &mut self, ) -> Result, sqlx::Error> { Ok(sqlx::query!( - "SELECT number FROM l1_batches \ - LEFT JOIN eth_txs_history AS commit_tx \ - ON (l1_batches.eth_commit_tx_id = commit_tx.eth_tx_id) \ - WHERE commit_tx.confirmed_at IS NOT NULL \ - ORDER BY number DESC LIMIT 1" + r#" + SELECT + number + FROM + l1_batches + LEFT JOIN eth_txs_history AS commit_tx ON (l1_batches.eth_commit_tx_id = commit_tx.eth_tx_id) + WHERE + commit_tx.confirmed_at IS NOT NULL + ORDER BY + number DESC + LIMIT + 1 + "# ) .fetch_optional(self.storage.conn()) .await? @@ -696,9 +1050,14 @@ impl BlocksDal<'_, '_> { /// Returns the number of the last L1 batch for which an Ethereum prove tx exists in the database. pub async fn get_last_l1_batch_with_prove_tx(&mut self) -> sqlx::Result { let row = sqlx::query!( - "SELECT COALESCE(MAX(number), 0) AS \"number!\" \ - FROM l1_batches \ - WHERE eth_prove_tx_id IS NOT NULL" + r#" + SELECT + COALESCE(MAX(number), 0) AS "number!" + FROM + l1_batches + WHERE + eth_prove_tx_id IS NOT NULL + "# ) .fetch_one(self.storage.conn()) .await?; @@ -711,8 +1070,14 @@ impl BlocksDal<'_, '_> { l1_batch_number: L1BatchNumber, ) -> sqlx::Result> { let row = sqlx::query!( - "SELECT eth_commit_tx_id FROM l1_batches \ - WHERE number = $1", + r#" + SELECT + eth_commit_tx_id + FROM + l1_batches + WHERE + number = $1 + "#, l1_batch_number.0 as i64 ) .fetch_optional(self.storage.conn()) @@ -726,11 +1091,19 @@ impl BlocksDal<'_, '_> { &mut self, ) -> sqlx::Result> { Ok(sqlx::query!( - "SELECT number FROM l1_batches \ - LEFT JOIN eth_txs_history AS prove_tx \ - ON (l1_batches.eth_prove_tx_id = prove_tx.eth_tx_id) \ - WHERE prove_tx.confirmed_at IS NOT NULL \ - ORDER BY number DESC LIMIT 1" + r#" + SELECT + number + FROM + l1_batches + LEFT JOIN eth_txs_history AS prove_tx ON (l1_batches.eth_prove_tx_id = prove_tx.eth_tx_id) + WHERE + prove_tx.confirmed_at IS NOT NULL + ORDER BY + number DESC + LIMIT + 1 + "# ) .fetch_optional(self.storage.conn()) .await? @@ -742,11 +1115,19 @@ impl BlocksDal<'_, '_> { &mut self, ) -> sqlx::Result> { Ok(sqlx::query!( - "SELECT number FROM l1_batches \ - LEFT JOIN eth_txs_history as execute_tx \ - ON (l1_batches.eth_execute_tx_id = execute_tx.eth_tx_id) \ - WHERE execute_tx.confirmed_at IS NOT NULL \ - ORDER BY number DESC LIMIT 1" + r#" + SELECT + number + FROM + l1_batches + LEFT JOIN eth_txs_history AS execute_tx ON (l1_batches.eth_execute_tx_id = execute_tx.eth_tx_id) + WHERE + execute_tx.confirmed_at IS NOT NULL + ORDER BY + number DESC + LIMIT + 1 + "# ) .fetch_optional(self.storage.conn()) .await? @@ -760,20 +1141,58 @@ impl BlocksDal<'_, '_> { ) -> anyhow::Result> { let raw_batches = sqlx::query_as!( StorageL1Batch, - "SELECT number, timestamp, is_finished, l1_tx_count, l2_tx_count, fee_account_address, \ - bloom, priority_ops_onchain_data, hash, parent_hash, commitment, compressed_write_logs, \ - compressed_contracts, eth_prove_tx_id, eth_commit_tx_id, eth_execute_tx_id, \ - merkle_root_hash, l2_to_l1_logs, l2_to_l1_messages, \ - used_contract_hashes, compressed_initial_writes, compressed_repeated_writes, \ - l2_l1_compressed_messages, l2_l1_merkle_root, l1_gas_price, l2_fair_gas_price, \ - rollup_last_leaf_index, zkporter_is_available, bootloader_code_hash, \ - default_aa_code_hash, base_fee_per_gas, aux_data_hash, pass_through_data_hash, \ - meta_parameters_hash, protocol_version, compressed_state_diffs, \ - system_logs, events_queue_commitment, bootloader_initial_content_commitment \ - FROM l1_batches \ - LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number \ - WHERE eth_commit_tx_id IS NOT NULL AND eth_prove_tx_id IS NULL \ - ORDER BY number LIMIT $1", + r#" + SELECT + number, + timestamp, + is_finished, + l1_tx_count, + l2_tx_count, + fee_account_address, + bloom, + priority_ops_onchain_data, + hash, + parent_hash, + commitment, + compressed_write_logs, + compressed_contracts, + eth_prove_tx_id, + eth_commit_tx_id, + eth_execute_tx_id, + merkle_root_hash, + l2_to_l1_logs, + l2_to_l1_messages, + used_contract_hashes, + compressed_initial_writes, + compressed_repeated_writes, + l2_l1_compressed_messages, + l2_l1_merkle_root, + l1_gas_price, + l2_fair_gas_price, + rollup_last_leaf_index, + zkporter_is_available, + bootloader_code_hash, + default_aa_code_hash, + base_fee_per_gas, + aux_data_hash, + pass_through_data_hash, + meta_parameters_hash, + protocol_version, + compressed_state_diffs, + system_logs, + events_queue_commitment, + bootloader_initial_content_commitment + FROM + l1_batches + LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number + WHERE + eth_commit_tx_id IS NOT NULL + AND eth_prove_tx_id IS NULL + ORDER BY + number + LIMIT + $1 + "#, limit as i32 ) .instrument("get_ready_for_dummy_proof_l1_batches") @@ -807,7 +1226,13 @@ impl BlocksDal<'_, '_> { l1_batch_number: L1BatchNumber, ) -> sqlx::Result<()> { sqlx::query!( - "UPDATE l1_batches SET skip_proof = TRUE WHERE number = $1", + r#" + UPDATE l1_batches + SET + skip_proof = TRUE + WHERE + number = $1 + "#, l1_batch_number.0 as i64 ) .execute(self.storage.conn()) @@ -828,26 +1253,70 @@ impl BlocksDal<'_, '_> { // is used to avoid having gaps in the list of blocks to send dummy proofs for. let raw_batches = sqlx::query_as!( StorageL1Batch, - "SELECT number, timestamp, is_finished, l1_tx_count, l2_tx_count, fee_account_address, \ - bloom, priority_ops_onchain_data, hash, parent_hash, commitment, compressed_write_logs, \ - compressed_contracts, eth_prove_tx_id, eth_commit_tx_id, eth_execute_tx_id, \ - merkle_root_hash, l2_to_l1_logs, l2_to_l1_messages, \ - used_contract_hashes, compressed_initial_writes, compressed_repeated_writes, \ - l2_l1_compressed_messages, l2_l1_merkle_root, l1_gas_price, l2_fair_gas_price, \ - rollup_last_leaf_index, zkporter_is_available, bootloader_code_hash, \ - default_aa_code_hash, base_fee_per_gas, aux_data_hash, pass_through_data_hash, \ - meta_parameters_hash, system_logs, compressed_state_diffs, protocol_version, \ - events_queue_commitment, bootloader_initial_content_commitment \ - FROM \ - (SELECT l1_batches.*, row_number() OVER (ORDER BY number ASC) AS row_number \ - FROM l1_batches \ - WHERE eth_commit_tx_id IS NOT NULL \ - AND l1_batches.skip_proof = TRUE \ - AND l1_batches.number > $1 \ - ORDER BY number LIMIT $2\ - ) inn \ - LEFT JOIN commitments ON commitments.l1_batch_number = inn.number \ - WHERE number - row_number = $1", + r#" + SELECT + number, + timestamp, + is_finished, + l1_tx_count, + l2_tx_count, + fee_account_address, + bloom, + priority_ops_onchain_data, + hash, + parent_hash, + commitment, + compressed_write_logs, + compressed_contracts, + eth_prove_tx_id, + eth_commit_tx_id, + eth_execute_tx_id, + merkle_root_hash, + l2_to_l1_logs, + l2_to_l1_messages, + used_contract_hashes, + compressed_initial_writes, + compressed_repeated_writes, + l2_l1_compressed_messages, + l2_l1_merkle_root, + l1_gas_price, + l2_fair_gas_price, + rollup_last_leaf_index, + zkporter_is_available, + bootloader_code_hash, + default_aa_code_hash, + base_fee_per_gas, + aux_data_hash, + pass_through_data_hash, + meta_parameters_hash, + system_logs, + compressed_state_diffs, + protocol_version, + events_queue_commitment, + bootloader_initial_content_commitment + FROM + ( + SELECT + l1_batches.*, + ROW_NUMBER() OVER ( + ORDER BY + number ASC + ) AS ROW_NUMBER + FROM + l1_batches + WHERE + eth_commit_tx_id IS NOT NULL + AND l1_batches.skip_proof = TRUE + AND l1_batches.number > $1 + ORDER BY + number + LIMIT + $2 + ) inn + LEFT JOIN commitments ON commitments.l1_batch_number = inn.number + WHERE + number - ROW_NUMBER = $1 + "#, last_proved_block_number.0 as i32, limit as i32 ) @@ -867,28 +1336,68 @@ impl BlocksDal<'_, '_> { max_l1_batch_timestamp_millis: Option, ) -> anyhow::Result> { let raw_batches = match max_l1_batch_timestamp_millis { - None => sqlx::query_as!( - StorageL1Batch, - "SELECT number, timestamp, is_finished, l1_tx_count, l2_tx_count, fee_account_address, \ - bloom, priority_ops_onchain_data, hash, parent_hash, commitment, compressed_write_logs, \ - compressed_contracts, eth_prove_tx_id, eth_commit_tx_id, eth_execute_tx_id, \ - merkle_root_hash, l2_to_l1_logs, l2_to_l1_messages, \ - used_contract_hashes, compressed_initial_writes, compressed_repeated_writes, \ - l2_l1_compressed_messages, l2_l1_merkle_root, l1_gas_price, l2_fair_gas_price, \ - rollup_last_leaf_index, zkporter_is_available, bootloader_code_hash, \ - default_aa_code_hash, base_fee_per_gas, aux_data_hash, pass_through_data_hash, \ - meta_parameters_hash, protocol_version, compressed_state_diffs, \ - system_logs, events_queue_commitment, bootloader_initial_content_commitment \ - FROM l1_batches \ - LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number \ - WHERE eth_prove_tx_id IS NOT NULL AND eth_execute_tx_id IS NULL \ - ORDER BY number LIMIT $1", - limit as i32, - ) - .instrument("get_ready_for_execute_l1_batches/no_max_timestamp") - .with_arg("limit", &limit) - .fetch_all(self.storage.conn()) - .await?, + None => { + sqlx::query_as!( + StorageL1Batch, + r#" + SELECT + number, + timestamp, + is_finished, + l1_tx_count, + l2_tx_count, + fee_account_address, + bloom, + priority_ops_onchain_data, + hash, + parent_hash, + commitment, + compressed_write_logs, + compressed_contracts, + eth_prove_tx_id, + eth_commit_tx_id, + eth_execute_tx_id, + merkle_root_hash, + l2_to_l1_logs, + l2_to_l1_messages, + used_contract_hashes, + compressed_initial_writes, + compressed_repeated_writes, + l2_l1_compressed_messages, + l2_l1_merkle_root, + l1_gas_price, + l2_fair_gas_price, + rollup_last_leaf_index, + zkporter_is_available, + bootloader_code_hash, + default_aa_code_hash, + base_fee_per_gas, + aux_data_hash, + pass_through_data_hash, + meta_parameters_hash, + protocol_version, + compressed_state_diffs, + system_logs, + events_queue_commitment, + bootloader_initial_content_commitment + FROM + l1_batches + LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number + WHERE + eth_prove_tx_id IS NOT NULL + AND eth_execute_tx_id IS NULL + ORDER BY + number + LIMIT + $1 + "#, + limit as i32, + ) + .instrument("get_ready_for_execute_l1_batches/no_max_timestamp") + .with_arg("limit", &limit) + .fetch_all(self.storage.conn()) + .await? + } Some(max_l1_batch_timestamp_millis) => { // Do not lose the precision here, otherwise we can skip some L1 batches. @@ -913,9 +1422,19 @@ impl BlocksDal<'_, '_> { // We need to find the first L1 batch that is supposed to be executed. // Here we ignore the time delay, so we just take the first L1 batch that is ready for execution. let row = sqlx::query!( - "SELECT number FROM l1_batches \ - WHERE eth_prove_tx_id IS NOT NULL AND eth_execute_tx_id IS NULL \ - ORDER BY number LIMIT 1" + r#" + SELECT + number + FROM + l1_batches + WHERE + eth_prove_tx_id IS NOT NULL + AND eth_execute_tx_id IS NULL + ORDER BY + number + LIMIT + 1 + "# ) .fetch_optional(self.storage.conn()) .await?; @@ -930,13 +1449,23 @@ impl BlocksDal<'_, '_> { // Find the last L1 batch that is ready for execution. let row = sqlx::query!( - "SELECT max(l1_batches.number) FROM l1_batches \ - JOIN eth_txs ON (l1_batches.eth_commit_tx_id = eth_txs.id) \ - JOIN eth_txs_history AS commit_tx ON (eth_txs.confirmed_eth_tx_history_id = commit_tx.id) \ - WHERE commit_tx.confirmed_at IS NOT NULL \ - AND eth_prove_tx_id IS NOT NULL \ - AND eth_execute_tx_id IS NULL \ - AND EXTRACT(epoch FROM commit_tx.confirmed_at) < $1", + r#" + SELECT + MAX(l1_batches.number) + FROM + l1_batches + JOIN eth_txs ON (l1_batches.eth_commit_tx_id = eth_txs.id) + JOIN eth_txs_history AS commit_tx ON (eth_txs.confirmed_eth_tx_history_id = commit_tx.id) + WHERE + commit_tx.confirmed_at IS NOT NULL + AND eth_prove_tx_id IS NOT NULL + AND eth_execute_tx_id IS NULL + AND EXTRACT( + epoch + FROM + commit_tx.confirmed_at + ) < $1 + "#, max_l1_batch_timestamp_seconds_bd, ) .fetch_one(self.storage.conn()) @@ -948,26 +1477,66 @@ impl BlocksDal<'_, '_> { assert!(max_ready_to_send_block >= expected_started_point); sqlx::query_as!( StorageL1Batch, - "SELECT number, timestamp, is_finished, l1_tx_count, l2_tx_count, fee_account_address, \ - bloom, priority_ops_onchain_data, hash, parent_hash, commitment, compressed_write_logs, \ - compressed_contracts, eth_prove_tx_id, eth_commit_tx_id, eth_execute_tx_id, \ - merkle_root_hash, l2_to_l1_logs, l2_to_l1_messages, \ - used_contract_hashes, compressed_initial_writes, compressed_repeated_writes, \ - l2_l1_compressed_messages, l2_l1_merkle_root, l1_gas_price, l2_fair_gas_price, \ - rollup_last_leaf_index, zkporter_is_available, bootloader_code_hash, \ - default_aa_code_hash, base_fee_per_gas, aux_data_hash, pass_through_data_hash, \ - meta_parameters_hash, protocol_version, compressed_state_diffs, \ - system_logs, events_queue_commitment, bootloader_initial_content_commitment \ - FROM l1_batches \ - LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number \ - WHERE number BETWEEN $1 AND $2 \ - ORDER BY number LIMIT $3", + r#" + SELECT + number, + timestamp, + is_finished, + l1_tx_count, + l2_tx_count, + fee_account_address, + bloom, + priority_ops_onchain_data, + hash, + parent_hash, + commitment, + compressed_write_logs, + compressed_contracts, + eth_prove_tx_id, + eth_commit_tx_id, + eth_execute_tx_id, + merkle_root_hash, + l2_to_l1_logs, + l2_to_l1_messages, + used_contract_hashes, + compressed_initial_writes, + compressed_repeated_writes, + l2_l1_compressed_messages, + l2_l1_merkle_root, + l1_gas_price, + l2_fair_gas_price, + rollup_last_leaf_index, + zkporter_is_available, + bootloader_code_hash, + default_aa_code_hash, + base_fee_per_gas, + aux_data_hash, + pass_through_data_hash, + meta_parameters_hash, + protocol_version, + compressed_state_diffs, + system_logs, + events_queue_commitment, + bootloader_initial_content_commitment + FROM + l1_batches + LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number + WHERE + number BETWEEN $1 AND $2 + ORDER BY + number + LIMIT + $3 + "#, expected_started_point as i32, max_ready_to_send_block, limit as i32, ) .instrument("get_ready_for_execute_l1_batches") - .with_arg("numbers", &(expected_started_point..=max_ready_to_send_block)) + .with_arg( + "numbers", + &(expected_started_point..=max_ready_to_send_block), + ) .with_arg("limit", &limit) .fetch_all(self.storage.conn()) .await? @@ -985,37 +1554,78 @@ impl BlocksDal<'_, '_> { ) -> anyhow::Result> { let raw_batches = sqlx::query_as!( StorageL1Batch, - "SELECT number, l1_batches.timestamp, is_finished, l1_tx_count, l2_tx_count, fee_account_address, \ - bloom, priority_ops_onchain_data, hash, parent_hash, commitment, compressed_write_logs, \ - compressed_contracts, eth_prove_tx_id, eth_commit_tx_id, eth_execute_tx_id, \ - merkle_root_hash, l2_to_l1_logs, l2_to_l1_messages, \ - used_contract_hashes, compressed_initial_writes, compressed_repeated_writes, \ - l2_l1_compressed_messages, l2_l1_merkle_root, l1_gas_price, l2_fair_gas_price, \ - rollup_last_leaf_index, zkporter_is_available, l1_batches.bootloader_code_hash, \ - l1_batches.default_aa_code_hash, base_fee_per_gas, aux_data_hash, pass_through_data_hash, \ - meta_parameters_hash, protocol_version, compressed_state_diffs, \ - system_logs, events_queue_commitment, bootloader_initial_content_commitment \ - FROM l1_batches \ - LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number \ - JOIN protocol_versions ON protocol_versions.id = l1_batches.protocol_version \ - WHERE eth_commit_tx_id IS NULL \ - AND number != 0 \ - AND protocol_versions.bootloader_code_hash = $1 AND protocol_versions.default_account_code_hash = $2 \ - AND commitment IS NOT NULL \ - AND (protocol_versions.id = $3 OR protocol_versions.upgrade_tx_hash IS NULL) \ - ORDER BY number LIMIT $4", + r#" + SELECT + number, + l1_batches.timestamp, + is_finished, + l1_tx_count, + l2_tx_count, + fee_account_address, + bloom, + priority_ops_onchain_data, + hash, + parent_hash, + commitment, + compressed_write_logs, + compressed_contracts, + eth_prove_tx_id, + eth_commit_tx_id, + eth_execute_tx_id, + merkle_root_hash, + l2_to_l1_logs, + l2_to_l1_messages, + used_contract_hashes, + compressed_initial_writes, + compressed_repeated_writes, + l2_l1_compressed_messages, + l2_l1_merkle_root, + l1_gas_price, + l2_fair_gas_price, + rollup_last_leaf_index, + zkporter_is_available, + l1_batches.bootloader_code_hash, + l1_batches.default_aa_code_hash, + base_fee_per_gas, + aux_data_hash, + pass_through_data_hash, + meta_parameters_hash, + protocol_version, + compressed_state_diffs, + system_logs, + events_queue_commitment, + bootloader_initial_content_commitment + FROM + l1_batches + LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number + JOIN protocol_versions ON protocol_versions.id = l1_batches.protocol_version + WHERE + eth_commit_tx_id IS NULL + AND number != 0 + AND protocol_versions.bootloader_code_hash = $1 + AND protocol_versions.default_account_code_hash = $2 + AND commitment IS NOT NULL + AND ( + protocol_versions.id = $3 + OR protocol_versions.upgrade_tx_hash IS NULL + ) + ORDER BY + number + LIMIT + $4 + "#, bootloader_hash.as_bytes(), default_aa_hash.as_bytes(), protocol_version_id as i32, limit as i64, ) - .instrument("get_ready_for_commit_l1_batches") - .with_arg("limit", &limit) - .with_arg("bootloader_hash", &bootloader_hash) - .with_arg("default_aa_hash", &default_aa_hash) - .with_arg("protocol_version_id", &protocol_version_id) - .fetch_all(self.storage.conn()) - .await?; + .instrument("get_ready_for_commit_l1_batches") + .with_arg("limit", &limit) + .with_arg("bootloader_hash", &bootloader_hash) + .with_arg("default_aa_hash", &default_aa_hash) + .with_arg("protocol_version_id", &protocol_version_id) + .fetch_all(self.storage.conn()) + .await?; self.map_l1_batches(raw_batches) .await @@ -1031,26 +1641,68 @@ impl BlocksDal<'_, '_> { ) -> anyhow::Result> { let raw_batches = sqlx::query_as!( StorageL1Batch, - "SELECT number, l1_batches.timestamp, is_finished, l1_tx_count, l2_tx_count, fee_account_address, \ - bloom, priority_ops_onchain_data, hash, parent_hash, commitment, compressed_write_logs, \ - compressed_contracts, eth_prove_tx_id, eth_commit_tx_id, eth_execute_tx_id, \ - merkle_root_hash, l2_to_l1_logs, l2_to_l1_messages, \ - used_contract_hashes, compressed_initial_writes, compressed_repeated_writes, \ - l2_l1_compressed_messages, l2_l1_merkle_root, l1_gas_price, l2_fair_gas_price, \ - rollup_last_leaf_index, zkporter_is_available, l1_batches.bootloader_code_hash, \ - l1_batches.default_aa_code_hash, base_fee_per_gas, aux_data_hash, pass_through_data_hash, \ - meta_parameters_hash, protocol_version, compressed_state_diffs, \ - system_logs, events_queue_commitment, bootloader_initial_content_commitment \ - FROM l1_batches \ - LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number \ - JOIN protocol_versions ON protocol_versions.id = l1_batches.protocol_version \ - WHERE eth_commit_tx_id IS NULL \ - AND number != 0 \ - AND protocol_versions.bootloader_code_hash = $1 AND protocol_versions.default_account_code_hash = $2 \ - AND commitment IS NOT NULL \ - AND (protocol_versions.id = $3 OR protocol_versions.upgrade_tx_hash IS NULL) \ - AND events_queue_commitment IS NOT NULL AND bootloader_initial_content_commitment IS NOT NULL \ - ORDER BY number LIMIT $4", + r#" + SELECT + number, + l1_batches.timestamp, + is_finished, + l1_tx_count, + l2_tx_count, + fee_account_address, + bloom, + priority_ops_onchain_data, + hash, + parent_hash, + commitment, + compressed_write_logs, + compressed_contracts, + eth_prove_tx_id, + eth_commit_tx_id, + eth_execute_tx_id, + merkle_root_hash, + l2_to_l1_logs, + l2_to_l1_messages, + used_contract_hashes, + compressed_initial_writes, + compressed_repeated_writes, + l2_l1_compressed_messages, + l2_l1_merkle_root, + l1_gas_price, + l2_fair_gas_price, + rollup_last_leaf_index, + zkporter_is_available, + l1_batches.bootloader_code_hash, + l1_batches.default_aa_code_hash, + base_fee_per_gas, + aux_data_hash, + pass_through_data_hash, + meta_parameters_hash, + protocol_version, + compressed_state_diffs, + system_logs, + events_queue_commitment, + bootloader_initial_content_commitment + FROM + l1_batches + LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number + JOIN protocol_versions ON protocol_versions.id = l1_batches.protocol_version + WHERE + eth_commit_tx_id IS NULL + AND number != 0 + AND protocol_versions.bootloader_code_hash = $1 + AND protocol_versions.default_account_code_hash = $2 + AND commitment IS NOT NULL + AND ( + protocol_versions.id = $3 + OR protocol_versions.upgrade_tx_hash IS NULL + ) + AND events_queue_commitment IS NOT NULL + AND bootloader_initial_content_commitment IS NOT NULL + ORDER BY + number + LIMIT + $4 + "#, bootloader_hash.as_bytes(), default_aa_hash.as_bytes(), protocol_version_id as i32, @@ -1074,7 +1726,14 @@ impl BlocksDal<'_, '_> { number: L1BatchNumber, ) -> sqlx::Result> { Ok(sqlx::query!( - "SELECT hash FROM l1_batches WHERE number = $1", + r#" + SELECT + hash + FROM + l1_batches + WHERE + number = $1 + "#, number.0 as i64 ) .fetch_optional(self.storage.conn()) @@ -1088,7 +1747,15 @@ impl BlocksDal<'_, '_> { number: L1BatchNumber, ) -> Result, sqlx::Error> { let Some(row) = sqlx::query!( - "SELECT timestamp, hash FROM l1_batches WHERE number = $1", + r#" + SELECT + timestamp, + hash + FROM + l1_batches + WHERE + number = $1 + "#, number.0 as i64 ) .fetch_optional(self.storage.conn()) @@ -1105,15 +1772,34 @@ impl BlocksDal<'_, '_> { pub async fn get_newest_l1_batch_header(&mut self) -> sqlx::Result { let last_l1_batch = sqlx::query_as!( StorageL1BatchHeader, - "SELECT number, l1_tx_count, l2_tx_count, \ - timestamp, is_finished, fee_account_address, l2_to_l1_logs, l2_to_l1_messages, \ - bloom, priority_ops_onchain_data, \ - used_contract_hashes, base_fee_per_gas, l1_gas_price, \ - l2_fair_gas_price, bootloader_code_hash, default_aa_code_hash, protocol_version, \ - compressed_state_diffs, system_logs \ - FROM l1_batches \ - ORDER BY number DESC \ - LIMIT 1" + r#" + SELECT + number, + l1_tx_count, + l2_tx_count, + timestamp, + is_finished, + fee_account_address, + l2_to_l1_logs, + l2_to_l1_messages, + bloom, + priority_ops_onchain_data, + used_contract_hashes, + base_fee_per_gas, + l1_gas_price, + l2_fair_gas_price, + bootloader_code_hash, + default_aa_code_hash, + protocol_version, + compressed_state_diffs, + system_logs + FROM + l1_batches + ORDER BY + number DESC + LIMIT + 1 + "# ) .instrument("get_newest_l1_batch_header") .fetch_one(self.storage.conn()) @@ -1163,9 +1849,16 @@ impl BlocksDal<'_, '_> { l1_batch_number: L1BatchNumber, ) -> sqlx::Result>> { Ok(sqlx::query!( - "SELECT bytecode_hash, bytecode FROM factory_deps \ - INNER JOIN miniblocks ON miniblocks.number = factory_deps.miniblock_number \ - WHERE miniblocks.l1_batch_number = $1", + r#" + SELECT + bytecode_hash, + bytecode + FROM + factory_deps + INNER JOIN miniblocks ON miniblocks.number = factory_deps.miniblock_number + WHERE + miniblocks.l1_batch_number = $1 + "#, l1_batch_number.0 as i64 ) .fetch_all(self.storage.conn()) @@ -1188,9 +1881,16 @@ impl BlocksDal<'_, '_> { last_batch_to_keep: Option, ) -> sqlx::Result<()> { let block_number = last_batch_to_keep.map_or(-1, |number| number.0 as i64); - sqlx::query!("DELETE FROM l1_batches WHERE number > $1", block_number) - .execute(self.storage.conn()) - .await?; + sqlx::query!( + r#" + DELETE FROM l1_batches + WHERE + number > $1 + "#, + block_number + ) + .execute(self.storage.conn()) + .await?; Ok(()) } @@ -1208,9 +1908,16 @@ impl BlocksDal<'_, '_> { last_miniblock_to_keep: Option, ) -> sqlx::Result<()> { let block_number = last_miniblock_to_keep.map_or(-1, |number| number.0 as i64); - sqlx::query!("DELETE FROM miniblocks WHERE number > $1", block_number) - .execute(self.storage.conn()) - .await?; + sqlx::query!( + r#" + DELETE FROM miniblocks + WHERE + number > $1 + "#, + block_number + ) + .execute(self.storage.conn()) + .await?; Ok(()) } @@ -1246,9 +1953,14 @@ impl BlocksDal<'_, '_> { predicted_gas_cost: u32, ) -> sqlx::Result<()> { sqlx::query!( - "UPDATE l1_batches \ - SET predicted_commit_gas_cost = $2, updated_at = now() \ - WHERE number = $1", + r#" + UPDATE l1_batches + SET + predicted_commit_gas_cost = $2, + updated_at = NOW() + WHERE + number = $1 + "#, number.0 as i64, predicted_gas_cost as i64 ) @@ -1262,9 +1974,15 @@ impl BlocksDal<'_, '_> { l1_batch_number: L1BatchNumber, ) -> sqlx::Result> { let row = sqlx::query!( - "SELECT MIN(miniblocks.number) as \"min?\", MAX(miniblocks.number) as \"max?\" \ - FROM miniblocks \ - WHERE l1_batch_number = $1", + r#" + SELECT + MIN(miniblocks.number) AS "min?", + MAX(miniblocks.number) AS "max?" + FROM + miniblocks + WHERE + l1_batch_number = $1 + "#, l1_batch_number.0 as i64 ) .fetch_one(self.storage.conn()) @@ -1290,71 +2008,23 @@ impl BlocksDal<'_, '_> { Ok(count != 0) } - pub async fn get_last_l1_batch_number_with_witness_inputs( - &mut self, - ) -> sqlx::Result { - let row = sqlx::query!( - "SELECT MAX(l1_batch_number) FROM witness_inputs \ - WHERE merkel_tree_paths_blob_url IS NOT NULL", - ) - .fetch_one(self.storage.conn()) - .await?; - - Ok(row - .max - .map(|l1_batch_number| L1BatchNumber(l1_batch_number as u32)) - .unwrap_or_default()) - } - - pub async fn get_l1_batches_with_blobs_in_db( - &mut self, - limit: u8, - ) -> sqlx::Result> { - let rows = sqlx::query!( - "SELECT l1_batch_number FROM witness_inputs \ - WHERE length(merkle_tree_paths) <> 0 \ - ORDER BY l1_batch_number DESC \ - LIMIT $1", - limit as i32 - ) - .fetch_all(self.storage.conn()) - .await?; - - Ok(rows - .into_iter() - .map(|row| L1BatchNumber(row.l1_batch_number as u32)) - .collect()) - } - - pub async fn get_merkle_tree_paths_blob_urls_to_be_cleaned( - &mut self, - limit: u8, - ) -> Result, sqlx::Error> { - let rows = sqlx::query!( - "SELECT l1_batch_number, merkel_tree_paths_blob_url \ - FROM witness_inputs \ - WHERE status = 'successful' \ - AND merkel_tree_paths_blob_url is NOT NULL \ - AND updated_at < NOW() - INTERVAL '30 days' \ - LIMIT $1", - limit as i32 - ) - .fetch_all(self.storage.conn()) - .await?; - - Ok(rows - .into_iter() - .map(|row| (row.l1_batch_number, row.merkel_tree_paths_blob_url.unwrap())) - .collect()) - } - // methods used for measuring Eth tx stage transition latencies // and emitting metrics base on these measured data pub async fn oldest_uncommitted_batch_timestamp(&mut self) -> sqlx::Result> { Ok(sqlx::query!( - "SELECT timestamp FROM l1_batches \ - WHERE eth_commit_tx_id IS NULL AND number > 0 \ - ORDER BY number LIMIT 1", + r#" + SELECT + timestamp + FROM + l1_batches + WHERE + eth_commit_tx_id IS NULL + AND number > 0 + ORDER BY + number + LIMIT + 1 + "#, ) .fetch_optional(self.storage.conn()) .await? @@ -1363,9 +2033,19 @@ impl BlocksDal<'_, '_> { pub async fn oldest_unproved_batch_timestamp(&mut self) -> sqlx::Result> { Ok(sqlx::query!( - "SELECT timestamp FROM l1_batches \ - WHERE eth_prove_tx_id IS NULL AND number > 0 \ - ORDER BY number LIMIT 1", + r#" + SELECT + timestamp + FROM + l1_batches + WHERE + eth_prove_tx_id IS NULL + AND number > 0 + ORDER BY + number + LIMIT + 1 + "#, ) .fetch_optional(self.storage.conn()) .await? @@ -1374,9 +2054,19 @@ impl BlocksDal<'_, '_> { pub async fn oldest_unexecuted_batch_timestamp(&mut self) -> Result, sqlx::Error> { Ok(sqlx::query!( - "SELECT timestamp FROM l1_batches \ - WHERE eth_execute_tx_id IS NULL AND number > 0 \ - ORDER BY number LIMIT 1", + r#" + SELECT + timestamp + FROM + l1_batches + WHERE + eth_execute_tx_id IS NULL + AND number > 0 + ORDER BY + number + LIMIT + 1 + "#, ) .fetch_optional(self.storage.conn()) .await? @@ -1388,7 +2078,14 @@ impl BlocksDal<'_, '_> { l1_batch_number: L1BatchNumber, ) -> anyhow::Result> { let Some(row) = sqlx::query!( - "SELECT protocol_version FROM l1_batches WHERE number = $1", + r#" + SELECT + protocol_version + FROM + l1_batches + WHERE + number = $1 + "#, l1_batch_number.0 as i64 ) .fetch_optional(self.storage.conn()) @@ -1407,7 +2104,14 @@ impl BlocksDal<'_, '_> { miniblock_number: MiniblockNumber, ) -> anyhow::Result> { let Some(row) = sqlx::query!( - "SELECT protocol_version FROM miniblocks WHERE number = $1", + r#" + SELECT + protocol_version + FROM + miniblocks + WHERE + number = $1 + "#, miniblock_number.0 as i64 ) .fetch_optional(self.storage.conn()) @@ -1426,7 +2130,14 @@ impl BlocksDal<'_, '_> { miniblock_number: MiniblockNumber, ) -> sqlx::Result> { Ok(sqlx::query!( - "SELECT timestamp FROM miniblocks WHERE number = $1", + r#" + SELECT + timestamp + FROM + miniblocks + WHERE + number = $1 + "#, miniblock_number.0 as i64, ) .fetch_optional(self.storage.conn()) @@ -1439,8 +2150,13 @@ impl BlocksDal<'_, '_> { id: ProtocolVersionId, ) -> sqlx::Result<()> { sqlx::query!( - "UPDATE miniblocks SET protocol_version = $1 \ - WHERE l1_batch_number IS NULL", + r#" + UPDATE miniblocks + SET + protocol_version = $1 + WHERE + l1_batch_number IS NULL + "#, id as i32, ) .execute(self.storage.conn()) @@ -1453,7 +2169,14 @@ impl BlocksDal<'_, '_> { l1_batch_number: L1BatchNumber, ) -> sqlx::Result> { Ok(sqlx::query!( - "SELECT fee_account_address FROM l1_batches WHERE number = $1", + r#" + SELECT + fee_account_address + FROM + l1_batches + WHERE + number = $1 + "#, l1_batch_number.0 as u32 ) .fetch_optional(self.storage.conn()) @@ -1466,7 +2189,14 @@ impl BlocksDal<'_, '_> { miniblock_number: MiniblockNumber, ) -> sqlx::Result> { Ok(sqlx::query!( - "SELECT virtual_blocks FROM miniblocks WHERE number = $1", + r#" + SELECT + virtual_blocks + FROM + miniblocks + WHERE + number = $1 + "#, miniblock_number.0 as u32 ) .fetch_optional(self.storage.conn()) @@ -1484,7 +2214,13 @@ impl BlocksDal<'_, '_> { hash: H256, ) -> sqlx::Result<()> { sqlx::query!( - "UPDATE l1_batches SET hash = $1 WHERE number = $2", + r#" + UPDATE l1_batches + SET + hash = $1 + WHERE + number = $2 + "#, hash.as_bytes(), batch_num.0 as i64 ) diff --git a/core/lib/dal/src/blocks_web3_dal.rs b/core/lib/dal/src/blocks_web3_dal.rs index ddb0a619e17c..4be51e07240f 100644 --- a/core/lib/dal/src/blocks_web3_dal.rs +++ b/core/lib/dal/src/blocks_web3_dal.rs @@ -33,24 +33,38 @@ pub struct BlocksWeb3Dal<'a, 'c> { impl BlocksWeb3Dal<'_, '_> { pub async fn get_sealed_miniblock_number(&mut self) -> sqlx::Result { - let number = sqlx::query!("SELECT MAX(number) as \"number\" FROM miniblocks") - .instrument("get_sealed_block_number") - .report_latency() - .fetch_one(self.storage.conn()) - .await? - .number - .expect("DAL invocation before genesis"); + let number = sqlx::query!( + r#" + SELECT + MAX(number) AS "number" + FROM + miniblocks + "# + ) + .instrument("get_sealed_block_number") + .report_latency() + .fetch_one(self.storage.conn()) + .await? + .number + .expect("DAL invocation before genesis"); Ok(MiniblockNumber(number as u32)) } pub async fn get_sealed_l1_batch_number(&mut self) -> sqlx::Result { - let number = sqlx::query!("SELECT MAX(number) as \"number\" FROM l1_batches") - .instrument("get_sealed_block_number") - .report_latency() - .fetch_one(self.storage.conn()) - .await? - .number - .expect("DAL invocation before genesis"); + let number = sqlx::query!( + r#" + SELECT + MAX(number) AS "number" + FROM + l1_batches + "# + ) + .instrument("get_sealed_block_number") + .report_latency() + .fetch_one(self.storage.conn()) + .await? + .number + .expect("DAL invocation before genesis"); Ok(L1BatchNumber(number as u32)) } @@ -170,10 +184,19 @@ impl BlocksWeb3Dal<'_, '_> { limit: usize, ) -> sqlx::Result<(Vec, Option)> { let rows = sqlx::query!( - "SELECT number, hash FROM miniblocks \ - WHERE number >= $1 \ - ORDER BY number ASC \ - LIMIT $2", + r#" + SELECT + number, + hash + FROM + miniblocks + WHERE + number >= $1 + ORDER BY + number ASC + LIMIT + $2 + "#, from_block.0 as i64, limit as i32 ) @@ -191,10 +214,18 @@ impl BlocksWeb3Dal<'_, '_> { from_block: MiniblockNumber, ) -> sqlx::Result> { let rows = sqlx::query!( - "SELECT hash, number, timestamp \ - FROM miniblocks \ - WHERE number > $1 \ - ORDER BY number ASC", + r#" + SELECT + hash, + number, + timestamp + FROM + miniblocks + WHERE + number > $1 + ORDER BY + number ASC + "#, from_block.0 as i64, ) .fetch_all(self.storage.conn()) @@ -268,8 +299,14 @@ impl BlocksWeb3Dal<'_, '_> { } }; let timestamp = sqlx::query!( - "SELECT timestamp FROM miniblocks \ - WHERE number = $1", + r#" + SELECT + timestamp + FROM + miniblocks + WHERE + number = $1 + "#, first_miniblock_of_batch.0 as i64 ) .fetch_optional(self.storage.conn()) @@ -283,7 +320,14 @@ impl BlocksWeb3Dal<'_, '_> { block_number: MiniblockNumber, ) -> sqlx::Result> { let hash = sqlx::query!( - "SELECT hash FROM miniblocks WHERE number = $1", + r#" + SELECT + hash + FROM + miniblocks + WHERE + number = $1 + "#, block_number.0 as i64 ) .fetch_optional(self.storage.conn()) @@ -297,7 +341,14 @@ impl BlocksWeb3Dal<'_, '_> { block_number: L1BatchNumber, ) -> sqlx::Result> { let raw_logs = sqlx::query!( - "SELECT l2_to_l1_logs FROM l1_batches WHERE number = $1", + r#" + SELECT + l2_to_l1_logs + FROM + l1_batches + WHERE + number = $1 + "#, block_number.0 as i64 ) .fetch_optional(self.storage.conn()) @@ -316,7 +367,14 @@ impl BlocksWeb3Dal<'_, '_> { miniblock_number: MiniblockNumber, ) -> sqlx::Result> { let number: Option = sqlx::query!( - "SELECT l1_batch_number FROM miniblocks WHERE number = $1", + r#" + SELECT + l1_batch_number + FROM + miniblocks + WHERE + number = $1 + "#, miniblock_number.0 as i64 ) .fetch_optional(self.storage.conn()) @@ -331,9 +389,15 @@ impl BlocksWeb3Dal<'_, '_> { l1_batch_number: L1BatchNumber, ) -> sqlx::Result> { let row = sqlx::query!( - "SELECT MIN(miniblocks.number) as \"min?\", MAX(miniblocks.number) as \"max?\" \ - FROM miniblocks \ - WHERE l1_batch_number = $1", + r#" + SELECT + MIN(miniblocks.number) AS "min?", + MAX(miniblocks.number) AS "max?" + FROM + miniblocks + WHERE + l1_batch_number = $1 + "#, l1_batch_number.0 as i64 ) .fetch_one(self.storage.conn()) @@ -353,9 +417,15 @@ impl BlocksWeb3Dal<'_, '_> { tx_hash: H256, ) -> sqlx::Result> { let row = sqlx::query!( - "SELECT l1_batch_number, l1_batch_tx_index \ - FROM transactions \ - WHERE hash = $1", + r#" + SELECT + l1_batch_number, + l1_batch_tx_index + FROM + transactions + WHERE + hash = $1 + "#, tx_hash.as_bytes() ) .fetch_optional(self.storage.conn()) @@ -377,8 +447,21 @@ impl BlocksWeb3Dal<'_, '_> { ) -> sqlx::Result> { Ok(sqlx::query_as!( CallTrace, - "SELECT * FROM call_traces WHERE tx_hash IN \ - (SELECT hash FROM transactions WHERE miniblock_number = $1)", + r#" + SELECT + * + FROM + call_traces + WHERE + tx_hash IN ( + SELECT + hash + FROM + transactions + WHERE + miniblock_number = $1 + ) + "#, block_number.0 as i64 ) .fetch_all(self.storage.conn()) @@ -396,9 +479,18 @@ impl BlocksWeb3Dal<'_, '_> { block_count: u64, ) -> sqlx::Result> { let result: Vec<_> = sqlx::query!( - "SELECT base_fee_per_gas FROM miniblocks \ - WHERE number <= $1 \ - ORDER BY number DESC LIMIT $2", + r#" + SELECT + base_fee_per_gas + FROM + miniblocks + WHERE + number <= $1 + ORDER BY + number DESC + LIMIT + $2 + "#, newest_block.0 as i64, block_count as i64 ) @@ -420,30 +512,50 @@ impl BlocksWeb3Dal<'_, '_> { let storage_block_details = sqlx::query_as!( StorageBlockDetails, r#" - SELECT miniblocks.number, - COALESCE(miniblocks.l1_batch_number, (SELECT (max(number) + 1) FROM l1_batches)) as "l1_batch_number!", - miniblocks.timestamp, - miniblocks.l1_tx_count, - miniblocks.l2_tx_count, - miniblocks.hash as "root_hash?", - commit_tx.tx_hash as "commit_tx_hash?", - commit_tx.confirmed_at as "committed_at?", - prove_tx.tx_hash as "prove_tx_hash?", - prove_tx.confirmed_at as "proven_at?", - execute_tx.tx_hash as "execute_tx_hash?", - execute_tx.confirmed_at as "executed_at?", - miniblocks.l1_gas_price, - miniblocks.l2_fair_gas_price, - miniblocks.bootloader_code_hash, - miniblocks.default_aa_code_hash, - miniblocks.protocol_version, - l1_batches.fee_account_address as "fee_account_address?" - FROM miniblocks + SELECT + miniblocks.number, + COALESCE( + miniblocks.l1_batch_number, + ( + SELECT + (MAX(number) + 1) + FROM + l1_batches + ) + ) AS "l1_batch_number!", + miniblocks.timestamp, + miniblocks.l1_tx_count, + miniblocks.l2_tx_count, + miniblocks.hash AS "root_hash?", + commit_tx.tx_hash AS "commit_tx_hash?", + commit_tx.confirmed_at AS "committed_at?", + prove_tx.tx_hash AS "prove_tx_hash?", + prove_tx.confirmed_at AS "proven_at?", + execute_tx.tx_hash AS "execute_tx_hash?", + execute_tx.confirmed_at AS "executed_at?", + miniblocks.l1_gas_price, + miniblocks.l2_fair_gas_price, + miniblocks.bootloader_code_hash, + miniblocks.default_aa_code_hash, + miniblocks.protocol_version, + l1_batches.fee_account_address AS "fee_account_address?" + FROM + miniblocks LEFT JOIN l1_batches ON miniblocks.l1_batch_number = l1_batches.number - LEFT JOIN eth_txs_history as commit_tx ON (l1_batches.eth_commit_tx_id = commit_tx.eth_tx_id AND commit_tx.confirmed_at IS NOT NULL) - LEFT JOIN eth_txs_history as prove_tx ON (l1_batches.eth_prove_tx_id = prove_tx.eth_tx_id AND prove_tx.confirmed_at IS NOT NULL) - LEFT JOIN eth_txs_history as execute_tx ON (l1_batches.eth_execute_tx_id = execute_tx.eth_tx_id AND execute_tx.confirmed_at IS NOT NULL) - WHERE miniblocks.number = $1 + LEFT JOIN eth_txs_history AS commit_tx ON ( + l1_batches.eth_commit_tx_id = commit_tx.eth_tx_id + AND commit_tx.confirmed_at IS NOT NULL + ) + LEFT JOIN eth_txs_history AS prove_tx ON ( + l1_batches.eth_prove_tx_id = prove_tx.eth_tx_id + AND prove_tx.confirmed_at IS NOT NULL + ) + LEFT JOIN eth_txs_history AS execute_tx ON ( + l1_batches.eth_execute_tx_id = execute_tx.eth_tx_id + AND execute_tx.confirmed_at IS NOT NULL + ) + WHERE + miniblocks.number = $1 "#, block_number.0 as i64 ) @@ -467,26 +579,38 @@ impl BlocksWeb3Dal<'_, '_> { let l1_batch_details: Option = sqlx::query_as!( StorageL1BatchDetails, r#" - SELECT l1_batches.number, - l1_batches.timestamp, - l1_batches.l1_tx_count, - l1_batches.l2_tx_count, - l1_batches.hash as "root_hash?", - commit_tx.tx_hash as "commit_tx_hash?", - commit_tx.confirmed_at as "committed_at?", - prove_tx.tx_hash as "prove_tx_hash?", - prove_tx.confirmed_at as "proven_at?", - execute_tx.tx_hash as "execute_tx_hash?", - execute_tx.confirmed_at as "executed_at?", - l1_batches.l1_gas_price, - l1_batches.l2_fair_gas_price, - l1_batches.bootloader_code_hash, - l1_batches.default_aa_code_hash - FROM l1_batches - LEFT JOIN eth_txs_history as commit_tx ON (l1_batches.eth_commit_tx_id = commit_tx.eth_tx_id AND commit_tx.confirmed_at IS NOT NULL) - LEFT JOIN eth_txs_history as prove_tx ON (l1_batches.eth_prove_tx_id = prove_tx.eth_tx_id AND prove_tx.confirmed_at IS NOT NULL) - LEFT JOIN eth_txs_history as execute_tx ON (l1_batches.eth_execute_tx_id = execute_tx.eth_tx_id AND execute_tx.confirmed_at IS NOT NULL) - WHERE l1_batches.number = $1 + SELECT + l1_batches.number, + l1_batches.timestamp, + l1_batches.l1_tx_count, + l1_batches.l2_tx_count, + l1_batches.hash AS "root_hash?", + commit_tx.tx_hash AS "commit_tx_hash?", + commit_tx.confirmed_at AS "committed_at?", + prove_tx.tx_hash AS "prove_tx_hash?", + prove_tx.confirmed_at AS "proven_at?", + execute_tx.tx_hash AS "execute_tx_hash?", + execute_tx.confirmed_at AS "executed_at?", + l1_batches.l1_gas_price, + l1_batches.l2_fair_gas_price, + l1_batches.bootloader_code_hash, + l1_batches.default_aa_code_hash + FROM + l1_batches + LEFT JOIN eth_txs_history AS commit_tx ON ( + l1_batches.eth_commit_tx_id = commit_tx.eth_tx_id + AND commit_tx.confirmed_at IS NOT NULL + ) + LEFT JOIN eth_txs_history AS prove_tx ON ( + l1_batches.eth_prove_tx_id = prove_tx.eth_tx_id + AND prove_tx.confirmed_at IS NOT NULL + ) + LEFT JOIN eth_txs_history AS execute_tx ON ( + l1_batches.eth_execute_tx_id = execute_tx.eth_tx_id + AND execute_tx.confirmed_at IS NOT NULL + ) + WHERE + l1_batches.number = $1 "#, l1_batch_number.0 as i64 ) diff --git a/core/lib/dal/src/consensus_dal.rs b/core/lib/dal/src/consensus_dal.rs index a258229fd29c..152191757ba8 100644 --- a/core/lib/dal/src/consensus_dal.rs +++ b/core/lib/dal/src/consensus_dal.rs @@ -9,10 +9,18 @@ pub struct ConsensusDal<'a, 'c> { impl ConsensusDal<'_, '_> { pub async fn replica_state(&mut self) -> anyhow::Result> { - let Some(row) = - sqlx::query!("SELECT state as \"state!\" FROM consensus_replica_state WHERE fake_key") - .fetch_optional(self.storage.conn()) - .await? + let Some(row) = sqlx::query!( + r#" + SELECT + state AS "state!" + FROM + consensus_replica_state + WHERE + fake_key + "# + ) + .fetch_optional(self.storage.conn()) + .await? else { return Ok(None); }; @@ -22,9 +30,21 @@ impl ConsensusDal<'_, '_> { pub async fn put_replica_state(&mut self, state: &ReplicaState) -> sqlx::Result<()> { let state = zksync_protobuf::serde::serialize(state, serde_json::value::Serializer).unwrap(); - sqlx::query!("INSERT INTO consensus_replica_state(fake_key,state) VALUES(true,$1) ON CONFLICT (fake_key) DO UPDATE SET state = excluded.state", state) - .execute(self.storage.conn()) - .await?; + sqlx::query!( + r#" + INSERT INTO + consensus_replica_state (fake_key, state) + VALUES + (TRUE, $1) + ON CONFLICT (fake_key) DO + UPDATE + SET + state = excluded.state + "#, + state + ) + .execute(self.storage.conn()) + .await?; Ok(()) } } diff --git a/core/lib/dal/src/contract_verification_dal.rs b/core/lib/dal/src/contract_verification_dal.rs index 5466b0c11b23..af4f3188a2dd 100644 --- a/core/lib/dal/src/contract_verification_dal.rs +++ b/core/lib/dal/src/contract_verification_dal.rs @@ -42,9 +42,14 @@ impl Display for Compiler { impl ContractVerificationDal<'_, '_> { pub async fn get_count_of_queued_verification_requests(&mut self) -> sqlx::Result { sqlx::query!( - "SELECT COUNT(*) as \"count!\" \ - FROM contract_verification_requests \ - WHERE status = 'queued'" + r#" + SELECT + COUNT(*) AS "count!" + FROM + contract_verification_requests + WHERE + status = 'queued' + "# ) .fetch_one(self.storage.conn()) .await @@ -56,22 +61,27 @@ impl ContractVerificationDal<'_, '_> { query: VerificationIncomingRequest, ) -> sqlx::Result { sqlx::query!( - "INSERT INTO contract_verification_requests ( \ - contract_address, \ - source_code, \ - contract_name, \ - zk_compiler_version, \ - compiler_version, \ - optimization_used, \ - optimizer_mode, \ - constructor_arguments, \ - is_system, \ - status, \ - created_at, \ - updated_at \ - ) - VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, 'queued', now(), now()) \ - RETURNING id", + r#" + INSERT INTO + contract_verification_requests ( + contract_address, + source_code, + contract_name, + zk_compiler_version, + compiler_version, + optimization_used, + optimizer_mode, + constructor_arguments, + is_system, + status, + created_at, + updated_at + ) + VALUES + ($1, $2, $3, $4, $5, $6, $7, $8, $9, 'queued', NOW(), NOW()) + RETURNING + id + "#, query.contract_address.as_bytes(), // Serialization should always succeed. serde_json::to_string(&query.source_code_data).unwrap(), @@ -103,19 +113,44 @@ impl ContractVerificationDal<'_, '_> { }; let result = sqlx::query_as!( StorageVerificationRequest, - "UPDATE contract_verification_requests \ - SET status = 'in_progress', attempts = attempts + 1, \ - updated_at = now(), processing_started_at = now() \ - WHERE id = ( \ - SELECT id FROM contract_verification_requests \ - WHERE status = 'queued' OR (status = 'in_progress' AND processing_started_at < now() - $1::interval) \ - ORDER BY created_at \ - LIMIT 1 \ - FOR UPDATE \ - SKIP LOCKED \ - ) \ - RETURNING id, contract_address, source_code, contract_name, zk_compiler_version, compiler_version, optimization_used, \ - optimizer_mode, constructor_arguments, is_system", + r#" + UPDATE contract_verification_requests + SET + status = 'in_progress', + attempts = attempts + 1, + updated_at = NOW(), + processing_started_at = NOW() + WHERE + id = ( + SELECT + id + FROM + contract_verification_requests + WHERE + status = 'queued' + OR ( + status = 'in_progress' + AND processing_started_at < NOW() - $1::INTERVAL + ) + ORDER BY + created_at + LIMIT + 1 + FOR UPDATE + SKIP LOCKED + ) + RETURNING + id, + contract_address, + source_code, + contract_name, + zk_compiler_version, + compiler_version, + optimization_used, + optimizer_mode, + constructor_arguments, + is_system + "#, &processing_timeout ) .fetch_optional(self.storage.conn()) @@ -136,9 +171,14 @@ impl ContractVerificationDal<'_, '_> { .context("start_transaction()")?; sqlx::query!( - "UPDATE contract_verification_requests \ - SET status = 'successful', updated_at = now() \ - WHERE id = $1", + r#" + UPDATE contract_verification_requests + SET + status = 'successful', + updated_at = NOW() + WHERE + id = $1 + "#, verification_info.request.id as i64, ) .execute(transaction.conn()) @@ -149,11 +189,16 @@ impl ContractVerificationDal<'_, '_> { let verification_info_json = serde_json::to_value(verification_info) .expect("Failed to serialize verification info into serde_json"); sqlx::query!( - "INSERT INTO contracts_verification_info \ - (address, verification_info) \ - VALUES ($1, $2) \ - ON CONFLICT (address) \ - DO UPDATE SET verification_info = $2", + r#" + INSERT INTO + contracts_verification_info (address, verification_info) + VALUES + ($1, $2) + ON CONFLICT (address) DO + UPDATE + SET + verification_info = $2 + "#, address.as_bytes(), &verification_info_json ) @@ -172,9 +217,17 @@ impl ContractVerificationDal<'_, '_> { panic_message: Option, ) -> sqlx::Result<()> { sqlx::query!( - "UPDATE contract_verification_requests \ - SET status = 'failed', updated_at = now(), error = $2, compilation_errors = $3, panic_message = $4 \ - WHERE id = $1", + r#" + UPDATE contract_verification_requests + SET + status = 'failed', + updated_at = NOW(), + error = $2, + compilation_errors = $3, + panic_message = $4 + WHERE + id = $1 + "#, id as i64, error.as_str(), &compilation_errors, @@ -190,8 +243,16 @@ impl ContractVerificationDal<'_, '_> { id: usize, ) -> anyhow::Result> { let Some(row) = sqlx::query!( - "SELECT status, error, compilation_errors FROM contract_verification_requests \ - WHERE id = $1", + r#" + SELECT + status, + error, + compilation_errors + FROM + contract_verification_requests + WHERE + id = $1 + "#, id as i64, ) .fetch_optional(self.storage.conn()) @@ -224,21 +285,38 @@ impl ContractVerificationDal<'_, '_> { ) -> anyhow::Result, DeployContractCalldata)>> { let hashed_key = get_code_key(&address).hashed_key(); let Some(row) = sqlx::query!( - "SELECT factory_deps.bytecode, transactions.data as \"data?\", transactions.contract_address as \"contract_address?\" \ - FROM ( \ - SELECT * FROM storage_logs \ - WHERE storage_logs.hashed_key = $1 \ - ORDER BY miniblock_number DESC, operation_number DESC \ - LIMIT 1 \ - ) storage_logs \ - JOIN factory_deps ON factory_deps.bytecode_hash = storage_logs.value \ - LEFT JOIN transactions ON transactions.hash = storage_logs.tx_hash \ - WHERE storage_logs.value != $2", + r#" + SELECT + factory_deps.bytecode, + transactions.data AS "data?", + transactions.contract_address AS "contract_address?" + FROM + ( + SELECT + * + FROM + storage_logs + WHERE + storage_logs.hashed_key = $1 + ORDER BY + miniblock_number DESC, + operation_number DESC + LIMIT + 1 + ) storage_logs + JOIN factory_deps ON factory_deps.bytecode_hash = storage_logs.value + LEFT JOIN transactions ON transactions.hash = storage_logs.tx_hash + WHERE + storage_logs.value != $2 + "#, hashed_key.as_bytes(), FAILED_CONTRACT_DEPLOYMENT_BYTECODE_HASH.as_bytes() ) .fetch_optional(self.storage.conn()) - .await? else { return Ok(None) }; + .await? + else { + return Ok(None); + }; let calldata = match row.contract_address { Some(contract_address) if contract_address == CONTRACT_DEPLOYER_ADDRESS.0.to_vec() => { // `row.contract_address` and `row.data` are either both `None` or both `Some(_)`. @@ -259,9 +337,14 @@ impl ContractVerificationDal<'_, '_> { /// Returns true if the contract has a stored contracts_verification_info. pub async fn is_contract_verified(&mut self, address: Address) -> sqlx::Result { let count = sqlx::query!( - "SELECT COUNT(*) as \"count!\" \ - FROM contracts_verification_info \ - WHERE address = $1", + r#" + SELECT + COUNT(*) AS "count!" + FROM + contracts_verification_info + WHERE + address = $1 + "#, address.as_bytes() ) .fetch_one(self.storage.conn()) @@ -273,7 +356,16 @@ impl ContractVerificationDal<'_, '_> { async fn get_compiler_versions(&mut self, compiler: Compiler) -> sqlx::Result> { let compiler = format!("{compiler}"); let versions: Vec<_> = sqlx::query!( - "SELECT version FROM compiler_versions WHERE compiler = $1 ORDER by version", + r#" + SELECT + VERSION + FROM + compiler_versions + WHERE + compiler = $1 + ORDER BY + VERSION + "#, &compiler ) .fetch_all(self.storage.conn()) @@ -313,18 +405,29 @@ impl ContractVerificationDal<'_, '_> { let compiler = format!("{compiler}"); sqlx::query!( - "DELETE FROM compiler_versions WHERE compiler = $1", + r#" + DELETE FROM compiler_versions + WHERE + compiler = $1 + "#, &compiler ) .execute(transaction.conn()) .await?; sqlx::query!( - "INSERT INTO compiler_versions (version, compiler, created_at, updated_at) \ - SELECT u.version, $2, now(), now() \ - FROM UNNEST($1::text[]) \ - AS u(version) \ - ON CONFLICT (version, compiler) DO NOTHING", + r#" + INSERT INTO + compiler_versions (VERSION, compiler, created_at, updated_at) + SELECT + u.version, + $2, + NOW(), + NOW() + FROM + UNNEST($1::TEXT[]) AS u (VERSION) + ON CONFLICT (VERSION, compiler) DO NOTHING + "#, &versions, &compiler, ) @@ -355,11 +458,25 @@ impl ContractVerificationDal<'_, '_> { pub async fn get_all_successful_requests(&mut self) -> sqlx::Result> { let result = sqlx::query_as!( StorageVerificationRequest, - "SELECT id, contract_address, source_code, contract_name, zk_compiler_version, compiler_version, optimization_used, \ - optimizer_mode, constructor_arguments, is_system \ - FROM contract_verification_requests \ - WHERE status = 'successful' \ - ORDER BY id", + r#" + SELECT + id, + contract_address, + source_code, + contract_name, + zk_compiler_version, + compiler_version, + optimization_used, + optimizer_mode, + constructor_arguments, + is_system + FROM + contract_verification_requests + WHERE + status = 'successful' + ORDER BY + id + "#, ) .fetch_all(self.storage.conn()) .await? @@ -374,7 +491,14 @@ impl ContractVerificationDal<'_, '_> { address: Address, ) -> anyhow::Result> { let Some(row) = sqlx::query!( - "SELECT verification_info FROM contracts_verification_info WHERE address = $1", + r#" + SELECT + verification_info + FROM + contracts_verification_info + WHERE + address = $1 + "#, address.as_bytes(), ) .fetch_optional(self.storage.conn()) diff --git a/core/lib/dal/src/eth_sender_dal.rs b/core/lib/dal/src/eth_sender_dal.rs index 94d7adfe2849..797928740602 100644 --- a/core/lib/dal/src/eth_sender_dal.rs +++ b/core/lib/dal/src/eth_sender_dal.rs @@ -27,9 +27,24 @@ impl EthSenderDal<'_, '_> { pub async fn get_inflight_txs(&mut self) -> sqlx::Result> { let txs = sqlx::query_as!( StorageEthTx, - "SELECT * FROM eth_txs WHERE confirmed_eth_tx_history_id IS NULL \ - AND id <= (SELECT COALESCE(MAX(eth_tx_id), 0) FROM eth_txs_history WHERE sent_at_block IS NOT NULL) \ - ORDER BY id" + r#" + SELECT + * + FROM + eth_txs + WHERE + confirmed_eth_tx_history_id IS NULL + AND id <= ( + SELECT + COALESCE(MAX(eth_tx_id), 0) + FROM + eth_txs_history + WHERE + sent_at_block IS NOT NULL + ) + ORDER BY + id + "# ) .fetch_all(self.storage.conn()) .await?; @@ -83,7 +98,14 @@ impl EthSenderDal<'_, '_> { pub async fn get_eth_tx(&mut self, eth_tx_id: u32) -> sqlx::Result> { Ok(sqlx::query_as!( StorageEthTx, - "SELECT * FROM eth_txs WHERE id = $1", + r#" + SELECT + * + FROM + eth_txs + WHERE + id = $1 + "#, eth_tx_id as i32 ) .fetch_optional(self.storage.conn()) @@ -94,10 +116,23 @@ impl EthSenderDal<'_, '_> { pub async fn get_new_eth_txs(&mut self, limit: u64) -> sqlx::Result> { let txs = sqlx::query_as!( StorageEthTx, - "SELECT * FROM eth_txs \ - WHERE id > (SELECT COALESCE(MAX(eth_tx_id), 0) FROM eth_txs_history) \ - ORDER BY id \ - LIMIT $1", + r#" + SELECT + * + FROM + eth_txs + WHERE + id > ( + SELECT + COALESCE(MAX(eth_tx_id), 0) + FROM + eth_txs_history + ) + ORDER BY + id + LIMIT + $1 + "#, limit as i64 ) .fetch_all(self.storage.conn()) @@ -108,18 +143,24 @@ impl EthSenderDal<'_, '_> { pub async fn get_unsent_txs(&mut self) -> sqlx::Result> { let txs = sqlx::query_as!( StorageTxHistoryToSend, - "SELECT \ - eth_txs_history.id, \ - eth_txs_history.eth_tx_id, \ - eth_txs_history.tx_hash, \ - eth_txs_history.base_fee_per_gas, \ - eth_txs_history.priority_fee_per_gas, \ - eth_txs_history.signed_raw_tx, \ - eth_txs.nonce \ - FROM eth_txs_history \ - JOIN eth_txs ON eth_txs.id = eth_txs_history.eth_tx_id \ - WHERE eth_txs_history.sent_at_block IS NULL AND eth_txs.confirmed_eth_tx_history_id IS NULL \ - ORDER BY eth_txs_history.id DESC", + r#" + SELECT + eth_txs_history.id, + eth_txs_history.eth_tx_id, + eth_txs_history.tx_hash, + eth_txs_history.base_fee_per_gas, + eth_txs_history.priority_fee_per_gas, + eth_txs_history.signed_raw_tx, + eth_txs.nonce + FROM + eth_txs_history + JOIN eth_txs ON eth_txs.id = eth_txs_history.eth_tx_id + WHERE + eth_txs_history.sent_at_block IS NULL + AND eth_txs.confirmed_eth_tx_history_id IS NULL + ORDER BY + eth_txs_history.id DESC + "#, ) .fetch_all(self.storage.conn()) .await?; @@ -137,9 +178,22 @@ impl EthSenderDal<'_, '_> { let address = format!("{:#x}", contract_address); let eth_tx = sqlx::query_as!( StorageEthTx, - "INSERT INTO eth_txs (raw_tx, nonce, tx_type, contract_address, predicted_gas_cost, created_at, updated_at) \ - VALUES ($1, $2, $3, $4, $5, now(), now()) \ - RETURNING *", + r#" + INSERT INTO + eth_txs ( + raw_tx, + nonce, + tx_type, + contract_address, + predicted_gas_cost, + created_at, + updated_at + ) + VALUES + ($1, $2, $3, $4, $5, NOW(), NOW()) + RETURNING + * + "#, raw_tx, nonce as i64, tx_type.to_string(), @@ -166,11 +220,23 @@ impl EthSenderDal<'_, '_> { let tx_hash = format!("{:#x}", tx_hash); Ok(sqlx::query!( - "INSERT INTO eth_txs_history \ - (eth_tx_id, base_fee_per_gas, priority_fee_per_gas, tx_hash, signed_raw_tx, created_at, updated_at) \ - VALUES ($1, $2, $3, $4, $5, now(), now()) \ - ON CONFLICT (tx_hash) DO NOTHING \ - RETURNING id", + r#" + INSERT INTO + eth_txs_history ( + eth_tx_id, + base_fee_per_gas, + priority_fee_per_gas, + tx_hash, + signed_raw_tx, + created_at, + updated_at + ) + VALUES + ($1, $2, $3, $4, $5, NOW(), NOW()) + ON CONFLICT (tx_hash) DO NOTHING + RETURNING + id + "#, eth_tx_id as u32, base_fee_per_gas, priority_fee_per_gas, @@ -188,8 +254,15 @@ impl EthSenderDal<'_, '_> { sent_at_block: u32, ) -> sqlx::Result<()> { sqlx::query!( - "UPDATE eth_txs_history SET sent_at_block = $2, sent_at = now() \ - WHERE id = $1 AND sent_at_block IS NULL", + r#" + UPDATE eth_txs_history + SET + sent_at_block = $2, + sent_at = NOW() + WHERE + id = $1 + AND sent_at_block IS NULL + "#, eth_txs_history_id as i32, sent_at_block as i32 ) @@ -200,8 +273,11 @@ impl EthSenderDal<'_, '_> { pub async fn remove_tx_history(&mut self, eth_txs_history_id: u32) -> sqlx::Result<()> { sqlx::query!( - "DELETE FROM eth_txs_history \ - WHERE id = $1", + r#" + DELETE FROM eth_txs_history + WHERE + id = $1 + "#, eth_txs_history_id as i64 ) .execute(self.storage.conn()) @@ -219,19 +295,31 @@ impl EthSenderDal<'_, '_> { .map_err(|err| anyhow::anyhow!("Can't convert U256 to i64: {err}"))?; let tx_hash = format!("{:#x}", tx_hash); let ids = sqlx::query!( - "UPDATE eth_txs_history \ - SET updated_at = now(), confirmed_at = now() \ - WHERE tx_hash = $1 \ - RETURNING id, eth_tx_id", + r#" + UPDATE eth_txs_history + SET + updated_at = NOW(), + confirmed_at = NOW() + WHERE + tx_hash = $1 + RETURNING + id, + eth_tx_id + "#, tx_hash, ) .fetch_one(transaction.conn()) .await?; sqlx::query!( - "UPDATE eth_txs \ - SET gas_used = $1, confirmed_eth_tx_history_id = $2 \ - WHERE id = $3", + r#" + UPDATE eth_txs + SET + gas_used = $1, + confirmed_eth_tx_history_id = $2 + WHERE + id = $3 + "#, gas_used, ids.id, ids.eth_tx_id @@ -248,8 +336,15 @@ impl EthSenderDal<'_, '_> { eth_tx_id: u32, ) -> anyhow::Result> { let tx_hash = sqlx::query!( - "SELECT tx_hash FROM eth_txs_history \ - WHERE eth_tx_id = $1 AND confirmed_at IS NOT NULL", + r#" + SELECT + tx_hash + FROM + eth_txs_history + WHERE + eth_tx_id = $1 + AND confirmed_at IS NOT NULL + "#, eth_tx_id as i64 ) .fetch_optional(self.storage.conn()) @@ -327,9 +422,13 @@ impl EthSenderDal<'_, '_> { // Mark general entry as confirmed. sqlx::query!( - "UPDATE eth_txs \ - SET confirmed_eth_tx_history_id = $1 \ - WHERE id = $2", + r#" + UPDATE eth_txs + SET + confirmed_eth_tx_history_id = $1 + WHERE + id = $2 + "#, eth_history_id, eth_tx_id ) @@ -356,7 +455,16 @@ impl EthSenderDal<'_, '_> { ) -> sqlx::Result> { let tx_history = sqlx::query_as!( StorageTxHistory, - "SELECT * FROM eth_txs_history WHERE eth_tx_id = $1 ORDER BY created_at DESC", + r#" + SELECT + * + FROM + eth_txs_history + WHERE + eth_tx_id = $1 + ORDER BY + created_at DESC + "#, eth_tx_id as i32 ) .fetch_all(self.storage.conn()) @@ -383,7 +491,18 @@ impl EthSenderDal<'_, '_> { ) -> sqlx::Result> { let history_item = sqlx::query_as!( StorageTxHistory, - "SELECT * FROM eth_txs_history WHERE eth_tx_id = $1 ORDER BY created_at DESC LIMIT 1", + r#" + SELECT + * + FROM + eth_txs_history + WHERE + eth_tx_id = $1 + ORDER BY + created_at DESC + LIMIT + 1 + "#, eth_tx_id as i32 ) .fetch_optional(self.storage.conn()) @@ -392,15 +511,32 @@ impl EthSenderDal<'_, '_> { } pub async fn get_next_nonce(&mut self) -> sqlx::Result> { - let row = sqlx::query!("SELECT nonce FROM eth_txs ORDER BY id DESC LIMIT 1") - .fetch_optional(self.storage.conn()) - .await?; + let row = sqlx::query!( + r#" + SELECT + nonce + FROM + eth_txs + ORDER BY + id DESC + LIMIT + 1 + "# + ) + .fetch_optional(self.storage.conn()) + .await?; Ok(row.map(|row| row.nonce as u64 + 1)) } pub async fn mark_failed_transaction(&mut self, eth_tx_id: u32) -> sqlx::Result<()> { sqlx::query!( - "UPDATE eth_txs SET has_failed = TRUE WHERE id = $1", + r#" + UPDATE eth_txs + SET + has_failed = TRUE + WHERE + id = $1 + "#, eth_tx_id as i32 ) .execute(self.storage.conn()) @@ -409,17 +545,36 @@ impl EthSenderDal<'_, '_> { } pub async fn get_number_of_failed_transactions(&mut self) -> anyhow::Result { - sqlx::query!("SELECT COUNT(*) FROM eth_txs WHERE has_failed = TRUE") - .fetch_one(self.storage.conn()) - .await? - .count - .context("count field is missing") + sqlx::query!( + r#" + SELECT + COUNT(*) + FROM + eth_txs + WHERE + has_failed = TRUE + "# + ) + .fetch_one(self.storage.conn()) + .await? + .count + .context("count field is missing") } pub async fn clear_failed_transactions(&mut self) -> sqlx::Result<()> { sqlx::query!( - "DELETE FROM eth_txs WHERE id >= \ - (SELECT MIN(id) FROM eth_txs WHERE has_failed = TRUE)" + r#" + DELETE FROM eth_txs + WHERE + id >= ( + SELECT + MIN(id) + FROM + eth_txs + WHERE + has_failed = TRUE + ) + "# ) .execute(self.storage.conn()) .await?; diff --git a/core/lib/dal/src/events_dal.rs b/core/lib/dal/src/events_dal.rs index 22967982b3b0..b7087985f520 100644 --- a/core/lib/dal/src/events_dal.rs +++ b/core/lib/dal/src/events_dal.rs @@ -93,7 +93,11 @@ impl EventsDal<'_, '_> { /// Removes events with a block number strictly greater than the specified `block_number`. pub async fn rollback_events(&mut self, block_number: MiniblockNumber) { sqlx::query!( - "DELETE FROM events WHERE miniblock_number > $1", + r#" + DELETE FROM events + WHERE + miniblock_number > $1 + "#, block_number.0 as i64 ) .execute(self.storage.conn()) @@ -166,7 +170,11 @@ impl EventsDal<'_, '_> { /// Removes all L2-to-L1 logs with a miniblock number strictly greater than the specified `block_number`. pub async fn rollback_l2_to_l1_logs(&mut self, block_number: MiniblockNumber) { sqlx::query!( - "DELETE FROM l2_to_l1_logs WHERE miniblock_number > $1", + r#" + DELETE FROM l2_to_l1_logs + WHERE + miniblock_number > $1 + "#, block_number.0 as i64 ) .execute(self.storage.conn()) @@ -180,13 +188,28 @@ impl EventsDal<'_, '_> { ) -> Result, SqlxError> { sqlx::query_as!( StorageL2ToL1Log, - "SELECT \ - miniblock_number, log_index_in_miniblock, log_index_in_tx, tx_hash, \ - Null::bytea as \"block_hash\", Null::bigint as \"l1_batch_number?\", \ - shard_id, is_service, tx_index_in_miniblock, tx_index_in_l1_batch, sender, key, value \ - FROM l2_to_l1_logs \ - WHERE tx_hash = $1 \ - ORDER BY log_index_in_tx ASC", + r#" + SELECT + miniblock_number, + log_index_in_miniblock, + log_index_in_tx, + tx_hash, + NULL::bytea AS "block_hash", + NULL::BIGINT AS "l1_batch_number?", + shard_id, + is_service, + tx_index_in_miniblock, + tx_index_in_l1_batch, + sender, + key, + value + FROM + l2_to_l1_logs + WHERE + tx_hash = $1 + ORDER BY + log_index_in_tx ASC + "#, tx_hash.as_bytes() ) .fetch_all(self.storage.conn()) diff --git a/core/lib/dal/src/events_web3_dal.rs b/core/lib/dal/src/events_web3_dal.rs index e8b1c802446e..06a049cd0030 100644 --- a/core/lib/dal/src/events_web3_dal.rs +++ b/core/lib/dal/src/events_web3_dal.rs @@ -138,27 +138,53 @@ impl EventsWeb3Dal<'_, '_> { let db_logs: Vec = sqlx::query_as!( StorageWeb3Log, r#" - WITH events_select AS ( - SELECT - address, topic1, topic2, topic3, topic4, value, - miniblock_number, tx_hash, tx_index_in_block, - event_index_in_block, event_index_in_tx - FROM events - WHERE miniblock_number > $1 - ORDER BY miniblock_number ASC, event_index_in_block ASC - ) - SELECT miniblocks.hash as "block_hash?", - address as "address!", topic1 as "topic1!", topic2 as "topic2!", topic3 as "topic3!", topic4 as "topic4!", value as "value!", - miniblock_number as "miniblock_number!", miniblocks.l1_batch_number as "l1_batch_number?", tx_hash as "tx_hash!", - tx_index_in_block as "tx_index_in_block!", event_index_in_block as "event_index_in_block!", event_index_in_tx as "event_index_in_tx!" - FROM events_select - INNER JOIN miniblocks ON events_select.miniblock_number = miniblocks.number - ORDER BY miniblock_number ASC, event_index_in_block ASC + WITH + events_select AS ( + SELECT + address, + topic1, + topic2, + topic3, + topic4, + value, + miniblock_number, + tx_hash, + tx_index_in_block, + event_index_in_block, + event_index_in_tx + FROM + events + WHERE + miniblock_number > $1 + ORDER BY + miniblock_number ASC, + event_index_in_block ASC + ) + SELECT + miniblocks.hash AS "block_hash?", + address AS "address!", + topic1 AS "topic1!", + topic2 AS "topic2!", + topic3 AS "topic3!", + topic4 AS "topic4!", + value AS "value!", + miniblock_number AS "miniblock_number!", + miniblocks.l1_batch_number AS "l1_batch_number?", + tx_hash AS "tx_hash!", + tx_index_in_block AS "tx_index_in_block!", + event_index_in_block AS "event_index_in_block!", + event_index_in_tx AS "event_index_in_tx!" + FROM + events_select + INNER JOIN miniblocks ON events_select.miniblock_number = miniblocks.number + ORDER BY + miniblock_number ASC, + event_index_in_block ASC "#, from_block.0 as i64 ) - .fetch_all(self.storage.conn()) - .await?; + .fetch_all(self.storage.conn()) + .await?; let logs = db_logs.into_iter().map(Into::into).collect(); Ok(logs) } diff --git a/core/lib/dal/src/fri_gpu_prover_queue_dal.rs b/core/lib/dal/src/fri_gpu_prover_queue_dal.rs index 141b2e0378e2..a29298944449 100644 --- a/core/lib/dal/src/fri_gpu_prover_queue_dal.rs +++ b/core/lib/dal/src/fri_gpu_prover_queue_dal.rs @@ -18,37 +18,49 @@ impl FriGpuProverQueueDal<'_, '_> { ) -> Option { let processing_timeout = pg_interval_from_duration(processing_timeout); let result: Option = sqlx::query!( - "UPDATE gpu_prover_queue_fri \ - SET instance_status = 'reserved', \ - updated_at = now(), \ - processing_started_at = now() \ - WHERE id in ( \ - SELECT id \ - FROM gpu_prover_queue_fri \ - WHERE specialized_prover_group_id=$2 \ - AND zone=$3 \ - AND ( \ - instance_status = 'available' \ - OR (instance_status = 'reserved' AND processing_started_at < now() - $1::interval) \ - ) \ - ORDER BY updated_at ASC \ - LIMIT 1 \ - FOR UPDATE \ - SKIP LOCKED \ - ) \ - RETURNING gpu_prover_queue_fri.* - ", - &processing_timeout, - specialized_prover_group_id as i16, - zone - ) - .fetch_optional(self.storage.conn()) - .await - .unwrap() - .map(|row| SocketAddress { - host: row.instance_host.network(), - port: row.instance_port as u16, - }); + r#" + UPDATE gpu_prover_queue_fri + SET + instance_status = 'reserved', + updated_at = NOW(), + processing_started_at = NOW() + WHERE + id IN ( + SELECT + id + FROM + gpu_prover_queue_fri + WHERE + specialized_prover_group_id = $2 + AND zone = $3 + AND ( + instance_status = 'available' + OR ( + instance_status = 'reserved' + AND processing_started_at < NOW() - $1::INTERVAL + ) + ) + ORDER BY + updated_at ASC + LIMIT + 1 + FOR UPDATE + SKIP LOCKED + ) + RETURNING + gpu_prover_queue_fri.* + "#, + &processing_timeout, + specialized_prover_group_id as i16, + zone + ) + .fetch_optional(self.storage.conn()) + .await + .unwrap() + .map(|row| SocketAddress { + host: row.instance_host.network(), + port: row.instance_port as u16, + }); result } @@ -60,18 +72,35 @@ impl FriGpuProverQueueDal<'_, '_> { zone: String, ) { sqlx::query!( - "INSERT INTO gpu_prover_queue_fri (instance_host, instance_port, instance_status, specialized_prover_group_id, zone, created_at, updated_at) \ - VALUES (cast($1::text as inet), $2, 'available', $3, $4, now(), now()) \ - ON CONFLICT(instance_host, instance_port, zone) \ - DO UPDATE SET instance_status='available', specialized_prover_group_id=$3, zone=$4, updated_at=now()", - format!("{}",address.host), - address.port as i32, - specialized_prover_group_id as i16, - zone + r#" + INSERT INTO + gpu_prover_queue_fri ( + instance_host, + instance_port, + instance_status, + specialized_prover_group_id, + zone, + created_at, + updated_at + ) + VALUES + (CAST($1::TEXT AS inet), $2, 'available', $3, $4, NOW(), NOW()) + ON CONFLICT (instance_host, instance_port, zone) DO + UPDATE + SET + instance_status = 'available', + specialized_prover_group_id = $3, + zone = $4, + updated_at = NOW() + "#, + format!("{}", address.host), + address.port as i32, + specialized_prover_group_id as i16, + zone ) - .execute(self.storage.conn()) - .await - .unwrap(); + .execute(self.storage.conn()) + .await + .unwrap(); } pub async fn update_prover_instance_status( @@ -81,12 +110,16 @@ impl FriGpuProverQueueDal<'_, '_> { zone: String, ) { sqlx::query!( - "UPDATE gpu_prover_queue_fri \ - SET instance_status = $1, updated_at = now() \ - WHERE instance_host = $2::text::inet \ - AND instance_port = $3 \ + r#" + UPDATE gpu_prover_queue_fri + SET + instance_status = $1, + updated_at = NOW() + WHERE + instance_host = $2::TEXT::inet + AND instance_port = $3 AND zone = $4 - ", + "#, format!("{:?}", status).to_lowercase(), format!("{}", address.host), address.port as i32, @@ -103,13 +136,17 @@ impl FriGpuProverQueueDal<'_, '_> { zone: String, ) { sqlx::query!( - "UPDATE gpu_prover_queue_fri \ - SET instance_status = 'available', updated_at = now() \ - WHERE instance_host = $1::text::inet \ - AND instance_port = $2 \ - AND instance_status = 'full' \ + r#" + UPDATE gpu_prover_queue_fri + SET + instance_status = 'available', + updated_at = NOW() + WHERE + instance_host = $1::TEXT::inet + AND instance_port = $2 + AND instance_status = 'full' AND zone = $3 - ", + "#, format!("{}", address.host), address.port as i32, zone diff --git a/core/lib/dal/src/fri_proof_compressor_dal.rs b/core/lib/dal/src/fri_proof_compressor_dal.rs index 6e6db0bb6d86..ee331204ec43 100644 --- a/core/lib/dal/src/fri_proof_compressor_dal.rs +++ b/core/lib/dal/src/fri_proof_compressor_dal.rs @@ -40,9 +40,13 @@ impl FriProofCompressorDal<'_, '_> { fri_proof_blob_url: &str, ) { sqlx::query!( - "INSERT INTO proof_compression_jobs_fri(l1_batch_number, fri_proof_blob_url, status, created_at, updated_at) \ - VALUES ($1, $2, $3, now(), now()) \ - ON CONFLICT (l1_batch_number) DO NOTHING", + r#" + INSERT INTO + proof_compression_jobs_fri (l1_batch_number, fri_proof_blob_url, status, created_at, updated_at) + VALUES + ($1, $2, $3, NOW(), NOW()) + ON CONFLICT (l1_batch_number) DO NOTHING + "#, block_number.0 as i64, fri_proof_blob_url, ProofCompressionJobStatus::Queued.to_string(), @@ -54,15 +58,19 @@ impl FriProofCompressorDal<'_, '_> { pub async fn skip_proof_compression_job(&mut self, block_number: L1BatchNumber) { sqlx::query!( - "INSERT INTO proof_compression_jobs_fri(l1_batch_number, status, created_at, updated_at) \ - VALUES ($1, $2, now(), now()) \ - ON CONFLICT (l1_batch_number) DO NOTHING", - block_number.0 as i64, + r#" + INSERT INTO + proof_compression_jobs_fri (l1_batch_number, status, created_at, updated_at) + VALUES + ($1, $2, NOW(), NOW()) + ON CONFLICT (l1_batch_number) DO NOTHING + "#, + block_number.0 as i64, ProofCompressionJobStatus::Skipped.to_string(), - ) - .fetch_optional(self.storage.conn()) - .await - .unwrap(); + ) + .fetch_optional(self.storage.conn()) + .await + .unwrap(); } pub async fn get_next_proof_compression_job( @@ -70,20 +78,32 @@ impl FriProofCompressorDal<'_, '_> { picked_by: &str, ) -> Option { sqlx::query!( - "UPDATE proof_compression_jobs_fri \ - SET status = $1, attempts = attempts + 1, \ - updated_at = now(), processing_started_at = now(), \ - picked_by = $3 \ - WHERE l1_batch_number = ( \ - SELECT l1_batch_number \ - FROM proof_compression_jobs_fri \ - WHERE status = $2 \ - ORDER BY l1_batch_number ASC \ - LIMIT 1 \ - FOR UPDATE \ - SKIP LOCKED \ - ) \ - RETURNING proof_compression_jobs_fri.l1_batch_number", + r#" + UPDATE proof_compression_jobs_fri + SET + status = $1, + attempts = attempts + 1, + updated_at = NOW(), + processing_started_at = NOW(), + picked_by = $3 + WHERE + l1_batch_number = ( + SELECT + l1_batch_number + FROM + proof_compression_jobs_fri + WHERE + status = $2 + ORDER BY + l1_batch_number ASC + LIMIT + 1 + FOR UPDATE + SKIP LOCKED + ) + RETURNING + proof_compression_jobs_fri.l1_batch_number + "#, ProofCompressionJobStatus::InProgress.to_string(), ProofCompressionJobStatus::Queued.to_string(), picked_by, @@ -99,8 +119,14 @@ impl FriProofCompressorDal<'_, '_> { l1_batch_number: L1BatchNumber, ) -> sqlx::Result> { let attempts = sqlx::query!( - "SELECT attempts FROM proof_compression_jobs_fri \ - WHERE l1_batch_number = $1", + r#" + SELECT + attempts + FROM + proof_compression_jobs_fri + WHERE + l1_batch_number = $1 + "#, l1_batch_number.0 as i64, ) .fetch_optional(self.storage.conn()) @@ -117,9 +143,16 @@ impl FriProofCompressorDal<'_, '_> { l1_proof_blob_url: &str, ) { sqlx::query!( - "UPDATE proof_compression_jobs_fri \ - SET status = $1, updated_at = now(), time_taken = $2, l1_proof_blob_url = $3\ - WHERE l1_batch_number = $4", + r#" + UPDATE proof_compression_jobs_fri + SET + status = $1, + updated_at = NOW(), + time_taken = $2, + l1_proof_blob_url = $3 + WHERE + l1_batch_number = $4 + "#, ProofCompressionJobStatus::Successful.to_string(), duration_to_naive_time(time_taken), l1_proof_blob_url, @@ -136,9 +169,15 @@ impl FriProofCompressorDal<'_, '_> { block_number: L1BatchNumber, ) { sqlx::query!( - "UPDATE proof_compression_jobs_fri \ - SET status =$1, error= $2, updated_at = now() \ - WHERE l1_batch_number = $3", + r#" + UPDATE proof_compression_jobs_fri + SET + status = $1, + error = $2, + updated_at = NOW() + WHERE + l1_batch_number = $3 + "#, ProofCompressionJobStatus::Failed.to_string(), error, block_number.0 as i64 @@ -152,13 +191,23 @@ impl FriProofCompressorDal<'_, '_> { &mut self, ) -> Option<(L1BatchNumber, ProofCompressionJobStatus)> { let row = sqlx::query!( - "SELECT l1_batch_number, status \ - FROM proof_compression_jobs_fri - WHERE l1_batch_number = ( \ - SELECT MIN(l1_batch_number) \ - FROM proof_compression_jobs_fri \ - WHERE status = $1 OR status = $2 - )", + r#" + SELECT + l1_batch_number, + status + FROM + proof_compression_jobs_fri + WHERE + l1_batch_number = ( + SELECT + MIN(l1_batch_number) + FROM + proof_compression_jobs_fri + WHERE + status = $1 + OR status = $2 + ) + "#, ProofCompressionJobStatus::Successful.to_string(), ProofCompressionJobStatus::Skipped.to_string() ) @@ -176,9 +225,14 @@ impl FriProofCompressorDal<'_, '_> { pub async fn mark_proof_sent_to_server(&mut self, block_number: L1BatchNumber) { sqlx::query!( - "UPDATE proof_compression_jobs_fri \ - SET status = $1, updated_at = now() \ - WHERE l1_batch_number = $2", + r#" + UPDATE proof_compression_jobs_fri + SET + status = $1, + updated_at = NOW() + WHERE + l1_batch_number = $2 + "#, ProofCompressionJobStatus::SentToServer.to_string(), block_number.0 as i64 ) @@ -210,11 +264,18 @@ impl FriProofCompressorDal<'_, '_> { pub async fn get_oldest_not_compressed_batch(&mut self) -> Option { let result: Option = sqlx::query!( - "SELECT l1_batch_number \ - FROM proof_compression_jobs_fri \ - WHERE status <> 'successful' \ - ORDER BY l1_batch_number ASC \ - LIMIT 1", + r#" + SELECT + l1_batch_number + FROM + proof_compression_jobs_fri + WHERE + status <> 'successful' + ORDER BY + l1_batch_number ASC + LIMIT + 1 + "#, ) .fetch_optional(self.storage.conn()) .await @@ -232,20 +293,40 @@ impl FriProofCompressorDal<'_, '_> { let processing_timeout = pg_interval_from_duration(processing_timeout); { sqlx::query!( - "UPDATE proof_compression_jobs_fri \ - SET status = 'queued', updated_at = now(), processing_started_at = now() \ - WHERE (status = 'in_progress' AND processing_started_at <= now() - $1::interval AND attempts < $2) \ - OR (status = 'failed' AND attempts < $2) \ - RETURNING l1_batch_number, status, attempts", + r#" + UPDATE proof_compression_jobs_fri + SET + status = 'queued', + updated_at = NOW(), + processing_started_at = NOW() + WHERE + ( + status = 'in_progress' + AND processing_started_at <= NOW() - $1::INTERVAL + AND attempts < $2 + ) + OR ( + status = 'failed' + AND attempts < $2 + ) + RETURNING + l1_batch_number, + status, + attempts + "#, &processing_timeout, max_attempts as i32, ) - .fetch_all(self.storage.conn()) - .await - .unwrap() - .into_iter() - .map(|row| StuckJobs { id: row.l1_batch_number as u64, status: row.status, attempts: row.attempts as u64 }) - .collect() + .fetch_all(self.storage.conn()) + .await + .unwrap() + .into_iter() + .map(|row| StuckJobs { + id: row.l1_batch_number as u64, + status: row.status, + attempts: row.attempts as u64, + }) + .collect() } } } diff --git a/core/lib/dal/src/fri_protocol_versions_dal.rs b/core/lib/dal/src/fri_protocol_versions_dal.rs index 7eac1190bb9f..d982d85771e9 100644 --- a/core/lib/dal/src/fri_protocol_versions_dal.rs +++ b/core/lib/dal/src/fri_protocol_versions_dal.rs @@ -16,11 +16,20 @@ impl FriProtocolVersionsDal<'_, '_> { l1_verifier_config: L1VerifierConfig, ) { sqlx::query!( - "INSERT INTO prover_fri_protocol_versions \ - (id, recursion_scheduler_level_vk_hash, recursion_node_level_vk_hash, \ - recursion_leaf_level_vk_hash, recursion_circuits_set_vks_hash, created_at) \ - VALUES ($1, $2, $3, $4, $5, now()) \ - ON CONFLICT(id) DO NOTHING", + r#" + INSERT INTO + prover_fri_protocol_versions ( + id, + recursion_scheduler_level_vk_hash, + recursion_node_level_vk_hash, + recursion_leaf_level_vk_hash, + recursion_circuits_set_vks_hash, + created_at + ) + VALUES + ($1, $2, $3, $4, $5, NOW()) + ON CONFLICT (id) DO NOTHING + "#, id as i32, l1_verifier_config .recursion_scheduler_level_vk_hash @@ -48,13 +57,17 @@ impl FriProtocolVersionsDal<'_, '_> { vk_commitments: &L1VerifierConfig, ) -> Vec { sqlx::query!( - "SELECT id \ - FROM prover_fri_protocol_versions \ - WHERE recursion_circuits_set_vks_hash = $1 \ - AND recursion_leaf_level_vk_hash = $2 \ - AND recursion_node_level_vk_hash = $3 \ - AND recursion_scheduler_level_vk_hash = $4 \ - ", + r#" + SELECT + id + FROM + prover_fri_protocol_versions + WHERE + recursion_circuits_set_vks_hash = $1 + AND recursion_leaf_level_vk_hash = $2 + AND recursion_node_level_vk_hash = $3 + AND recursion_scheduler_level_vk_hash = $4 + "#, vk_commitments .params .recursion_circuits_set_vks_hash diff --git a/core/lib/dal/src/fri_prover_dal.rs b/core/lib/dal/src/fri_prover_dal.rs index c172ed2678fc..d9446182b7f2 100644 --- a/core/lib/dal/src/fri_prover_dal.rs +++ b/core/lib/dal/src/fri_prover_dal.rs @@ -54,40 +54,56 @@ impl FriProverDal<'_, '_> { ) -> Option { let protocol_versions: Vec = protocol_versions.iter().map(|&id| id as i32).collect(); sqlx::query!( - " - UPDATE prover_jobs_fri - SET status = 'in_progress', attempts = attempts + 1, - updated_at = now(), processing_started_at = now(), - picked_by = $2 - WHERE id = ( - SELECT id - FROM prover_jobs_fri - WHERE status = 'queued' - AND protocol_version = ANY($1) - ORDER BY aggregation_round DESC, l1_batch_number ASC, id ASC - LIMIT 1 + r#" + UPDATE prover_jobs_fri + SET + status = 'in_progress', + attempts = attempts + 1, + updated_at = NOW(), + processing_started_at = NOW(), + picked_by = $2 + WHERE + id = ( + SELECT + id + FROM + prover_jobs_fri + WHERE + status = 'queued' + AND protocol_version = ANY ($1) + ORDER BY + aggregation_round DESC, + l1_batch_number ASC, + id ASC + LIMIT + 1 FOR UPDATE - SKIP LOCKED + SKIP LOCKED ) - RETURNING prover_jobs_fri.id, prover_jobs_fri.l1_batch_number, prover_jobs_fri.circuit_id, - prover_jobs_fri.aggregation_round, prover_jobs_fri.sequence_number, prover_jobs_fri.depth, + RETURNING + prover_jobs_fri.id, + prover_jobs_fri.l1_batch_number, + prover_jobs_fri.circuit_id, + prover_jobs_fri.aggregation_round, + prover_jobs_fri.sequence_number, + prover_jobs_fri.depth, prover_jobs_fri.is_node_final_proof - ", + "#, &protocol_versions[..], picked_by, ) - .fetch_optional(self.storage.conn()) - .await - .unwrap() - .map(|row| FriProverJobMetadata { - id: row.id as u32, - block_number: L1BatchNumber(row.l1_batch_number as u32), - circuit_id: row.circuit_id as u8, - aggregation_round: AggregationRound::try_from(row.aggregation_round as i32).unwrap(), - sequence_number: row.sequence_number as usize, - depth: row.depth as u16, - is_node_final_proof: row.is_node_final_proof, - }) + .fetch_optional(self.storage.conn()) + .await + .unwrap() + .map(|row| FriProverJobMetadata { + id: row.id as u32, + block_number: L1BatchNumber(row.l1_batch_number as u32), + circuit_id: row.circuit_id as u8, + aggregation_round: AggregationRound::try_from(row.aggregation_round as i32).unwrap(), + sequence_number: row.sequence_number as usize, + depth: row.depth as u16, + is_node_final_proof: row.is_node_final_proof, + }) } pub async fn get_next_job_for_circuit_id_round( @@ -106,59 +122,90 @@ impl FriProverDal<'_, '_> { .map(|tuple| tuple.aggregation_round as i16) .collect(); sqlx::query!( - " - UPDATE prover_jobs_fri - SET status = 'in_progress', attempts = attempts + 1, - processing_started_at = now(), updated_at = now(), - picked_by = $4 - WHERE id = ( - SELECT pj.id - FROM ( SELECT * FROM unnest($1::smallint[], $2::smallint[]) ) AS tuple (circuit_id, round) - JOIN LATERAL - ( - SELECT * FROM prover_jobs_fri AS pj - WHERE pj.status = 'queued' - AND pj.protocol_version = ANY($3) - AND pj.circuit_id = tuple.circuit_id AND pj.aggregation_round = tuple.round - ORDER BY pj.l1_batch_number ASC, pj.id ASC - LIMIT 1 - ) AS pj ON true - ORDER BY pj.l1_batch_number ASC, pj.aggregation_round DESC, pj.id ASC - LIMIT 1 + r#" + UPDATE prover_jobs_fri + SET + status = 'in_progress', + attempts = attempts + 1, + processing_started_at = NOW(), + updated_at = NOW(), + picked_by = $4 + WHERE + id = ( + SELECT + pj.id + FROM + ( + SELECT + * + FROM + UNNEST($1::SMALLINT[], $2::SMALLINT[]) + ) AS tuple (circuit_id, ROUND) + JOIN LATERAL ( + SELECT + * + FROM + prover_jobs_fri AS pj + WHERE + pj.status = 'queued' + AND pj.protocol_version = ANY ($3) + AND pj.circuit_id = tuple.circuit_id + AND pj.aggregation_round = tuple.round + ORDER BY + pj.l1_batch_number ASC, + pj.id ASC + LIMIT + 1 + ) AS pj ON TRUE + ORDER BY + pj.l1_batch_number ASC, + pj.aggregation_round DESC, + pj.id ASC + LIMIT + 1 FOR UPDATE - SKIP LOCKED + SKIP LOCKED ) - RETURNING prover_jobs_fri.id, prover_jobs_fri.l1_batch_number, prover_jobs_fri.circuit_id, - prover_jobs_fri.aggregation_round, prover_jobs_fri.sequence_number, prover_jobs_fri.depth, + RETURNING + prover_jobs_fri.id, + prover_jobs_fri.l1_batch_number, + prover_jobs_fri.circuit_id, + prover_jobs_fri.aggregation_round, + prover_jobs_fri.sequence_number, + prover_jobs_fri.depth, prover_jobs_fri.is_node_final_proof - ", + "#, &circuit_ids[..], &aggregation_rounds[..], &protocol_versions[..], picked_by, ) - .fetch_optional(self.storage.conn()) - .await - .unwrap() - .map(|row| FriProverJobMetadata { - id: row.id as u32, - block_number: L1BatchNumber(row.l1_batch_number as u32), - circuit_id: row.circuit_id as u8, - aggregation_round: AggregationRound::try_from(row.aggregation_round as i32).unwrap(), - sequence_number: row.sequence_number as usize, - depth: row.depth as u16, - is_node_final_proof: row.is_node_final_proof, - }) + .fetch_optional(self.storage.conn()) + .await + .unwrap() + .map(|row| FriProverJobMetadata { + id: row.id as u32, + block_number: L1BatchNumber(row.l1_batch_number as u32), + circuit_id: row.circuit_id as u8, + aggregation_round: AggregationRound::try_from(row.aggregation_round as i32).unwrap(), + sequence_number: row.sequence_number as usize, + depth: row.depth as u16, + is_node_final_proof: row.is_node_final_proof, + }) } pub async fn save_proof_error(&mut self, id: u32, error: String) { { sqlx::query!( - " + r#" UPDATE prover_jobs_fri - SET status = 'failed', error = $1, updated_at = now() - WHERE id = $2 - ", + SET + status = 'failed', + error = $1, + updated_at = NOW() + WHERE + id = $2 + "#, error, id as i64, ) @@ -170,7 +217,14 @@ impl FriProverDal<'_, '_> { pub async fn get_prover_job_attempts(&mut self, id: u32) -> sqlx::Result> { let attempts = sqlx::query!( - "SELECT attempts FROM prover_jobs_fri WHERE id = $1", + r#" + SELECT + attempts + FROM + prover_jobs_fri + WHERE + id = $1 + "#, id as i64, ) .fetch_optional(self.storage.conn()) @@ -187,34 +241,44 @@ impl FriProverDal<'_, '_> { blob_url: &str, ) -> FriProverJobMetadata { sqlx::query!( - " - UPDATE prover_jobs_fri - SET status = 'successful', updated_at = now(), time_taken = $1, proof_blob_url=$2 - WHERE id = $3 - RETURNING prover_jobs_fri.id, prover_jobs_fri.l1_batch_number, prover_jobs_fri.circuit_id, - prover_jobs_fri.aggregation_round, prover_jobs_fri.sequence_number, prover_jobs_fri.depth, + r#" + UPDATE prover_jobs_fri + SET + status = 'successful', + updated_at = NOW(), + time_taken = $1, + proof_blob_url = $2 + WHERE + id = $3 + RETURNING + prover_jobs_fri.id, + prover_jobs_fri.l1_batch_number, + prover_jobs_fri.circuit_id, + prover_jobs_fri.aggregation_round, + prover_jobs_fri.sequence_number, + prover_jobs_fri.depth, prover_jobs_fri.is_node_final_proof - ", + "#, duration_to_naive_time(time_taken), blob_url, id as i64, ) - .instrument("save_fri_proof") - .report_latency() - .with_arg("id", &id) - .fetch_optional(self.storage.conn()) - .await - .unwrap() - .map(|row| FriProverJobMetadata { - id: row.id as u32, - block_number: L1BatchNumber(row.l1_batch_number as u32), - circuit_id: row.circuit_id as u8, - aggregation_round: AggregationRound::try_from(row.aggregation_round as i32).unwrap(), - sequence_number: row.sequence_number as usize, - depth: row.depth as u16, - is_node_final_proof: row.is_node_final_proof, - }) - .unwrap() + .instrument("save_fri_proof") + .report_latency() + .with_arg("id", &id) + .fetch_optional(self.storage.conn()) + .await + .unwrap() + .map(|row| FriProverJobMetadata { + id: row.id as u32, + block_number: L1BatchNumber(row.l1_batch_number as u32), + circuit_id: row.circuit_id as u8, + aggregation_round: AggregationRound::try_from(row.aggregation_round as i32).unwrap(), + sequence_number: row.sequence_number as usize, + depth: row.depth as u16, + is_node_final_proof: row.is_node_final_proof, + }) + .unwrap() } pub async fn requeue_stuck_jobs( @@ -225,28 +289,54 @@ impl FriProverDal<'_, '_> { let processing_timeout = pg_interval_from_duration(processing_timeout); { sqlx::query!( - " + r#" UPDATE prover_jobs_fri - SET status = 'queued', updated_at = now(), processing_started_at = now() - WHERE id in ( - SELECT id - FROM prover_jobs_fri - WHERE (status = 'in_progress' AND processing_started_at <= now() - $1::interval AND attempts < $2) - OR (status = 'in_gpu_proof' AND processing_started_at <= now() - $1::interval AND attempts < $2) - OR (status = 'failed' AND attempts < $2) - FOR UPDATE SKIP LOCKED - ) - RETURNING id, status, attempts - ", + SET + status = 'queued', + updated_at = NOW(), + processing_started_at = NOW() + WHERE + id IN ( + SELECT + id + FROM + prover_jobs_fri + WHERE + ( + status = 'in_progress' + AND processing_started_at <= NOW() - $1::INTERVAL + AND attempts < $2 + ) + OR ( + status = 'in_gpu_proof' + AND processing_started_at <= NOW() - $1::INTERVAL + AND attempts < $2 + ) + OR ( + status = 'failed' + AND attempts < $2 + ) + FOR UPDATE + SKIP LOCKED + ) + RETURNING + id, + status, + attempts + "#, &processing_timeout, max_attempts as i32, ) - .fetch_all(self.storage.conn()) - .await - .unwrap() - .into_iter() - .map(|row| StuckJobs { id: row.id as u64, status: row.status, attempts: row.attempts as u64 }) - .collect() + .fetch_all(self.storage.conn()) + .await + .unwrap() + .into_iter() + .map(|row| StuckJobs { + id: row.id as u64, + status: row.status, + attempts: row.attempts as u64, + }) + .collect() } } @@ -263,12 +353,28 @@ impl FriProverDal<'_, '_> { protocol_version_id: FriProtocolVersionId, ) { sqlx::query!( - " - INSERT INTO prover_jobs_fri (l1_batch_number, circuit_id, circuit_blob_url, aggregation_round, sequence_number, depth, is_node_final_proof, protocol_version, status, created_at, updated_at) - VALUES ($1, $2, $3, $4, $5, $6, $7, $8, 'queued', now(), now()) - ON CONFLICT(l1_batch_number, aggregation_round, circuit_id, depth, sequence_number) - DO UPDATE SET updated_at=now() - ", + r#" + INSERT INTO + prover_jobs_fri ( + l1_batch_number, + circuit_id, + circuit_blob_url, + aggregation_round, + sequence_number, + depth, + is_node_final_proof, + protocol_version, + status, + created_at, + updated_at + ) + VALUES + ($1, $2, $3, $4, $5, $6, $7, $8, 'queued', NOW(), NOW()) + ON CONFLICT (l1_batch_number, aggregation_round, circuit_id, depth, sequence_number) DO + UPDATE + SET + updated_at = NOW() + "#, l1_batch_number.0 as i64, circuit_id as i16, circuit_blob_url, @@ -287,24 +393,45 @@ impl FriProverDal<'_, '_> { { sqlx::query!( r#" - SELECT COUNT(*) as "count!", circuit_id as "circuit_id!", aggregation_round as "aggregation_round!", status as "status!" - FROM prover_jobs_fri - WHERE status <> 'skipped' and status <> 'successful' - GROUP BY circuit_id, aggregation_round, status + SELECT + COUNT(*) AS "count!", + circuit_id AS "circuit_id!", + aggregation_round AS "aggregation_round!", + status AS "status!" + FROM + prover_jobs_fri + WHERE + status <> 'skipped' + AND status <> 'successful' + GROUP BY + circuit_id, + aggregation_round, + status "# ) - .fetch_all(self.storage.conn()) - .await - .unwrap() - .into_iter() - .map(|row| (row.circuit_id, row.aggregation_round, row.status, row.count as usize)) - .fold(HashMap::new(), |mut acc, (circuit_id, aggregation_round, status, value)| { - let stats = acc.entry((circuit_id as u8, aggregation_round as u8)).or_insert(JobCountStatistics { - queued: 0, - in_progress: 0, - failed: 0, - successful: 0, - }); + .fetch_all(self.storage.conn()) + .await + .unwrap() + .into_iter() + .map(|row| { + ( + row.circuit_id, + row.aggregation_round, + row.status, + row.count as usize, + ) + }) + .fold( + HashMap::new(), + |mut acc, (circuit_id, aggregation_round, status, value)| { + let stats = acc + .entry((circuit_id as u8, aggregation_round as u8)) + .or_insert(JobCountStatistics { + queued: 0, + in_progress: 0, + failed: 0, + successful: 0, + }); match status.as_ref() { "queued" => stats.queued = value, "in_progress" => stats.in_progress = value, @@ -313,7 +440,8 @@ impl FriProverDal<'_, '_> { _ => (), } acc - }) + }, + ) } } @@ -321,10 +449,17 @@ impl FriProverDal<'_, '_> { { sqlx::query!( r#" - SELECT MIN(l1_batch_number) as "l1_batch_number!", circuit_id, aggregation_round - FROM prover_jobs_fri - WHERE status IN('queued', 'in_gpu_proof', 'in_progress', 'failed') - GROUP BY circuit_id, aggregation_round + SELECT + MIN(l1_batch_number) AS "l1_batch_number!", + circuit_id, + aggregation_round + FROM + prover_jobs_fri + WHERE + status IN ('queued', 'in_gpu_proof', 'in_progress', 'failed') + GROUP BY + circuit_id, + aggregation_round "# ) .fetch_all(self.storage.conn()) @@ -347,14 +482,19 @@ impl FriProverDal<'_, '_> { ) -> Option { sqlx::query!( r#" - SELECT l1_batch_number - FROM prover_jobs_fri - WHERE status <> 'skipped' - AND status <> 'successful' - AND aggregation_round = $1 - ORDER BY l1_batch_number ASC - LIMIT 1 - "#, + SELECT + l1_batch_number + FROM + prover_jobs_fri + WHERE + status <> 'skipped' + AND status <> 'successful' + AND aggregation_round = $1 + ORDER BY + l1_batch_number ASC + LIMIT + 1 + "#, aggregation_round as i16 ) .fetch_optional(self.storage.conn()) @@ -365,9 +505,14 @@ impl FriProverDal<'_, '_> { pub async fn update_status(&mut self, id: u32, status: &str) { sqlx::query!( - "UPDATE prover_jobs_fri \ - SET status = $1, updated_at = now() \ - WHERE id = $2", + r#" + UPDATE prover_jobs_fri + SET + status = $1, + updated_at = NOW() + WHERE + id = $2 + "#, status, id as i64, ) @@ -378,9 +523,14 @@ impl FriProverDal<'_, '_> { pub async fn save_successful_sent_proof(&mut self, l1_batch_number: L1BatchNumber) { sqlx::query!( - "UPDATE prover_jobs_fri \ - SET status = 'sent_to_server', updated_at = now() \ - WHERE l1_batch_number = $1", + r#" + UPDATE prover_jobs_fri + SET + status = 'sent_to_server', + updated_at = NOW() + WHERE + l1_batch_number = $1 + "#, l1_batch_number.0 as i64, ) .execute(self.storage.conn()) @@ -393,10 +543,16 @@ impl FriProverDal<'_, '_> { l1_batch_number: L1BatchNumber, ) -> Option { sqlx::query!( - "SELECT id from prover_jobs_fri \ - WHERE l1_batch_number = $1 \ - AND status = 'successful' \ - AND aggregation_round = $2", + r#" + SELECT + id + FROM + prover_jobs_fri + WHERE + l1_batch_number = $1 + AND status = 'successful' + AND aggregation_round = $2 + "#, l1_batch_number.0 as i64, AggregationRound::Scheduler as i16, ) diff --git a/core/lib/dal/src/fri_scheduler_dependency_tracker_dal.rs b/core/lib/dal/src/fri_scheduler_dependency_tracker_dal.rs index a9639dfe9518..e123ab7064b3 100644 --- a/core/lib/dal/src/fri_scheduler_dependency_tracker_dal.rs +++ b/core/lib/dal/src/fri_scheduler_dependency_tracker_dal.rs @@ -11,26 +11,33 @@ impl FriSchedulerDependencyTrackerDal<'_, '_> { pub async fn get_l1_batches_ready_for_queuing(&mut self) -> Vec { sqlx::query!( r#" - UPDATE scheduler_dependency_tracker_fri - SET status='queuing' - WHERE l1_batch_number IN - (SELECT l1_batch_number FROM scheduler_dependency_tracker_fri - WHERE status != 'queued' - AND circuit_1_final_prover_job_id IS NOT NULL - AND circuit_2_final_prover_job_id IS NOT NULL - AND circuit_3_final_prover_job_id IS NOT NULL - AND circuit_4_final_prover_job_id IS NOT NULL - AND circuit_5_final_prover_job_id IS NOT NULL - AND circuit_6_final_prover_job_id IS NOT NULL - AND circuit_7_final_prover_job_id IS NOT NULL - AND circuit_8_final_prover_job_id IS NOT NULL - AND circuit_9_final_prover_job_id IS NOT NULL - AND circuit_10_final_prover_job_id IS NOT NULL - AND circuit_11_final_prover_job_id IS NOT NULL - AND circuit_12_final_prover_job_id IS NOT NULL - AND circuit_13_final_prover_job_id IS NOT NULL - ) - RETURNING l1_batch_number; + UPDATE scheduler_dependency_tracker_fri + SET + status = 'queuing' + WHERE + l1_batch_number IN ( + SELECT + l1_batch_number + FROM + scheduler_dependency_tracker_fri + WHERE + status != 'queued' + AND circuit_1_final_prover_job_id IS NOT NULL + AND circuit_2_final_prover_job_id IS NOT NULL + AND circuit_3_final_prover_job_id IS NOT NULL + AND circuit_4_final_prover_job_id IS NOT NULL + AND circuit_5_final_prover_job_id IS NOT NULL + AND circuit_6_final_prover_job_id IS NOT NULL + AND circuit_7_final_prover_job_id IS NOT NULL + AND circuit_8_final_prover_job_id IS NOT NULL + AND circuit_9_final_prover_job_id IS NOT NULL + AND circuit_10_final_prover_job_id IS NOT NULL + AND circuit_11_final_prover_job_id IS NOT NULL + AND circuit_12_final_prover_job_id IS NOT NULL + AND circuit_13_final_prover_job_id IS NOT NULL + ) + RETURNING + l1_batch_number; "#, ) .fetch_all(self.storage.conn()) @@ -44,10 +51,12 @@ impl FriSchedulerDependencyTrackerDal<'_, '_> { pub async fn mark_l1_batches_queued(&mut self, l1_batches: Vec) { sqlx::query!( r#" - UPDATE scheduler_dependency_tracker_fri - SET status='queued' - WHERE l1_batch_number = ANY($1) - "#, + UPDATE scheduler_dependency_tracker_fri + SET + status = 'queued' + WHERE + l1_batch_number = ANY ($1) + "#, &l1_batches[..] ) .execute(self.storage.conn()) @@ -83,9 +92,13 @@ impl FriSchedulerDependencyTrackerDal<'_, '_> { ) -> [u32; 13] { sqlx::query!( r#" - SELECT * FROM scheduler_dependency_tracker_fri - WHERE l1_batch_number = $1 - "#, + SELECT + * + FROM + scheduler_dependency_tracker_fri + WHERE + l1_batch_number = $1 + "#, l1_batch_number.0 as i64, ) .fetch_all(self.storage.conn()) diff --git a/core/lib/dal/src/fri_witness_generator_dal.rs b/core/lib/dal/src/fri_witness_generator_dal.rs index c11f20adec56..874ad8d03689 100644 --- a/core/lib/dal/src/fri_witness_generator_dal.rs +++ b/core/lib/dal/src/fri_witness_generator_dal.rs @@ -43,16 +43,27 @@ impl FriWitnessGeneratorDal<'_, '_> { protocol_version_id: FriProtocolVersionId, ) { sqlx::query!( - "INSERT INTO witness_inputs_fri(l1_batch_number, merkle_tree_paths_blob_url, protocol_version, status, created_at, updated_at) \ - VALUES ($1, $2, $3, 'queued', now(), now()) \ - ON CONFLICT (l1_batch_number) DO NOTHING", - block_number.0 as i64, - object_key, - protocol_version_id as i32, - ) - .fetch_optional(self.storage.conn()) - .await - .unwrap(); + r#" + INSERT INTO + witness_inputs_fri ( + l1_batch_number, + merkle_tree_paths_blob_url, + protocol_version, + status, + created_at, + updated_at + ) + VALUES + ($1, $2, $3, 'queued', NOW(), NOW()) + ON CONFLICT (l1_batch_number) DO NOTHING + "#, + block_number.0 as i64, + object_key, + protocol_version_id as i32, + ) + .fetch_optional(self.storage.conn()) + .await + .unwrap(); } pub async fn get_next_basic_circuit_witness_job( @@ -63,24 +74,34 @@ impl FriWitnessGeneratorDal<'_, '_> { ) -> Option { let protocol_versions: Vec = protocol_versions.iter().map(|&id| id as i32).collect(); sqlx::query!( - " - UPDATE witness_inputs_fri - SET status = 'in_progress', attempts = attempts + 1, - updated_at = now(), processing_started_at = now(), - picked_by = $3 - WHERE l1_batch_number = ( - SELECT l1_batch_number - FROM witness_inputs_fri - WHERE l1_batch_number <= $1 - AND status = 'queued' - AND protocol_version = ANY($2) - ORDER BY l1_batch_number ASC - LIMIT 1 + r#" + UPDATE witness_inputs_fri + SET + status = 'in_progress', + attempts = attempts + 1, + updated_at = NOW(), + processing_started_at = NOW(), + picked_by = $3 + WHERE + l1_batch_number = ( + SELECT + l1_batch_number + FROM + witness_inputs_fri + WHERE + l1_batch_number <= $1 + AND status = 'queued' + AND protocol_version = ANY ($2) + ORDER BY + l1_batch_number ASC + LIMIT + 1 FOR UPDATE - SKIP LOCKED + SKIP LOCKED ) - RETURNING witness_inputs_fri.* - ", + RETURNING + witness_inputs_fri.* + "#, last_l1_batch_to_process as i64, &protocol_versions[..], picked_by, @@ -96,8 +117,14 @@ impl FriWitnessGeneratorDal<'_, '_> { l1_batch_number: L1BatchNumber, ) -> sqlx::Result> { let attempts = sqlx::query!( - "SELECT attempts FROM witness_inputs_fri \ - WHERE l1_batch_number = $1", + r#" + SELECT + attempts + FROM + witness_inputs_fri + WHERE + l1_batch_number = $1 + "#, l1_batch_number.0 as i64, ) .fetch_optional(self.storage.conn()) @@ -113,10 +140,14 @@ impl FriWitnessGeneratorDal<'_, '_> { block_number: L1BatchNumber, ) { sqlx::query!( - " - UPDATE witness_inputs_fri SET status =$1, updated_at = now() - WHERE l1_batch_number = $2 - ", + r#" + UPDATE witness_inputs_fri + SET + status = $1, + updated_at = NOW() + WHERE + l1_batch_number = $2 + "#, format!("{}", status), block_number.0 as i64 ) @@ -131,11 +162,15 @@ impl FriWitnessGeneratorDal<'_, '_> { time_taken: Duration, ) { sqlx::query!( - " - UPDATE witness_inputs_fri - SET status = 'successful', updated_at = now(), time_taken = $1 - WHERE l1_batch_number = $2 - ", + r#" + UPDATE witness_inputs_fri + SET + status = 'successful', + updated_at = NOW(), + time_taken = $1 + WHERE + l1_batch_number = $2 + "#, duration_to_naive_time(time_taken), block_number.0 as i64 ) @@ -146,10 +181,15 @@ impl FriWitnessGeneratorDal<'_, '_> { pub async fn mark_witness_job_failed(&mut self, error: &str, block_number: L1BatchNumber) { sqlx::query!( - " - UPDATE witness_inputs_fri SET status ='failed', error= $1, updated_at = now() - WHERE l1_batch_number = $2 - ", + r#" + UPDATE witness_inputs_fri + SET + status = 'failed', + error = $1, + updated_at = NOW() + WHERE + l1_batch_number = $2 + "#, error, block_number.0 as i64 ) @@ -160,11 +200,15 @@ impl FriWitnessGeneratorDal<'_, '_> { pub async fn mark_leaf_aggregation_job_failed(&mut self, error: &str, id: u32) { sqlx::query!( - " - UPDATE leaf_aggregation_witness_jobs_fri - SET status ='failed', error= $1, updated_at = now() - WHERE id = $2 - ", + r#" + UPDATE leaf_aggregation_witness_jobs_fri + SET + status = 'failed', + error = $1, + updated_at = NOW() + WHERE + id = $2 + "#, error, id as i64 ) @@ -175,11 +219,15 @@ impl FriWitnessGeneratorDal<'_, '_> { pub async fn mark_leaf_aggregation_as_successful(&mut self, id: u32, time_taken: Duration) { sqlx::query!( - " - UPDATE leaf_aggregation_witness_jobs_fri - SET status = 'successful', updated_at = now(), time_taken = $1 - WHERE id = $2 - ", + r#" + UPDATE leaf_aggregation_witness_jobs_fri + SET + status = 'successful', + updated_at = NOW(), + time_taken = $1 + WHERE + id = $2 + "#, duration_to_naive_time(time_taken), id as i64 ) @@ -195,23 +243,45 @@ impl FriWitnessGeneratorDal<'_, '_> { ) -> Vec { let processing_timeout = pg_interval_from_duration(processing_timeout); sqlx::query!( - " - UPDATE witness_inputs_fri - SET status = 'queued', updated_at = now(), processing_started_at = now() - WHERE (status = 'in_progress' AND processing_started_at <= now() - $1::interval AND attempts < $2) - OR (status = 'in_gpu_proof' AND processing_started_at <= now() - $1::interval AND attempts < $2) - OR (status = 'failed' AND attempts < $2) - RETURNING l1_batch_number, status, attempts - ", - &processing_timeout, - max_attempts as i32, - ) - .fetch_all(self.storage.conn()) - .await - .unwrap() - .into_iter() - .map(|row| StuckJobs { id: row.l1_batch_number as u64, status: row.status, attempts: row.attempts as u64 }) - .collect() + r#" + UPDATE witness_inputs_fri + SET + status = 'queued', + updated_at = NOW(), + processing_started_at = NOW() + WHERE + ( + status = 'in_progress' + AND processing_started_at <= NOW() - $1::INTERVAL + AND attempts < $2 + ) + OR ( + status = 'in_gpu_proof' + AND processing_started_at <= NOW() - $1::INTERVAL + AND attempts < $2 + ) + OR ( + status = 'failed' + AND attempts < $2 + ) + RETURNING + l1_batch_number, + status, + attempts + "#, + &processing_timeout, + max_attempts as i32, + ) + .fetch_all(self.storage.conn()) + .await + .unwrap() + .into_iter() + .map(|row| StuckJobs { + id: row.l1_batch_number as u64, + status: row.status, + attempts: row.attempts as u64, + }) + .collect() } pub async fn create_aggregation_jobs( @@ -228,13 +298,25 @@ impl FriWitnessGeneratorDal<'_, '_> { closed_form_inputs_and_urls { sqlx::query!( - " - INSERT INTO leaf_aggregation_witness_jobs_fri - (l1_batch_number, circuit_id, closed_form_inputs_blob_url, number_of_basic_circuits, protocol_version, status, created_at, updated_at) - VALUES ($1, $2, $3, $4, $5, 'waiting_for_proofs', now(), now()) - ON CONFLICT(l1_batch_number, circuit_id) - DO UPDATE SET updated_at=now() - ", + r#" + INSERT INTO + leaf_aggregation_witness_jobs_fri ( + l1_batch_number, + circuit_id, + closed_form_inputs_blob_url, + number_of_basic_circuits, + protocol_version, + status, + created_at, + updated_at + ) + VALUES + ($1, $2, $3, $4, $5, 'waiting_for_proofs', NOW(), NOW()) + ON CONFLICT (l1_batch_number, circuit_id) DO + UPDATE + SET + updated_at = NOW() + "#, block_number.0 as i64, *circuit_id as i16, closed_form_inputs_url, @@ -257,13 +339,23 @@ impl FriWitnessGeneratorDal<'_, '_> { } sqlx::query!( - " - INSERT INTO scheduler_witness_jobs_fri - (l1_batch_number, scheduler_partial_input_blob_url, protocol_version, status, created_at, updated_at) - VALUES ($1, $2, $3, 'waiting_for_proofs', now(), now()) - ON CONFLICT(l1_batch_number) - DO UPDATE SET updated_at=now() - ", + r#" + INSERT INTO + scheduler_witness_jobs_fri ( + l1_batch_number, + scheduler_partial_input_blob_url, + protocol_version, + status, + created_at, + updated_at + ) + VALUES + ($1, $2, $3, 'waiting_for_proofs', NOW(), NOW()) + ON CONFLICT (l1_batch_number) DO + UPDATE + SET + updated_at = NOW() + "#, block_number.0 as i64, scheduler_partial_input_blob_url, protocol_version_id as i32, @@ -273,13 +365,16 @@ impl FriWitnessGeneratorDal<'_, '_> { .unwrap(); sqlx::query!( - " - INSERT INTO scheduler_dependency_tracker_fri - (l1_batch_number, status, created_at, updated_at) - VALUES ($1, 'waiting_for_proofs', now(), now()) - ON CONFLICT(l1_batch_number) - DO UPDATE SET updated_at=now() - ", + r#" + INSERT INTO + scheduler_dependency_tracker_fri (l1_batch_number, status, created_at, updated_at) + VALUES + ($1, 'waiting_for_proofs', NOW(), NOW()) + ON CONFLICT (l1_batch_number) DO + UPDATE + SET + updated_at = NOW() + "#, block_number.0 as i64, ) .execute(self.storage.conn()) @@ -297,23 +392,34 @@ impl FriWitnessGeneratorDal<'_, '_> { ) -> Option { let protocol_versions: Vec = protocol_versions.iter().map(|&id| id as i32).collect(); let row = sqlx::query!( - " - UPDATE leaf_aggregation_witness_jobs_fri - SET status = 'in_progress', attempts = attempts + 1, - updated_at = now(), processing_started_at = now(), - picked_by = $2 - WHERE id = ( - SELECT id - FROM leaf_aggregation_witness_jobs_fri - WHERE status = 'queued' - AND protocol_version = ANY($1) - ORDER BY l1_batch_number ASC, id ASC - LIMIT 1 + r#" + UPDATE leaf_aggregation_witness_jobs_fri + SET + status = 'in_progress', + attempts = attempts + 1, + updated_at = NOW(), + processing_started_at = NOW(), + picked_by = $2 + WHERE + id = ( + SELECT + id + FROM + leaf_aggregation_witness_jobs_fri + WHERE + status = 'queued' + AND protocol_version = ANY ($1) + ORDER BY + l1_batch_number ASC, + id ASC + LIMIT + 1 FOR UPDATE - SKIP LOCKED + SKIP LOCKED ) - RETURNING leaf_aggregation_witness_jobs_fri.* - ", + RETURNING + leaf_aggregation_witness_jobs_fri.* + "#, &protocol_versions[..], picked_by, ) @@ -343,8 +449,14 @@ impl FriWitnessGeneratorDal<'_, '_> { id: u32, ) -> sqlx::Result> { let attempts = sqlx::query!( - "SELECT attempts FROM leaf_aggregation_witness_jobs_fri \ - WHERE id = $1", + r#" + SELECT + attempts + FROM + leaf_aggregation_witness_jobs_fri + WHERE + id = $1 + "#, id as i64, ) .fetch_optional(self.storage.conn()) @@ -363,15 +475,20 @@ impl FriWitnessGeneratorDal<'_, '_> { depth: u16, ) -> Vec { sqlx::query!( - " - SELECT id from prover_jobs_fri - WHERE l1_batch_number = $1 - AND circuit_id = $2 - AND aggregation_round = $3 - AND depth = $4 - AND status = 'successful' - ORDER BY sequence_number ASC; - ", + r#" + SELECT + id + FROM + prover_jobs_fri + WHERE + l1_batch_number = $1 + AND circuit_id = $2 + AND aggregation_round = $3 + AND depth = $4 + AND status = 'successful' + ORDER BY + sequence_number ASC; + "#, block_number.0 as i64, circuit_id as i16, round as i16, @@ -389,20 +506,32 @@ impl FriWitnessGeneratorDal<'_, '_> { sqlx::query!( r#" UPDATE leaf_aggregation_witness_jobs_fri - SET status='queued' - WHERE (l1_batch_number, circuit_id) IN - (SELECT prover_jobs_fri.l1_batch_number, prover_jobs_fri.circuit_id - FROM prover_jobs_fri - JOIN leaf_aggregation_witness_jobs_fri lawj ON - prover_jobs_fri.l1_batch_number = lawj.l1_batch_number - AND prover_jobs_fri.circuit_id = lawj.circuit_id - WHERE lawj.status = 'waiting_for_proofs' - AND prover_jobs_fri.status = 'successful' - AND prover_jobs_fri.aggregation_round = 0 - GROUP BY prover_jobs_fri.l1_batch_number, prover_jobs_fri.circuit_id, lawj.number_of_basic_circuits - HAVING COUNT(*) = lawj.number_of_basic_circuits) - RETURNING l1_batch_number, circuit_id; - "#, + SET + status = 'queued' + WHERE + (l1_batch_number, circuit_id) IN ( + SELECT + prover_jobs_fri.l1_batch_number, + prover_jobs_fri.circuit_id + FROM + prover_jobs_fri + JOIN leaf_aggregation_witness_jobs_fri lawj ON prover_jobs_fri.l1_batch_number = lawj.l1_batch_number + AND prover_jobs_fri.circuit_id = lawj.circuit_id + WHERE + lawj.status = 'waiting_for_proofs' + AND prover_jobs_fri.status = 'successful' + AND prover_jobs_fri.aggregation_round = 0 + GROUP BY + prover_jobs_fri.l1_batch_number, + prover_jobs_fri.circuit_id, + lawj.number_of_basic_circuits + HAVING + COUNT(*) = lawj.number_of_basic_circuits + ) + RETURNING + l1_batch_number, + circuit_id; + "#, ) .fetch_all(self.storage.conn()) .await @@ -421,13 +550,17 @@ impl FriWitnessGeneratorDal<'_, '_> { url: String, ) { sqlx::query!( - " - UPDATE node_aggregation_witness_jobs_fri - SET aggregations_url = $1, number_of_dependent_jobs = $5, updated_at = now() - WHERE l1_batch_number = $2 + r#" + UPDATE node_aggregation_witness_jobs_fri + SET + aggregations_url = $1, + number_of_dependent_jobs = $5, + updated_at = NOW() + WHERE + l1_batch_number = $2 AND circuit_id = $3 AND depth = $4 - ", + "#, url, block_number.0 as i64, circuit_id as i16, @@ -446,23 +579,35 @@ impl FriWitnessGeneratorDal<'_, '_> { ) -> Option { let protocol_versions: Vec = protocol_versions.iter().map(|&id| id as i32).collect(); let row = sqlx::query!( - " - UPDATE node_aggregation_witness_jobs_fri - SET status = 'in_progress', attempts = attempts + 1, - updated_at = now(), processing_started_at = now(), - picked_by = $2 - WHERE id = ( - SELECT id - FROM node_aggregation_witness_jobs_fri - WHERE status = 'queued' - AND protocol_version = ANY($1) - ORDER BY l1_batch_number ASC, depth ASC, id ASC - LIMIT 1 + r#" + UPDATE node_aggregation_witness_jobs_fri + SET + status = 'in_progress', + attempts = attempts + 1, + updated_at = NOW(), + processing_started_at = NOW(), + picked_by = $2 + WHERE + id = ( + SELECT + id + FROM + node_aggregation_witness_jobs_fri + WHERE + status = 'queued' + AND protocol_version = ANY ($1) + ORDER BY + l1_batch_number ASC, + depth ASC, + id ASC + LIMIT + 1 FOR UPDATE - SKIP LOCKED + SKIP LOCKED ) - RETURNING node_aggregation_witness_jobs_fri.* - ", + RETURNING + node_aggregation_witness_jobs_fri.* + "#, &protocol_versions[..], picked_by, ) @@ -496,8 +641,14 @@ impl FriWitnessGeneratorDal<'_, '_> { id: u32, ) -> sqlx::Result> { let attempts = sqlx::query!( - "SELECT attempts FROM node_aggregation_witness_jobs_fri \ - WHERE id = $1", + r#" + SELECT + attempts + FROM + node_aggregation_witness_jobs_fri + WHERE + id = $1 + "#, id as i64, ) .fetch_optional(self.storage.conn()) @@ -510,11 +661,15 @@ impl FriWitnessGeneratorDal<'_, '_> { pub async fn mark_node_aggregation_job_failed(&mut self, error: &str, id: u32) { sqlx::query!( - " - UPDATE node_aggregation_witness_jobs_fri - SET status ='failed', error= $1, updated_at = now() - WHERE id = $2 - ", + r#" + UPDATE node_aggregation_witness_jobs_fri + SET + status = 'failed', + error = $1, + updated_at = NOW() + WHERE + id = $2 + "#, error, id as i64 ) @@ -525,11 +680,15 @@ impl FriWitnessGeneratorDal<'_, '_> { pub async fn mark_node_aggregation_as_successful(&mut self, id: u32, time_taken: Duration) { sqlx::query!( - " - UPDATE node_aggregation_witness_jobs_fri - SET status = 'successful', updated_at = now(), time_taken = $1 - WHERE id = $2 - ", + r#" + UPDATE node_aggregation_witness_jobs_fri + SET + status = 'successful', + updated_at = NOW(), + time_taken = $1 + WHERE + id = $2 + "#, duration_to_naive_time(time_taken), id as i64 ) @@ -548,42 +707,73 @@ impl FriWitnessGeneratorDal<'_, '_> { protocol_version_id: FriProtocolVersionId, ) { sqlx::query!( - "INSERT INTO node_aggregation_witness_jobs_fri (l1_batch_number, circuit_id, depth, aggregations_url, number_of_dependent_jobs, protocol_version, status, created_at, updated_at) - VALUES ($1, $2, $3, $4, $5, $6, 'waiting_for_proofs', now(), now()) - ON CONFLICT(l1_batch_number, circuit_id, depth) - DO UPDATE SET updated_at=now()", - block_number.0 as i64, - circuit_id as i16, - depth as i32, - aggregations_url, - number_of_dependent_jobs, - protocol_version_id as i32, - ) - .fetch_optional(self.storage.conn()) - .await - .unwrap(); + r#" + INSERT INTO + node_aggregation_witness_jobs_fri ( + l1_batch_number, + circuit_id, + depth, + aggregations_url, + number_of_dependent_jobs, + protocol_version, + status, + created_at, + updated_at + ) + VALUES + ($1, $2, $3, $4, $5, $6, 'waiting_for_proofs', NOW(), NOW()) + ON CONFLICT (l1_batch_number, circuit_id, depth) DO + UPDATE + SET + updated_at = NOW() + "#, + block_number.0 as i64, + circuit_id as i16, + depth as i32, + aggregations_url, + number_of_dependent_jobs, + protocol_version_id as i32, + ) + .fetch_optional(self.storage.conn()) + .await + .unwrap(); } pub async fn move_depth_zero_node_aggregation_jobs(&mut self) -> Vec<(i64, u8, u16)> { sqlx::query!( r#" UPDATE node_aggregation_witness_jobs_fri - SET status='queued' - WHERE (l1_batch_number, circuit_id, depth) IN - (SELECT prover_jobs_fri.l1_batch_number, prover_jobs_fri.circuit_id, prover_jobs_fri.depth - FROM prover_jobs_fri - JOIN node_aggregation_witness_jobs_fri nawj ON - prover_jobs_fri.l1_batch_number = nawj.l1_batch_number - AND prover_jobs_fri.circuit_id = nawj.circuit_id - AND prover_jobs_fri.depth = nawj.depth - WHERE nawj.status = 'waiting_for_proofs' - AND prover_jobs_fri.status = 'successful' - AND prover_jobs_fri.aggregation_round = 1 - AND prover_jobs_fri.depth = 0 - GROUP BY prover_jobs_fri.l1_batch_number, prover_jobs_fri.circuit_id, prover_jobs_fri.depth, nawj.number_of_dependent_jobs - HAVING COUNT(*) = nawj.number_of_dependent_jobs) - RETURNING l1_batch_number, circuit_id, depth; - "#, + SET + status = 'queued' + WHERE + (l1_batch_number, circuit_id, depth) IN ( + SELECT + prover_jobs_fri.l1_batch_number, + prover_jobs_fri.circuit_id, + prover_jobs_fri.depth + FROM + prover_jobs_fri + JOIN node_aggregation_witness_jobs_fri nawj ON prover_jobs_fri.l1_batch_number = nawj.l1_batch_number + AND prover_jobs_fri.circuit_id = nawj.circuit_id + AND prover_jobs_fri.depth = nawj.depth + WHERE + nawj.status = 'waiting_for_proofs' + AND prover_jobs_fri.status = 'successful' + AND prover_jobs_fri.aggregation_round = 1 + AND prover_jobs_fri.depth = 0 + GROUP BY + prover_jobs_fri.l1_batch_number, + prover_jobs_fri.circuit_id, + prover_jobs_fri.depth, + nawj.number_of_dependent_jobs + HAVING + COUNT(*) = nawj.number_of_dependent_jobs + ) + RETURNING + l1_batch_number, + circuit_id, + depth; + "#, ) .fetch_all(self.storage.conn()) .await @@ -597,21 +787,36 @@ impl FriWitnessGeneratorDal<'_, '_> { sqlx::query!( r#" UPDATE node_aggregation_witness_jobs_fri - SET status='queued' - WHERE (l1_batch_number, circuit_id, depth) IN - (SELECT prover_jobs_fri.l1_batch_number, prover_jobs_fri.circuit_id, prover_jobs_fri.depth - FROM prover_jobs_fri - JOIN node_aggregation_witness_jobs_fri nawj ON - prover_jobs_fri.l1_batch_number = nawj.l1_batch_number - AND prover_jobs_fri.circuit_id = nawj.circuit_id - AND prover_jobs_fri.depth = nawj.depth - WHERE nawj.status = 'waiting_for_proofs' - AND prover_jobs_fri.status = 'successful' - AND prover_jobs_fri.aggregation_round = 2 - GROUP BY prover_jobs_fri.l1_batch_number, prover_jobs_fri.circuit_id, prover_jobs_fri.depth, nawj.number_of_dependent_jobs - HAVING COUNT(*) = nawj.number_of_dependent_jobs) - RETURNING l1_batch_number, circuit_id, depth; - "#, + SET + status = 'queued' + WHERE + (l1_batch_number, circuit_id, depth) IN ( + SELECT + prover_jobs_fri.l1_batch_number, + prover_jobs_fri.circuit_id, + prover_jobs_fri.depth + FROM + prover_jobs_fri + JOIN node_aggregation_witness_jobs_fri nawj ON prover_jobs_fri.l1_batch_number = nawj.l1_batch_number + AND prover_jobs_fri.circuit_id = nawj.circuit_id + AND prover_jobs_fri.depth = nawj.depth + WHERE + nawj.status = 'waiting_for_proofs' + AND prover_jobs_fri.status = 'successful' + AND prover_jobs_fri.aggregation_round = 2 + GROUP BY + prover_jobs_fri.l1_batch_number, + prover_jobs_fri.circuit_id, + prover_jobs_fri.depth, + nawj.number_of_dependent_jobs + HAVING + COUNT(*) = nawj.number_of_dependent_jobs + ) + RETURNING + l1_batch_number, + circuit_id, + depth; + "#, ) .fetch_all(self.storage.conn()) .await @@ -628,21 +833,39 @@ impl FriWitnessGeneratorDal<'_, '_> { ) -> Vec { let processing_timeout = pg_interval_from_duration(processing_timeout); sqlx::query!( - " - UPDATE leaf_aggregation_witness_jobs_fri - SET status = 'queued', updated_at = now(), processing_started_at = now() - WHERE (status = 'in_progress' AND processing_started_at <= now() - $1::interval AND attempts < $2) - OR (status = 'failed' AND attempts < $2) - RETURNING id, status, attempts - ", - &processing_timeout, - max_attempts as i32, + r#" + UPDATE leaf_aggregation_witness_jobs_fri + SET + status = 'queued', + updated_at = NOW(), + processing_started_at = NOW() + WHERE + ( + status = 'in_progress' + AND processing_started_at <= NOW() - $1::INTERVAL + AND attempts < $2 + ) + OR ( + status = 'failed' + AND attempts < $2 + ) + RETURNING + id, + status, + attempts + "#, + &processing_timeout, + max_attempts as i32, ) .fetch_all(self.storage.conn()) .await .unwrap() .into_iter() - .map(|row| StuckJobs { id: row.id as u64, status: row.status, attempts: row.attempts as u64 }) + .map(|row| StuckJobs { + id: row.id as u64, + status: row.status, + attempts: row.attempts as u64, + }) .collect() } @@ -653,30 +876,50 @@ impl FriWitnessGeneratorDal<'_, '_> { ) -> Vec { let processing_timeout = pg_interval_from_duration(processing_timeout); sqlx::query!( - " - UPDATE node_aggregation_witness_jobs_fri - SET status = 'queued', updated_at = now(), processing_started_at = now() - WHERE (status = 'in_progress' AND processing_started_at <= now() - $1::interval AND attempts < $2) - OR (status = 'failed' AND attempts < $2) - RETURNING id, status, attempts - ", - &processing_timeout, - max_attempts as i32, + r#" + UPDATE node_aggregation_witness_jobs_fri + SET + status = 'queued', + updated_at = NOW(), + processing_started_at = NOW() + WHERE + ( + status = 'in_progress' + AND processing_started_at <= NOW() - $1::INTERVAL + AND attempts < $2 + ) + OR ( + status = 'failed' + AND attempts < $2 + ) + RETURNING + id, + status, + attempts + "#, + &processing_timeout, + max_attempts as i32, ) .fetch_all(self.storage.conn()) .await .unwrap() .into_iter() - .map(|row| StuckJobs { id: row.id as u64, status: row.status, attempts: row.attempts as u64 }) + .map(|row| StuckJobs { + id: row.id as u64, + status: row.status, + attempts: row.attempts as u64, + }) .collect() } pub async fn mark_scheduler_jobs_as_queued(&mut self, l1_batch_number: i64) { sqlx::query!( r#" - UPDATE scheduler_witness_jobs_fri - SET status='queued' - WHERE l1_batch_number = $1 + UPDATE scheduler_witness_jobs_fri + SET + status = 'queued' + WHERE + l1_batch_number = $1 AND status != 'successful' AND status != 'in_progress' "#, @@ -694,21 +937,39 @@ impl FriWitnessGeneratorDal<'_, '_> { ) -> Vec { let processing_timeout = pg_interval_from_duration(processing_timeout); sqlx::query!( - " - UPDATE scheduler_witness_jobs_fri - SET status = 'queued', updated_at = now(), processing_started_at = now() - WHERE (status = 'in_progress' AND processing_started_at <= now() - $1::interval AND attempts < $2) - OR (status = 'failed' AND attempts < $2) - RETURNING l1_batch_number, status, attempts - ", - &processing_timeout, - max_attempts as i32, + r#" + UPDATE scheduler_witness_jobs_fri + SET + status = 'queued', + updated_at = NOW(), + processing_started_at = NOW() + WHERE + ( + status = 'in_progress' + AND processing_started_at <= NOW() - $1::INTERVAL + AND attempts < $2 + ) + OR ( + status = 'failed' + AND attempts < $2 + ) + RETURNING + l1_batch_number, + status, + attempts + "#, + &processing_timeout, + max_attempts as i32, ) .fetch_all(self.storage.conn()) .await .unwrap() .into_iter() - .map(|row| StuckJobs { id: row.l1_batch_number as u64, status: row.status, attempts: row.attempts as u64 }) + .map(|row| StuckJobs { + id: row.l1_batch_number as u64, + status: row.status, + attempts: row.attempts as u64, + }) .collect() } @@ -719,23 +980,33 @@ impl FriWitnessGeneratorDal<'_, '_> { ) -> Option { let protocol_versions: Vec = protocol_versions.iter().map(|&id| id as i32).collect(); sqlx::query!( - " - UPDATE scheduler_witness_jobs_fri - SET status = 'in_progress', attempts = attempts + 1, - updated_at = now(), processing_started_at = now(), - picked_by = $2 - WHERE l1_batch_number = ( - SELECT l1_batch_number - FROM scheduler_witness_jobs_fri - WHERE status = 'queued' - AND protocol_version = ANY($1) - ORDER BY l1_batch_number ASC - LIMIT 1 + r#" + UPDATE scheduler_witness_jobs_fri + SET + status = 'in_progress', + attempts = attempts + 1, + updated_at = NOW(), + processing_started_at = NOW(), + picked_by = $2 + WHERE + l1_batch_number = ( + SELECT + l1_batch_number + FROM + scheduler_witness_jobs_fri + WHERE + status = 'queued' + AND protocol_version = ANY ($1) + ORDER BY + l1_batch_number ASC + LIMIT + 1 FOR UPDATE - SKIP LOCKED + SKIP LOCKED ) - RETURNING scheduler_witness_jobs_fri.* - ", + RETURNING + scheduler_witness_jobs_fri.* + "#, &protocol_versions[..], picked_by, ) @@ -750,8 +1021,14 @@ impl FriWitnessGeneratorDal<'_, '_> { l1_batch_number: L1BatchNumber, ) -> sqlx::Result> { let attempts = sqlx::query!( - "SELECT attempts FROM scheduler_witness_jobs_fri \ - WHERE l1_batch_number = $1", + r#" + SELECT + attempts + FROM + scheduler_witness_jobs_fri + WHERE + l1_batch_number = $1 + "#, l1_batch_number.0 as i64, ) .fetch_optional(self.storage.conn()) @@ -767,11 +1044,15 @@ impl FriWitnessGeneratorDal<'_, '_> { time_taken: Duration, ) { sqlx::query!( - " - UPDATE scheduler_witness_jobs_fri - SET status = 'successful', updated_at = now(), time_taken = $1 - WHERE l1_batch_number = $2 - ", + r#" + UPDATE scheduler_witness_jobs_fri + SET + status = 'successful', + updated_at = NOW(), + time_taken = $1 + WHERE + l1_batch_number = $2 + "#, duration_to_naive_time(time_taken), block_number.0 as i64 ) @@ -782,11 +1063,15 @@ impl FriWitnessGeneratorDal<'_, '_> { pub async fn mark_scheduler_job_failed(&mut self, error: &str, block_number: L1BatchNumber) { sqlx::query!( - " - UPDATE scheduler_witness_jobs_fri - SET status ='failed', error= $1, updated_at = now() - WHERE l1_batch_number = $2 - ", + r#" + UPDATE scheduler_witness_jobs_fri + SET + status = 'failed', + error = $1, + updated_at = NOW() + WHERE + l1_batch_number = $2 + "#, error, block_number.0 as i64 ) @@ -838,9 +1123,14 @@ impl FriWitnessGeneratorDal<'_, '_> { l1_batch_number: L1BatchNumber, ) -> FriProtocolVersionId { sqlx::query!( - "SELECT protocol_version \ - FROM witness_inputs_fri \ - WHERE l1_batch_number = $1", + r#" + SELECT + protocol_version + FROM + witness_inputs_fri + WHERE + l1_batch_number = $1 + "#, l1_batch_number.0 as i64, ) .fetch_one(self.storage.conn()) diff --git a/core/lib/dal/src/gpu_prover_queue_dal.rs b/core/lib/dal/src/gpu_prover_queue_dal.rs index b4c348ab3e77..b424edd57456 100644 --- a/core/lib/dal/src/gpu_prover_queue_dal.rs +++ b/core/lib/dal/src/gpu_prover_queue_dal.rs @@ -20,40 +20,51 @@ impl GpuProverQueueDal<'_, '_> { { let processing_timeout = pg_interval_from_duration(processing_timeout); let result: Option = sqlx::query!( - " + r#" UPDATE gpu_prover_queue - SET instance_status = 'reserved', - updated_at = now(), - processing_started_at = now() - WHERE id in ( - SELECT id - FROM gpu_prover_queue - WHERE specialized_prover_group_id=$2 - AND region=$3 - AND zone=$4 - AND ( - instance_status = 'available' - OR (instance_status = 'reserved' AND processing_started_at < now() - $1::interval) + SET + instance_status = 'reserved', + updated_at = NOW(), + processing_started_at = NOW() + WHERE + id IN ( + SELECT + id + FROM + gpu_prover_queue + WHERE + specialized_prover_group_id = $2 + AND region = $3 + AND zone = $4 + AND ( + instance_status = 'available' + OR ( + instance_status = 'reserved' + AND processing_started_at < NOW() - $1::INTERVAL + ) + ) + ORDER BY + updated_at ASC + LIMIT + 1 + FOR UPDATE + SKIP LOCKED ) - ORDER BY updated_at ASC - LIMIT 1 - FOR UPDATE - SKIP LOCKED - ) - RETURNING gpu_prover_queue.* - ", + RETURNING + gpu_prover_queue.* + "#, &processing_timeout, specialized_prover_group_id as i16, region, zone ) - .fetch_optional(self.storage.conn()) - .await - .unwrap() - .map(|row| SocketAddress { - host: row.instance_host.network(), - port: row.instance_port as u16, - }); + .fetch_optional(self.storage.conn()) + .await + .unwrap() + .map(|row| SocketAddress { + host: row.instance_host.network(), + port: row.instance_port as u16, + }); result } @@ -70,11 +81,35 @@ impl GpuProverQueueDal<'_, '_> { ) { { sqlx::query!( - " - INSERT INTO gpu_prover_queue (instance_host, instance_port, queue_capacity, queue_free_slots, instance_status, specialized_prover_group_id, region, zone, num_gpu, created_at, updated_at) - VALUES (cast($1::text as inet), $2, $3, $3, 'available', $4, $5, $6, $7, now(), now()) - ON CONFLICT(instance_host, instance_port, region, zone) - DO UPDATE SET instance_status='available', queue_capacity=$3, queue_free_slots=$3, specialized_prover_group_id=$4, region=$5, zone=$6, num_gpu=$7, updated_at=now()", + r#" + INSERT INTO + gpu_prover_queue ( + instance_host, + instance_port, + queue_capacity, + queue_free_slots, + instance_status, + specialized_prover_group_id, + region, + zone, + num_gpu, + created_at, + updated_at + ) + VALUES + (CAST($1::TEXT AS inet), $2, $3, $3, 'available', $4, $5, $6, $7, NOW(), NOW()) + ON CONFLICT (instance_host, instance_port, region, zone) DO + UPDATE + SET + instance_status = 'available', + queue_capacity = $3, + queue_free_slots = $3, + specialized_prover_group_id = $4, + region = $5, + zone = $6, + num_gpu = $7, + updated_at = NOW() + "#, format!("{}",address.host), address.port as i32, queue_capacity as i32, @@ -98,14 +133,18 @@ impl GpuProverQueueDal<'_, '_> { ) { { sqlx::query!( - " + r#" UPDATE gpu_prover_queue - SET instance_status = $1, updated_at = now(), queue_free_slots = $4 - WHERE instance_host = $2::text::inet - AND instance_port = $3 - AND region = $5 - AND zone = $6 - ", + SET + instance_status = $1, + updated_at = NOW(), + queue_free_slots = $4 + WHERE + instance_host = $2::TEXT::inet + AND instance_port = $3 + AND region = $5 + AND zone = $6 + "#, format!("{:?}", status).to_lowercase(), format!("{}", address.host), address.port as i32, @@ -128,15 +167,19 @@ impl GpuProverQueueDal<'_, '_> { ) { { sqlx::query!( - " + r#" UPDATE gpu_prover_queue - SET instance_status = 'available', updated_at = now(), queue_free_slots = $3 - WHERE instance_host = $1::text::inet - AND instance_port = $2 - AND instance_status = 'full' - AND region = $4 - AND zone = $5 - ", + SET + instance_status = 'available', + updated_at = NOW(), + queue_free_slots = $3 + WHERE + instance_host = $1::TEXT::inet + AND instance_port = $2 + AND instance_status = 'full' + AND region = $4 + AND zone = $5 + "#, format!("{}", address.host), address.port as i32, queue_free_slots as i32, @@ -153,10 +196,16 @@ impl GpuProverQueueDal<'_, '_> { { sqlx::query!( r#" - SELECT region, zone, SUM(num_gpu) AS total_gpus - FROM gpu_prover_queue - GROUP BY region, zone - "#, + SELECT + region, + zone, + SUM(num_gpu) AS total_gpus + FROM + gpu_prover_queue + GROUP BY + region, + zone + "#, ) .fetch_all(self.storage.conn()) .await diff --git a/core/lib/dal/src/proof_generation_dal.rs b/core/lib/dal/src/proof_generation_dal.rs index f381d313bd90..cdcfd70880b1 100644 --- a/core/lib/dal/src/proof_generation_dal.rs +++ b/core/lib/dal/src/proof_generation_dal.rs @@ -29,19 +29,34 @@ impl ProofGenerationDal<'_, '_> { ) -> Option { let processing_timeout = pg_interval_from_duration(processing_timeout); let result: Option = sqlx::query!( - "UPDATE proof_generation_details \ - SET status = 'picked_by_prover', updated_at = now(), prover_taken_at = now() \ - WHERE l1_batch_number = ( \ - SELECT l1_batch_number \ - FROM proof_generation_details \ - WHERE status = 'ready_to_be_proven' \ - OR (status = 'picked_by_prover' AND prover_taken_at < now() - $1::interval) \ - ORDER BY l1_batch_number ASC \ - LIMIT 1 \ - FOR UPDATE \ - SKIP LOCKED \ - ) \ - RETURNING proof_generation_details.l1_batch_number", + r#" + UPDATE proof_generation_details + SET + status = 'picked_by_prover', + updated_at = NOW(), + prover_taken_at = NOW() + WHERE + l1_batch_number = ( + SELECT + l1_batch_number + FROM + proof_generation_details + WHERE + status = 'ready_to_be_proven' + OR ( + status = 'picked_by_prover' + AND prover_taken_at < NOW() - $1::INTERVAL + ) + ORDER BY + l1_batch_number ASC + LIMIT + 1 + FOR UPDATE + SKIP LOCKED + ) + RETURNING + proof_generation_details.l1_batch_number + "#, &processing_timeout, ) .fetch_optional(self.storage.conn()) @@ -58,9 +73,15 @@ impl ProofGenerationDal<'_, '_> { proof_blob_url: &str, ) -> Result<(), SqlxError> { sqlx::query!( - "UPDATE proof_generation_details \ - SET status='generated', proof_blob_url = $1, updated_at = now() \ - WHERE l1_batch_number = $2", + r#" + UPDATE proof_generation_details + SET + status = 'generated', + proof_blob_url = $1, + updated_at = NOW() + WHERE + l1_batch_number = $2 + "#, proof_blob_url, block_number.0 as i64, ) @@ -78,10 +99,13 @@ impl ProofGenerationDal<'_, '_> { proof_gen_data_blob_url: &str, ) { sqlx::query!( - "INSERT INTO proof_generation_details \ - (l1_batch_number, status, proof_gen_data_blob_url, created_at, updated_at) \ - VALUES ($1, 'ready_to_be_proven', $2, now(), now()) \ - ON CONFLICT (l1_batch_number) DO NOTHING", + r#" + INSERT INTO + proof_generation_details (l1_batch_number, status, proof_gen_data_blob_url, created_at, updated_at) + VALUES + ($1, 'ready_to_be_proven', $2, NOW(), NOW()) + ON CONFLICT (l1_batch_number) DO NOTHING + "#, block_number.0 as i64, proof_gen_data_blob_url, ) @@ -95,9 +119,14 @@ impl ProofGenerationDal<'_, '_> { block_number: L1BatchNumber, ) -> Result<(), SqlxError> { sqlx::query!( - "UPDATE proof_generation_details \ - SET status=$1, updated_at = now() \ - WHERE l1_batch_number = $2", + r#" + UPDATE proof_generation_details + SET + status = $1, + updated_at = NOW() + WHERE + l1_batch_number = $2 + "#, ProofGenerationJobStatus::Skipped.to_string(), block_number.0 as i64, ) @@ -111,11 +140,18 @@ impl ProofGenerationDal<'_, '_> { pub async fn get_oldest_unpicked_batch(&mut self) -> Option { let result: Option = sqlx::query!( - "SELECT l1_batch_number \ - FROM proof_generation_details \ - WHERE status = 'ready_to_be_proven' \ - ORDER BY l1_batch_number ASC \ - LIMIT 1", + r#" + SELECT + l1_batch_number + FROM + proof_generation_details + WHERE + status = 'ready_to_be_proven' + ORDER BY + l1_batch_number ASC + LIMIT + 1 + "#, ) .fetch_optional(self.storage.conn()) .await @@ -127,11 +163,18 @@ impl ProofGenerationDal<'_, '_> { pub async fn get_oldest_not_generated_batch(&mut self) -> Option { let result: Option = sqlx::query!( - "SELECT l1_batch_number \ - FROM proof_generation_details \ - WHERE status NOT IN ('generated', 'skipped') \ - ORDER BY l1_batch_number ASC \ - LIMIT 1", + r#" + SELECT + l1_batch_number + FROM + proof_generation_details + WHERE + status NOT IN ('generated', 'skipped') + ORDER BY + l1_batch_number ASC + LIMIT + 1 + "#, ) .fetch_optional(self.storage.conn()) .await diff --git a/core/lib/dal/src/protocol_versions_dal.rs b/core/lib/dal/src/protocol_versions_dal.rs index c7b75b3d87a9..0f4818864dfe 100644 --- a/core/lib/dal/src/protocol_versions_dal.rs +++ b/core/lib/dal/src/protocol_versions_dal.rs @@ -27,25 +27,49 @@ impl ProtocolVersionsDal<'_, '_> { tx_hash: Option, ) { sqlx::query!( - "INSERT INTO protocol_versions \ - (id, timestamp, recursion_scheduler_level_vk_hash, recursion_node_level_vk_hash, \ - recursion_leaf_level_vk_hash, recursion_circuits_set_vks_hash, bootloader_code_hash, \ - default_account_code_hash, verifier_address, upgrade_tx_hash, created_at) \ - VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, now())", - id as i32, - timestamp as i64, - l1_verifier_config.recursion_scheduler_level_vk_hash.as_bytes(), - l1_verifier_config.params.recursion_node_level_vk_hash.as_bytes(), - l1_verifier_config.params.recursion_leaf_level_vk_hash.as_bytes(), - l1_verifier_config.params.recursion_circuits_set_vks_hash.as_bytes(), - base_system_contracts_hashes.bootloader.as_bytes(), - base_system_contracts_hashes.default_aa.as_bytes(), - verifier_address.as_bytes(), - tx_hash.map(|tx_hash| tx_hash.0.to_vec()), - ) - .execute(self.storage.conn()) - .await - .unwrap(); + r#" + INSERT INTO + protocol_versions ( + id, + timestamp, + recursion_scheduler_level_vk_hash, + recursion_node_level_vk_hash, + recursion_leaf_level_vk_hash, + recursion_circuits_set_vks_hash, + bootloader_code_hash, + default_account_code_hash, + verifier_address, + upgrade_tx_hash, + created_at + ) + VALUES + ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, NOW()) + "#, + id as i32, + timestamp as i64, + l1_verifier_config + .recursion_scheduler_level_vk_hash + .as_bytes(), + l1_verifier_config + .params + .recursion_node_level_vk_hash + .as_bytes(), + l1_verifier_config + .params + .recursion_leaf_level_vk_hash + .as_bytes(), + l1_verifier_config + .params + .recursion_circuits_set_vks_hash + .as_bytes(), + base_system_contracts_hashes.bootloader.as_bytes(), + base_system_contracts_hashes.default_aa.as_bytes(), + verifier_address.as_bytes(), + tx_hash.map(|tx_hash| tx_hash.0.to_vec()), + ) + .execute(self.storage.conn()) + .await + .unwrap(); } pub async fn save_protocol_version_with_tx(&mut self, version: ProtocolVersion) { @@ -76,22 +100,47 @@ impl ProtocolVersionsDal<'_, '_> { pub async fn save_prover_protocol_version(&mut self, version: ProtocolVersion) { sqlx::query!( - "INSERT INTO prover_protocol_versions - (id, timestamp, recursion_scheduler_level_vk_hash, recursion_node_level_vk_hash, - recursion_leaf_level_vk_hash, recursion_circuits_set_vks_hash, verifier_address, created_at) - VALUES ($1, $2, $3, $4, $5, $6, $7, now()) - ", - version.id as i32, - version.timestamp as i64, - version.l1_verifier_config.recursion_scheduler_level_vk_hash.as_bytes(), - version.l1_verifier_config.params.recursion_node_level_vk_hash.as_bytes(), - version.l1_verifier_config.params.recursion_leaf_level_vk_hash.as_bytes(), - version.l1_verifier_config.params.recursion_circuits_set_vks_hash.as_bytes(), - version.verifier_address.as_bytes(), - ) - .execute(self.storage.conn()) - .await - .unwrap(); + r#" + INSERT INTO + prover_protocol_versions ( + id, + timestamp, + recursion_scheduler_level_vk_hash, + recursion_node_level_vk_hash, + recursion_leaf_level_vk_hash, + recursion_circuits_set_vks_hash, + verifier_address, + created_at + ) + VALUES + ($1, $2, $3, $4, $5, $6, $7, NOW()) + "#, + version.id as i32, + version.timestamp as i64, + version + .l1_verifier_config + .recursion_scheduler_level_vk_hash + .as_bytes(), + version + .l1_verifier_config + .params + .recursion_node_level_vk_hash + .as_bytes(), + version + .l1_verifier_config + .params + .recursion_leaf_level_vk_hash + .as_bytes(), + version + .l1_verifier_config + .params + .recursion_circuits_set_vks_hash + .as_bytes(), + version.verifier_address.as_bytes(), + ) + .execute(self.storage.conn()) + .await + .unwrap(); } pub async fn base_system_contracts_by_timestamp( @@ -99,11 +148,20 @@ impl ProtocolVersionsDal<'_, '_> { current_timestamp: u64, ) -> (BaseSystemContracts, ProtocolVersionId) { let row = sqlx::query!( - "SELECT bootloader_code_hash, default_account_code_hash, id FROM protocol_versions - WHERE timestamp <= $1 - ORDER BY id DESC - LIMIT 1 - ", + r#" + SELECT + bootloader_code_hash, + default_account_code_hash, + id + FROM + protocol_versions + WHERE + timestamp <= $1 + ORDER BY + id DESC + LIMIT + 1 + "#, current_timestamp as i64 ) .fetch_one(self.storage.conn()) @@ -125,9 +183,15 @@ impl ProtocolVersionsDal<'_, '_> { version_id: u16, ) -> Option { let row = sqlx::query!( - "SELECT bootloader_code_hash, default_account_code_hash FROM protocol_versions - WHERE id = $1 - ", + r#" + SELECT + bootloader_code_hash, + default_account_code_hash + FROM + protocol_versions + WHERE + id = $1 + "#, version_id as i32 ) .fetch_optional(self.storage.conn()) @@ -154,11 +218,18 @@ impl ProtocolVersionsDal<'_, '_> { ) -> Option { let storage_protocol_version: StorageProtocolVersion = sqlx::query_as!( StorageProtocolVersion, - "SELECT * FROM protocol_versions - WHERE id < $1 - ORDER BY id DESC - LIMIT 1 - ", + r#" + SELECT + * + FROM + protocol_versions + WHERE + id < $1 + ORDER BY + id DESC + LIMIT + 1 + "#, version_id as i32 ) .fetch_optional(self.storage.conn()) @@ -177,7 +248,14 @@ impl ProtocolVersionsDal<'_, '_> { ) -> Option { let storage_protocol_version: StorageProtocolVersion = sqlx::query_as!( StorageProtocolVersion, - "SELECT * FROM protocol_versions WHERE id = $1", + r#" + SELECT + * + FROM + protocol_versions + WHERE + id = $1 + "#, version_id as i32 ) .fetch_optional(self.storage.conn()) @@ -193,15 +271,22 @@ impl ProtocolVersionsDal<'_, '_> { version_id: ProtocolVersionId, ) -> Option { let row = sqlx::query!( - "SELECT recursion_scheduler_level_vk_hash, recursion_node_level_vk_hash, recursion_leaf_level_vk_hash, recursion_circuits_set_vks_hash - FROM protocol_versions - WHERE id = $1 - ", + r#" + SELECT + recursion_scheduler_level_vk_hash, + recursion_node_level_vk_hash, + recursion_leaf_level_vk_hash, + recursion_circuits_set_vks_hash + FROM + protocol_versions + WHERE + id = $1 + "#, version_id as i32 ) - .fetch_optional(self.storage.conn()) - .await - .unwrap()?; + .fetch_optional(self.storage.conn()) + .await + .unwrap()?; Some(L1VerifierConfig { params: VerifierParams { recursion_node_level_vk_hash: H256::from_slice(&row.recursion_node_level_vk_hash), @@ -217,30 +302,54 @@ impl ProtocolVersionsDal<'_, '_> { } pub async fn last_version_id(&mut self) -> Option { - let id = sqlx::query!(r#"SELECT MAX(id) as "max?" FROM protocol_versions"#) - .fetch_optional(self.storage.conn()) - .await - .unwrap()? - .max?; + let id = sqlx::query!( + r#" + SELECT + MAX(id) AS "max?" + FROM + protocol_versions + "# + ) + .fetch_optional(self.storage.conn()) + .await + .unwrap()? + .max?; Some((id as u16).try_into().unwrap()) } pub async fn last_used_version_id(&mut self) -> Option { - let id = - sqlx::query!(r#"SELECT protocol_version FROM l1_batches ORDER BY number DESC LIMIT 1"#) - .fetch_optional(self.storage.conn()) - .await - .unwrap()? - .protocol_version?; + let id = sqlx::query!( + r#" + SELECT + protocol_version + FROM + l1_batches + ORDER BY + number DESC + LIMIT + 1 + "# + ) + .fetch_optional(self.storage.conn()) + .await + .unwrap()? + .protocol_version?; Some((id as u16).try_into().unwrap()) } pub async fn all_version_ids(&mut self) -> Vec { - let rows = sqlx::query!("SELECT id FROM protocol_versions") - .fetch_all(self.storage.conn()) - .await - .unwrap(); + let rows = sqlx::query!( + r#" + SELECT + id + FROM + protocol_versions + "# + ) + .fetch_all(self.storage.conn()) + .await + .unwrap(); rows.into_iter() .map(|row| (row.id as u16).try_into().unwrap()) .collect() @@ -251,10 +360,14 @@ impl ProtocolVersionsDal<'_, '_> { protocol_version_id: ProtocolVersionId, ) -> Option { let row = sqlx::query!( - " - SELECT upgrade_tx_hash FROM protocol_versions - WHERE id = $1 - ", + r#" + SELECT + upgrade_tx_hash + FROM + protocol_versions + WHERE + id = $1 + "#, protocol_version_id as i32 ) .fetch_optional(self.storage.conn()) @@ -286,13 +399,16 @@ impl ProtocolVersionsDal<'_, '_> { ) -> Vec { sqlx::query!( r#" - SELECT id - FROM prover_protocol_versions - WHERE recursion_circuits_set_vks_hash = $1 + SELECT + id + FROM + prover_protocol_versions + WHERE + recursion_circuits_set_vks_hash = $1 AND recursion_leaf_level_vk_hash = $2 AND recursion_node_level_vk_hash = $3 AND recursion_scheduler_level_vk_hash = $4 - "#, + "#, vk_commitments .params .recursion_circuits_set_vks_hash @@ -317,8 +433,14 @@ impl ProtocolVersionsDal<'_, '_> { pub async fn prover_protocol_version_exists(&mut self, id: ProtocolVersionId) -> bool { sqlx::query!( - "SELECT COUNT(*) as \"count!\" FROM prover_protocol_versions \ - WHERE id = $1", + r#" + SELECT + COUNT(*) AS "count!" + FROM + prover_protocol_versions + WHERE + id = $1 + "#, id as i32 ) .fetch_one(self.storage.conn()) diff --git a/core/lib/dal/src/protocol_versions_web3_dal.rs b/core/lib/dal/src/protocol_versions_web3_dal.rs index 2819d94f8d81..7c4b4d256a2a 100644 --- a/core/lib/dal/src/protocol_versions_web3_dal.rs +++ b/core/lib/dal/src/protocol_versions_web3_dal.rs @@ -11,9 +11,14 @@ impl ProtocolVersionsWeb3Dal<'_, '_> { pub async fn get_protocol_version_by_id(&mut self, version_id: u16) -> Option { let storage_protocol_version: Option = sqlx::query_as!( StorageProtocolVersion, - "SELECT * FROM protocol_versions - WHERE id = $1 - ", + r#" + SELECT + * + FROM + protocol_versions + WHERE + id = $1 + "#, version_id as i32 ) .fetch_optional(self.storage.conn()) @@ -26,7 +31,16 @@ impl ProtocolVersionsWeb3Dal<'_, '_> { pub async fn get_latest_protocol_version(&mut self) -> ProtocolVersion { let storage_protocol_version: StorageProtocolVersion = sqlx::query_as!( StorageProtocolVersion, - "SELECT * FROM protocol_versions ORDER BY id DESC LIMIT 1", + r#" + SELECT + * + FROM + protocol_versions + ORDER BY + id DESC + LIMIT + 1 + "#, ) .fetch_one(self.storage.conn()) .await diff --git a/core/lib/dal/src/prover_dal.rs b/core/lib/dal/src/prover_dal.rs index ea6eba5eda0f..c0a767531af3 100644 --- a/core/lib/dal/src/prover_dal.rs +++ b/core/lib/dal/src/prover_dal.rs @@ -7,14 +7,10 @@ use std::{ use sqlx::Error; use zksync_types::{ - aggregated_operations::L1BatchProofForL1, proofs::{ AggregationRound, JobCountStatistics, JobExtendedStatistics, ProverJobInfo, ProverJobMetadata, }, - zkevm_test_harness::{ - abstract_zksync_circuit::concrete_circuits::ZkSyncProof, bellman::bn256::Bn256, - }, L1BatchNumber, ProtocolVersionId, }; @@ -37,22 +33,34 @@ impl ProverDal<'_, '_> { ) -> Option { let protocol_versions: Vec = protocol_versions.iter().map(|&id| id as i32).collect(); let result: Option = sqlx::query!( - " - UPDATE prover_jobs - SET status = 'in_progress', attempts = attempts + 1, - updated_at = now(), processing_started_at = now() - WHERE id = ( - SELECT id - FROM prover_jobs - WHERE status = 'queued' - AND protocol_version = ANY($1) - ORDER BY aggregation_round DESC, l1_batch_number ASC, id ASC - LIMIT 1 - FOR UPDATE + r#" + UPDATE prover_jobs + SET + status = 'in_progress', + attempts = attempts + 1, + updated_at = NOW(), + processing_started_at = NOW() + WHERE + id = ( + SELECT + id + FROM + prover_jobs + WHERE + status = 'queued' + AND protocol_version = ANY ($1) + ORDER BY + aggregation_round DESC, + l1_batch_number ASC, + id ASC + LIMIT + 1 + FOR UPDATE SKIP LOCKED ) - RETURNING prover_jobs.* - ", + RETURNING + prover_jobs.* + "#, &protocol_versions[..] ) .fetch_optional(self.storage.conn()) @@ -71,22 +79,29 @@ impl ProverDal<'_, '_> { pub async fn get_proven_l1_batches(&mut self) -> Vec<(L1BatchNumber, AggregationRound)> { { sqlx::query!( - r#"SELECT MAX(l1_batch_number) as "l1_batch_number!", aggregation_round FROM prover_jobs - WHERE status='successful' - GROUP BY aggregation_round + r#" + SELECT + MAX(l1_batch_number) AS "l1_batch_number!", + aggregation_round + FROM + prover_jobs + WHERE + status = 'successful' + GROUP BY + aggregation_round "# ) - .fetch_all(self.storage.conn()) - .await - .unwrap() - .into_iter() - .map(|record| { - ( - L1BatchNumber(record.l1_batch_number as u32), - record.aggregation_round.try_into().unwrap(), - ) - }) - .collect() + .fetch_all(self.storage.conn()) + .await + .unwrap() + .into_iter() + .map(|record| { + ( + L1BatchNumber(record.l1_batch_number as u32), + record.aggregation_round.try_into().unwrap(), + ) + }) + .collect() } } @@ -99,23 +114,35 @@ impl ProverDal<'_, '_> { let protocol_versions: Vec = protocol_versions.iter().map(|&id| id as i32).collect(); let result: Option = sqlx::query!( - " + r#" UPDATE prover_jobs - SET status = 'in_progress', attempts = attempts + 1, - updated_at = now(), processing_started_at = now() - WHERE id = ( - SELECT id - FROM prover_jobs - WHERE circuit_type = ANY($1) - AND status = 'queued' - AND protocol_version = ANY($2) - ORDER BY aggregation_round DESC, l1_batch_number ASC, id ASC - LIMIT 1 + SET + status = 'in_progress', + attempts = attempts + 1, + updated_at = NOW(), + processing_started_at = NOW() + WHERE + id = ( + SELECT + id + FROM + prover_jobs + WHERE + circuit_type = ANY ($1) + AND status = 'queued' + AND protocol_version = ANY ($2) + ORDER BY + aggregation_round DESC, + l1_batch_number ASC, + id ASC + LIMIT + 1 FOR UPDATE - SKIP LOCKED + SKIP LOCKED ) - RETURNING prover_jobs.* - ", + RETURNING + prover_jobs.* + "#, &circuit_types[..], &protocol_versions[..] ) @@ -146,11 +173,24 @@ impl ProverDal<'_, '_> { let it = circuit_types_and_urls.into_iter().enumerate(); for (sequence_number, (circuit, circuit_input_blob_url)) in it { sqlx::query!( - " - INSERT INTO prover_jobs (l1_batch_number, circuit_type, sequence_number, prover_input, aggregation_round, circuit_input_blob_url, protocol_version, status, created_at, updated_at) - VALUES ($1, $2, $3, $4, $5, $6, $7, 'queued', now(), now()) - ON CONFLICT(l1_batch_number, aggregation_round, sequence_number) DO NOTHING - ", + r#" + INSERT INTO + prover_jobs ( + l1_batch_number, + circuit_type, + sequence_number, + prover_input, + aggregation_round, + circuit_input_blob_url, + protocol_version, + status, + created_at, + updated_at + ) + VALUES + ($1, $2, $3, $4, $5, $6, $7, 'queued', NOW(), NOW()) + ON CONFLICT (l1_batch_number, aggregation_round, sequence_number) DO NOTHING + "#, l1_batch_number.0 as i64, circuit, sequence_number as i64, @@ -180,11 +220,17 @@ impl ProverDal<'_, '_> { ) -> Result<(), Error> { { sqlx::query!( - " + r#" UPDATE prover_jobs - SET status = 'successful', updated_at = now(), time_taken = $1, result = $2, proccesed_by = $3 - WHERE id = $4 - ", + SET + status = 'successful', + updated_at = NOW(), + time_taken = $1, + result = $2, + proccesed_by = $3 + WHERE + id = $4 + "#, duration_to_naive_time(time_taken), &proof, proccesed_by, @@ -210,12 +256,18 @@ impl ProverDal<'_, '_> { let mut transaction = self.storage.start_transaction().await.unwrap(); let row = sqlx::query!( - " + r#" UPDATE prover_jobs - SET status = 'failed', error = $1, updated_at = now() - WHERE id = $2 - RETURNING l1_batch_number, attempts - ", + SET + status = 'failed', + error = $1, + updated_at = NOW() + WHERE + id = $2 + RETURNING + l1_batch_number, + attempts + "#, error, id as i64, ) @@ -243,65 +295,45 @@ impl ProverDal<'_, '_> { let processing_timeout = pg_interval_from_duration(processing_timeout); { sqlx::query!( - " + r#" UPDATE prover_jobs - SET status = 'queued', updated_at = now(), processing_started_at = now() - WHERE (status = 'in_progress' AND processing_started_at <= now() - $1::interval AND attempts < $2) - OR (status = 'in_gpu_proof' AND processing_started_at <= now() - $1::interval AND attempts < $2) - OR (status = 'failed' AND attempts < $2) - RETURNING id, status, attempts - ", + SET + status = 'queued', + updated_at = NOW(), + processing_started_at = NOW() + WHERE + ( + status = 'in_progress' + AND processing_started_at <= NOW() - $1::INTERVAL + AND attempts < $2 + ) + OR ( + status = 'in_gpu_proof' + AND processing_started_at <= NOW() - $1::INTERVAL + AND attempts < $2 + ) + OR ( + status = 'failed' + AND attempts < $2 + ) + RETURNING + id, + status, + attempts + "#, &processing_timeout, max_attempts as i32, ) - .fetch_all(self.storage.conn()) - .await - .unwrap() - .into_iter() - .map(|row| StuckProverJobs{id: row.id as u64, status: row.status, attempts: row.attempts as u64}) - .collect() - } - } - - // For each block in the provided range it returns a tuple: - // (aggregation_coords; scheduler_proof) - pub async fn get_final_proofs_for_blocks( - &mut self, - from_block: L1BatchNumber, - to_block: L1BatchNumber, - ) -> Vec { - { - sqlx::query!( - "SELECT prover_jobs.result as proof, scheduler_witness_jobs.aggregation_result_coords - FROM prover_jobs - INNER JOIN scheduler_witness_jobs - ON prover_jobs.l1_batch_number = scheduler_witness_jobs.l1_batch_number - WHERE prover_jobs.l1_batch_number >= $1 AND prover_jobs.l1_batch_number <= $2 - AND prover_jobs.aggregation_round = 3 - AND prover_jobs.status = 'successful' - ", - from_block.0 as i32, - to_block.0 as i32 - ) - .fetch_all(self.storage.conn()) - .await - .unwrap() - .into_iter() - .map(|row| { - let deserialized_proof = bincode::deserialize::>( - &row.proof - .expect("prove_job with `successful` status has no result"), - ).expect("cannot deserialize proof"); - let deserialized_aggregation_result_coords = bincode::deserialize::<[[u8; 32]; 4]>( - &row.aggregation_result_coords - .expect("scheduler_witness_job with `successful` status has no aggregation_result_coords"), - ).expect("cannot deserialize proof"); - L1BatchProofForL1 { - aggregation_result_coords: deserialized_aggregation_result_coords, - scheduler_proof: ZkSyncProof::into_proof(deserialized_proof), - } - }) - .collect() + .fetch_all(self.storage.conn()) + .await + .unwrap() + .into_iter() + .map(|row| StuckProverJobs { + id: row.id as u64, + status: row.status, + attempts: row.attempts as u64, + }) + .collect() } } @@ -311,10 +343,18 @@ impl ProverDal<'_, '_> { { sqlx::query!( r#" - SELECT COUNT(*) as "count!", circuit_type as "circuit_type!", status as "status!" - FROM prover_jobs - WHERE status <> 'skipped' and status <> 'successful' - GROUP BY circuit_type, status + SELECT + COUNT(*) AS "count!", + circuit_type AS "circuit_type!", + status AS "status!" + FROM + prover_jobs + WHERE + status <> 'skipped' + AND status <> 'successful' + GROUP BY + circuit_type, + status "# ) .fetch_all(self.storage.conn()) @@ -345,9 +385,13 @@ impl ProverDal<'_, '_> { { let mut results: HashMap = sqlx::query!( r#" - SELECT COUNT(*) as "count!", status as "status!" - FROM prover_jobs - GROUP BY status + SELECT + COUNT(*) AS "count!", + status AS "status!" + FROM + prover_jobs + GROUP BY + status "# ) .fetch_all(self.storage.conn()) @@ -369,13 +413,22 @@ impl ProverDal<'_, '_> { { sqlx::query!( r#" - SELECT MIN(l1_batch_number) as "l1_batch_number?" FROM ( - SELECT MIN(l1_batch_number) as "l1_batch_number" - FROM prover_jobs - WHERE status = 'successful' OR aggregation_round < 3 - GROUP BY l1_batch_number - HAVING MAX(aggregation_round) < 3 - ) as inn + SELECT + MIN(l1_batch_number) AS "l1_batch_number?" + FROM + ( + SELECT + MIN(l1_batch_number) AS "l1_batch_number" + FROM + prover_jobs + WHERE + status = 'successful' + OR aggregation_round < 3 + GROUP BY + l1_batch_number + HAVING + MAX(aggregation_round) < 3 + ) AS inn "# ) .fetch_one(self.storage.conn()) @@ -392,12 +445,21 @@ impl ProverDal<'_, '_> { { sqlx::query!( r#" - SELECT MIN(l1_batch_number) as "l1_batch_number!", circuit_type - FROM prover_jobs - WHERE aggregation_round = 0 AND (status = 'queued' OR status = 'in_progress' - OR status = 'in_gpu_proof' - OR status = 'failed') - GROUP BY circuit_type + SELECT + MIN(l1_batch_number) AS "l1_batch_number!", + circuit_type + FROM + prover_jobs + WHERE + aggregation_round = 0 + AND ( + status = 'queued' + OR status = 'in_progress' + OR status = 'in_gpu_proof' + OR status = 'failed' + ) + GROUP BY + circuit_type "# ) .fetch_all(self.storage.conn()) @@ -414,19 +476,36 @@ impl ProverDal<'_, '_> { let limits = sqlx::query!( r#" SELECT - (SELECT l1_batch_number - FROM prover_jobs - WHERE status NOT IN ('successful', 'skipped') - ORDER BY l1_batch_number - LIMIT 1) as "successful_limit!", - - (SELECT l1_batch_number - FROM prover_jobs - WHERE status <> 'queued' - ORDER BY l1_batch_number DESC - LIMIT 1) as "queued_limit!", - - (SELECT MAX(l1_batch_number) as "max!" FROM prover_jobs) as "max_block!" + ( + SELECT + l1_batch_number + FROM + prover_jobs + WHERE + status NOT IN ('successful', 'skipped') + ORDER BY + l1_batch_number + LIMIT + 1 + ) AS "successful_limit!", + ( + SELECT + l1_batch_number + FROM + prover_jobs + WHERE + status <> 'queued' + ORDER BY + l1_batch_number DESC + LIMIT + 1 + ) AS "queued_limit!", + ( + SELECT + MAX(l1_batch_number) AS "max!" + FROM + prover_jobs + ) AS "max_block!" "# ) .fetch_one(self.storage.conn()) @@ -541,9 +620,19 @@ impl ProverDal<'_, '_> { job_id: u32, ) -> Result, Error> { { - let row = sqlx::query!("SELECT * from prover_jobs where id=$1", job_id as i64) - .fetch_optional(self.storage.conn()) - .await?; + let row = sqlx::query!( + r#" + SELECT + * + FROM + prover_jobs + WHERE + id = $1 + "#, + job_id as i64 + ) + .fetch_optional(self.storage.conn()) + .await?; Ok(row.map(|row| ProverJobMetadata { id: row.id as u32, @@ -562,11 +651,17 @@ impl ProverDal<'_, '_> { { let job_ids = sqlx::query!( r#" - SELECT id, circuit_input_blob_url FROM prover_jobs - WHERE status='successful' - AND circuit_input_blob_url is NOT NULL + SELECT + id, + circuit_input_blob_url + FROM + prover_jobs + WHERE + status = 'successful' + AND circuit_input_blob_url IS NOT NULL AND updated_at < NOW() - INTERVAL '30 days' - LIMIT $1; + LIMIT + $1; "#, limit as i32 ) @@ -585,8 +680,11 @@ impl ProverDal<'_, '_> { sqlx::query!( r#" UPDATE prover_jobs - SET status = $1, updated_at = now() - WHERE id = $2 + SET + status = $1, + updated_at = NOW() + WHERE + id = $2 "#, status, id as i64, diff --git a/core/lib/dal/src/snapshots_creator_dal.rs b/core/lib/dal/src/snapshots_creator_dal.rs index b87003602598..15e7f0aae525 100644 --- a/core/lib/dal/src/snapshots_creator_dal.rs +++ b/core/lib/dal/src/snapshots_creator_dal.rs @@ -17,11 +17,17 @@ impl SnapshotsCreatorDal<'_, '_> { ) -> sqlx::Result { let count = sqlx::query!( r#" - SELECT index - FROM initial_writes - WHERE l1_batch_number <= $1 - ORDER BY l1_batch_number DESC , index DESC - LIMIT 1; + SELECT + INDEX + FROM + initial_writes + WHERE + l1_batch_number <= $1 + ORDER BY + l1_batch_number DESC, + INDEX DESC + LIMIT + 1; "#, l1_batch_number.0 as i32 ) @@ -40,23 +46,34 @@ impl SnapshotsCreatorDal<'_, '_> { ) -> sqlx::Result> { let storage_logs = sqlx::query!( r#" - SELECT storage_logs.key as "key!", - storage_logs.value as "value!", - storage_logs.address as "address!", - storage_logs.miniblock_number as "miniblock_number!", - initial_writes.l1_batch_number as "l1_batch_number!", - initial_writes.index - FROM (SELECT hashed_key, - max(ARRAY [miniblock_number, operation_number]::int[]) AS op - FROM storage_logs - WHERE miniblock_number <= $1 and hashed_key >= $2 and hashed_key < $3 - GROUP BY hashed_key - ORDER BY hashed_key) AS keys - INNER JOIN storage_logs ON keys.hashed_key = storage_logs.hashed_key + SELECT + storage_logs.key AS "key!", + storage_logs.value AS "value!", + storage_logs.address AS "address!", + storage_logs.miniblock_number AS "miniblock_number!", + initial_writes.l1_batch_number AS "l1_batch_number!", + initial_writes.index + FROM + ( + SELECT + hashed_key, + MAX(ARRAY[miniblock_number, operation_number]::INT[]) AS op + FROM + storage_logs + WHERE + miniblock_number <= $1 + AND hashed_key >= $2 + AND hashed_key < $3 + GROUP BY + hashed_key + ORDER BY + hashed_key + ) AS keys + INNER JOIN storage_logs ON keys.hashed_key = storage_logs.hashed_key AND storage_logs.miniblock_number = keys.op[1] AND storage_logs.operation_number = keys.op[2] - INNER JOIN initial_writes ON keys.hashed_key = initial_writes.hashed_key; - "#, + INNER JOIN initial_writes ON keys.hashed_key = initial_writes.hashed_key; + "#, miniblock_number.0 as i64, hashed_keys_range.start().0.as_slice(), hashed_keys_range.end().0.as_slice(), @@ -87,17 +104,25 @@ impl SnapshotsCreatorDal<'_, '_> { miniblock_number: MiniblockNumber, ) -> sqlx::Result> { let rows = sqlx::query!( - "SELECT bytecode FROM factory_deps WHERE miniblock_number <= $1", + r#" + SELECT + bytecode + FROM + factory_deps + WHERE + miniblock_number <= $1 + "#, miniblock_number.0 as i64, ) .instrument("get_all_factory_deps") .report_latency() .fetch_all(self.storage.conn()) .await?; + Ok(rows .into_iter() .map(|row| SnapshotFactoryDependency { - bytecode: row.bytecode, + bytecode: row.bytecode.into(), }) .collect()) } diff --git a/core/lib/dal/src/snapshots_dal.rs b/core/lib/dal/src/snapshots_dal.rs index 0e031b31d142..9582b3a72094 100644 --- a/core/lib/dal/src/snapshots_dal.rs +++ b/core/lib/dal/src/snapshots_dal.rs @@ -18,8 +18,18 @@ impl SnapshotsDal<'_, '_> { factory_deps_filepaths: &str, ) -> Result<(), sqlx::Error> { sqlx::query!( - "INSERT INTO snapshots (l1_batch_number, storage_logs_filepaths, factory_deps_filepath, created_at, updated_at) \ - VALUES ($1, $2, $3, NOW(), NOW())", + r#" + INSERT INTO + snapshots ( + l1_batch_number, + storage_logs_filepaths, + factory_deps_filepath, + created_at, + updated_at + ) + VALUES + ($1, $2, $3, NOW(), NOW()) + "#, l1_batch_number.0 as i32, storage_logs_filepaths, factory_deps_filepaths, @@ -33,7 +43,14 @@ impl SnapshotsDal<'_, '_> { pub async fn get_all_snapshots(&mut self) -> Result { let records: Vec = sqlx::query!( - "SELECT l1_batch_number, factory_deps_filepath, storage_logs_filepaths FROM snapshots" + r#" + SELECT + l1_batch_number, + factory_deps_filepath, + storage_logs_filepaths + FROM + snapshots + "# ) .instrument("get_all_snapshots") .report_latency() @@ -52,7 +69,16 @@ impl SnapshotsDal<'_, '_> { l1_batch_number: L1BatchNumber, ) -> Result, sqlx::Error> { let record: Option = sqlx::query!( - "SELECT l1_batch_number, factory_deps_filepath, storage_logs_filepaths FROM snapshots WHERE l1_batch_number = $1", + r#" + SELECT + l1_batch_number, + factory_deps_filepath, + storage_logs_filepaths + FROM + snapshots + WHERE + l1_batch_number = $1 + "#, l1_batch_number.0 as i32 ) .instrument("get_snapshot_metadata") diff --git a/core/lib/dal/src/storage_dal.rs b/core/lib/dal/src/storage_dal.rs index 4512d028488f..8f08f65b4405 100644 --- a/core/lib/dal/src/storage_dal.rs +++ b/core/lib/dal/src/storage_dal.rs @@ -27,12 +27,19 @@ impl StorageDal<'_, '_> { // Copy from stdin can't be used here because of 'ON CONFLICT'. sqlx::query!( - "INSERT INTO factory_deps \ - (bytecode_hash, bytecode, miniblock_number, created_at, updated_at) \ - SELECT u.bytecode_hash, u.bytecode, $3, now(), now() \ - FROM UNNEST($1::bytea[], $2::bytea[]) \ - AS u(bytecode_hash, bytecode) \ - ON CONFLICT (bytecode_hash) DO NOTHING", + r#" + INSERT INTO + factory_deps (bytecode_hash, bytecode, miniblock_number, created_at, updated_at) + SELECT + u.bytecode_hash, + u.bytecode, + $3, + NOW(), + NOW() + FROM + UNNEST($1::bytea[], $2::bytea[]) AS u (bytecode_hash, bytecode) + ON CONFLICT (bytecode_hash) DO NOTHING + "#, &bytecode_hashes as &[&[u8]], &bytecodes as &[&[u8]], block_number.0 as i64, @@ -45,7 +52,14 @@ impl StorageDal<'_, '_> { /// Returns bytecode for a factory dependency with the specified bytecode `hash`. pub async fn get_factory_dep(&mut self, hash: H256) -> Option> { sqlx::query!( - "SELECT bytecode FROM factory_deps WHERE bytecode_hash = $1", + r#" + SELECT + bytecode + FROM + factory_deps + WHERE + bytecode_hash = $1 + "#, hash.as_bytes(), ) .fetch_optional(self.storage.conn()) @@ -91,7 +105,15 @@ impl StorageDal<'_, '_> { let hashes_as_bytes: Vec<_> = hashes.iter().map(H256::as_bytes).collect(); sqlx::query!( - "SELECT bytecode, bytecode_hash FROM factory_deps WHERE bytecode_hash = ANY($1)", + r#" + SELECT + bytecode, + bytecode_hash + FROM + factory_deps + WHERE + bytecode_hash = ANY ($1) + "#, &hashes_as_bytes as &[&[u8]], ) .fetch_all(self.storage.conn()) @@ -114,7 +136,14 @@ impl StorageDal<'_, '_> { block_number: MiniblockNumber, ) -> Vec { sqlx::query!( - "SELECT bytecode_hash FROM factory_deps WHERE miniblock_number > $1", + r#" + SELECT + bytecode_hash + FROM + factory_deps + WHERE + miniblock_number > $1 + "#, block_number.0 as i64 ) .fetch_all(self.storage.conn()) @@ -159,12 +188,26 @@ impl StorageDal<'_, '_> { // Copy from stdin can't be used here because of 'ON CONFLICT'. sqlx::query!( - "INSERT INTO storage (hashed_key, address, key, value, tx_hash, created_at, updated_at) \ - SELECT u.hashed_key, u.address, u.key, u.value, u.tx_hash, now(), now() \ - FROM UNNEST ($1::bytea[], $2::bytea[], $3::bytea[], $4::bytea[], $5::bytea[]) \ - AS u(hashed_key, address, key, value, tx_hash) \ - ON CONFLICT (hashed_key) \ - DO UPDATE SET tx_hash = excluded.tx_hash, value = excluded.value, updated_at = now()", + r#" + INSERT INTO + storage (hashed_key, address, key, value, tx_hash, created_at, updated_at) + SELECT + u.hashed_key, + u.address, + u.key, + u.value, + u.tx_hash, + NOW(), + NOW() + FROM + UNNEST($1::bytea[], $2::bytea[], $3::bytea[], $4::bytea[], $5::bytea[]) AS u (hashed_key, address, key, value, tx_hash) + ON CONFLICT (hashed_key) DO + UPDATE + SET + tx_hash = excluded.tx_hash, + value = excluded.value, + updated_at = NOW() + "#, &hashed_keys, &addresses as &[&[u8]], &keys as &[&[u8]], @@ -183,7 +226,14 @@ impl StorageDal<'_, '_> { let hashed_key = key.hashed_key(); sqlx::query!( - "SELECT value FROM storage WHERE hashed_key = $1", + r#" + SELECT + value + FROM + storage + WHERE + hashed_key = $1 + "#, hashed_key.as_bytes() ) .instrument("get_by_key") @@ -198,7 +248,11 @@ impl StorageDal<'_, '_> { /// Removes all factory deps with a miniblock number strictly greater than the specified `block_number`. pub async fn rollback_factory_deps(&mut self, block_number: MiniblockNumber) { sqlx::query!( - "DELETE FROM factory_deps WHERE miniblock_number > $1", + r#" + DELETE FROM factory_deps + WHERE + miniblock_number > $1 + "#, block_number.0 as i64 ) .execute(self.storage.conn()) diff --git a/core/lib/dal/src/storage_logs_dal.rs b/core/lib/dal/src/storage_logs_dal.rs index 43a69ebca57c..ff757b748e8d 100644 --- a/core/lib/dal/src/storage_logs_dal.rs +++ b/core/lib/dal/src/storage_logs_dal.rs @@ -73,7 +73,14 @@ impl StorageLogsDal<'_, '_> { logs: &[(H256, Vec)], ) { let operation_number = sqlx::query!( - "SELECT MAX(operation_number) as \"max?\" FROM storage_logs WHERE miniblock_number = $1", + r#" + SELECT + MAX(operation_number) AS "max?" + FROM + storage_logs + WHERE + miniblock_number = $1 + "#, block_number.0 as i64 ) .fetch_one(self.storage.conn()) @@ -129,7 +136,11 @@ impl StorageLogsDal<'_, '_> { let stage_start = Instant::now(); sqlx::query!( - "DELETE FROM storage WHERE hashed_key = ANY($1)", + r#" + DELETE FROM storage + WHERE + hashed_key = ANY ($1) + "#, &keys_to_delete as &[&[u8]], ) .execute(self.storage.conn()) @@ -143,9 +154,15 @@ impl StorageLogsDal<'_, '_> { let stage_start = Instant::now(); sqlx::query!( - "UPDATE storage SET value = u.value \ - FROM UNNEST($1::bytea[], $2::bytea[]) AS u(key, value) \ - WHERE u.key = hashed_key", + r#" + UPDATE storage + SET + value = u.value + FROM + UNNEST($1::bytea[], $2::bytea[]) AS u (key, value) + WHERE + u.key = hashed_key + "#, &keys_to_update as &[&[u8]], &values_to_update as &[&[u8]], ) @@ -165,8 +182,19 @@ impl StorageLogsDal<'_, '_> { miniblock_number: MiniblockNumber, ) -> Vec { sqlx::query!( - "SELECT DISTINCT ON (hashed_key) hashed_key FROM \ - (SELECT * FROM storage_logs WHERE miniblock_number > $1) inn", + r#" + SELECT DISTINCT + ON (hashed_key) hashed_key + FROM + ( + SELECT + * + FROM + storage_logs + WHERE + miniblock_number > $1 + ) inn + "#, miniblock_number.0 as i64 ) .fetch_all(self.storage.conn()) @@ -180,7 +208,11 @@ impl StorageLogsDal<'_, '_> { /// Removes all storage logs with a miniblock number strictly greater than the specified `block_number`. pub async fn rollback_storage_logs(&mut self, block_number: MiniblockNumber) { sqlx::query!( - "DELETE FROM storage_logs WHERE miniblock_number > $1", + r#" + DELETE FROM storage_logs + WHERE + miniblock_number > $1 + "#, block_number.0 as i64 ) .execute(self.storage.conn()) @@ -191,14 +223,26 @@ impl StorageLogsDal<'_, '_> { pub async fn is_contract_deployed_at_address(&mut self, address: Address) -> bool { let hashed_key = get_code_key(&address).hashed_key(); let row = sqlx::query!( - "SELECT COUNT(*) as \"count!\" \ - FROM (\ - SELECT * FROM storage_logs \ - WHERE storage_logs.hashed_key = $1 \ - ORDER BY storage_logs.miniblock_number DESC, storage_logs.operation_number DESC \ - LIMIT 1\ - ) sl \ - WHERE sl.value != $2", + r#" + SELECT + COUNT(*) AS "count!" + FROM + ( + SELECT + * + FROM + storage_logs + WHERE + storage_logs.hashed_key = $1 + ORDER BY + storage_logs.miniblock_number DESC, + storage_logs.operation_number DESC + LIMIT + 1 + ) sl + WHERE + sl.value != $2 + "#, hashed_key.as_bytes(), FAILED_CONTRACT_DEPLOYMENT_BYTECODE_HASH.as_bytes(), ) @@ -216,12 +260,33 @@ impl StorageLogsDal<'_, '_> { l1_batch_number: L1BatchNumber, ) -> HashMap { let rows = sqlx::query!( - "SELECT address, key, value \ - FROM storage_logs \ - WHERE miniblock_number BETWEEN \ - (SELECT MIN(number) FROM miniblocks WHERE l1_batch_number = $1) \ - AND (SELECT MAX(number) FROM miniblocks WHERE l1_batch_number = $1) \ - ORDER BY miniblock_number, operation_number", + r#" + SELECT + address, + key, + value + FROM + storage_logs + WHERE + miniblock_number BETWEEN ( + SELECT + MIN(number) + FROM + miniblocks + WHERE + l1_batch_number = $1 + ) AND ( + SELECT + MAX(number) + FROM + miniblocks + WHERE + l1_batch_number = $1 + ) + ORDER BY + miniblock_number, + operation_number + "#, l1_batch_number.0 as i64 ) .fetch_all(self.storage.conn()) @@ -333,8 +398,16 @@ impl StorageLogsDal<'_, '_> { let hashed_keys: Vec<_> = hashed_keys.iter().map(H256::as_bytes).collect(); let rows = sqlx::query!( - "SELECT hashed_key, l1_batch_number, index FROM initial_writes \ - WHERE hashed_key = ANY($1::bytea[])", + r#" + SELECT + hashed_key, + l1_batch_number, + INDEX + FROM + initial_writes + WHERE + hashed_key = ANY ($1::bytea[]) + "#, &hashed_keys as &[&[u8]], ) .instrument("get_l1_batches_and_indices_for_initial_writes") @@ -393,11 +466,26 @@ impl StorageLogsDal<'_, '_> { let hashed_keys: Vec<_> = hashed_keys.iter().map(H256::as_bytes).collect(); let rows = sqlx::query!( - "SELECT u.hashed_key as \"hashed_key!\", \ - (SELECT value FROM storage_logs \ - WHERE hashed_key = u.hashed_key AND miniblock_number <= $2 \ - ORDER BY miniblock_number DESC, operation_number DESC LIMIT 1) as \"value?\" \ - FROM UNNEST($1::bytea[]) AS u(hashed_key)", + r#" + SELECT + u.hashed_key AS "hashed_key!", + ( + SELECT + value + FROM + storage_logs + WHERE + hashed_key = u.hashed_key + AND miniblock_number <= $2 + ORDER BY + miniblock_number DESC, + operation_number DESC + LIMIT + 1 + ) AS "value?" + FROM + UNNEST($1::bytea[]) AS u (hashed_key) + "#, &hashed_keys as &[&[u8]], miniblock_number.0 as i64 ) @@ -449,20 +537,35 @@ impl StorageLogsDal<'_, '_> { .map(|range| (range.start().as_bytes(), range.end().as_bytes())) .unzip(); let rows = sqlx::query!( - "WITH sl AS ( \ - SELECT ( \ - SELECT ARRAY[hashed_key, value] AS kv \ - FROM storage_logs \ - WHERE storage_logs.miniblock_number = $1 \ - AND storage_logs.hashed_key >= u.start_key \ - AND storage_logs.hashed_key <= u.end_key \ - ORDER BY storage_logs.hashed_key LIMIT 1 \ - ) \ - FROM UNNEST($2::bytea[], $3::bytea[]) AS u(start_key, end_key) \ - ) \ - SELECT sl.kv[1] AS \"hashed_key?\", sl.kv[2] AS \"value?\", initial_writes.index \ - FROM sl \ - LEFT OUTER JOIN initial_writes ON initial_writes.hashed_key = sl.kv[1]", + r#" + WITH + sl AS ( + SELECT + ( + SELECT + ARRAY[hashed_key, value] AS kv + FROM + storage_logs + WHERE + storage_logs.miniblock_number = $1 + AND storage_logs.hashed_key >= u.start_key + AND storage_logs.hashed_key <= u.end_key + ORDER BY + storage_logs.hashed_key + LIMIT + 1 + ) + FROM + UNNEST($2::bytea[], $3::bytea[]) AS u (start_key, end_key) + ) + SELECT + sl.kv[1] AS "hashed_key?", + sl.kv[2] AS "value?", + initial_writes.index + FROM + sl + LEFT OUTER JOIN initial_writes ON initial_writes.hashed_key = sl.kv[1] + "#, miniblock_number.0 as i64, &start_keys as &[&[u8]], &end_keys as &[&[u8]], @@ -488,13 +591,21 @@ impl StorageLogsDal<'_, '_> { key_range: ops::RangeInclusive, ) -> sqlx::Result> { let rows = sqlx::query!( - "SELECT storage_logs.hashed_key, storage_logs.value, initial_writes.index \ - FROM storage_logs \ - INNER JOIN initial_writes ON storage_logs.hashed_key = initial_writes.hashed_key \ - WHERE storage_logs.miniblock_number = $1 \ - AND storage_logs.hashed_key >= $2::bytea \ - AND storage_logs.hashed_key <= $3::bytea \ - ORDER BY storage_logs.hashed_key", + r#" + SELECT + storage_logs.hashed_key, + storage_logs.value, + initial_writes.index + FROM + storage_logs + INNER JOIN initial_writes ON storage_logs.hashed_key = initial_writes.hashed_key + WHERE + storage_logs.miniblock_number = $1 + AND storage_logs.hashed_key >= $2::bytea + AND storage_logs.hashed_key <= $3::bytea + ORDER BY + storage_logs.hashed_key + "#, miniblock_number.0 as i64, key_range.start().as_bytes(), key_range.end().as_bytes() @@ -516,8 +627,12 @@ impl StorageLogsDal<'_, '_> { operation_numbers: &[i32], ) { sqlx::query!( - "DELETE FROM storage_logs \ - WHERE miniblock_number = $1 AND operation_number != ALL($2)", + r#" + DELETE FROM storage_logs + WHERE + miniblock_number = $1 + AND operation_number != ALL ($2) + "#, miniblock_number.0 as i64, &operation_numbers ) @@ -580,10 +695,14 @@ impl StorageLogsDal<'_, '_> { /// Vacuums `storage_logs` table. /// Shouldn't be used in production. pub async fn vacuum_storage_logs(&mut self) { - sqlx::query!("VACUUM storage_logs") - .execute(self.storage.conn()) - .await - .unwrap(); + sqlx::query!( + r#" + VACUUM storage_logs + "# + ) + .execute(self.storage.conn()) + .await + .unwrap(); } } diff --git a/core/lib/dal/src/storage_logs_dedup_dal.rs b/core/lib/dal/src/storage_logs_dedup_dal.rs index 25e0a8f6eefd..a7bef5aa794a 100644 --- a/core/lib/dal/src/storage_logs_dedup_dal.rs +++ b/core/lib/dal/src/storage_logs_dedup_dal.rs @@ -60,9 +60,18 @@ impl StorageLogsDedupDal<'_, '_> { .collect(); sqlx::query!( - "INSERT INTO initial_writes (hashed_key, index, l1_batch_number, created_at, updated_at) \ - SELECT u.hashed_key, u.index, $3, now(), now() \ - FROM UNNEST($1::bytea[], $2::bigint[]) AS u(hashed_key, index)", + r#" + INSERT INTO + initial_writes (hashed_key, INDEX, l1_batch_number, created_at, updated_at) + SELECT + u.hashed_key, + u.index, + $3, + NOW(), + NOW() + FROM + UNNEST($1::bytea[], $2::BIGINT[]) AS u (hashed_key, INDEX) + "#, &hashed_keys, &indices, l1_batch_number.0 as i64, @@ -77,7 +86,15 @@ impl StorageLogsDedupDal<'_, '_> { l1_batch_number: L1BatchNumber, ) -> HashSet { sqlx::query!( - "SELECT address, key FROM protective_reads WHERE l1_batch_number = $1", + r#" + SELECT + address, + key + FROM + protective_reads + WHERE + l1_batch_number = $1 + "#, l1_batch_number.0 as i64 ) .fetch_all(self.storage.conn()) @@ -94,12 +111,19 @@ impl StorageLogsDedupDal<'_, '_> { } pub async fn max_enumeration_index(&mut self) -> Option { - sqlx::query!("SELECT MAX(index) as \"max?\" FROM initial_writes",) - .fetch_one(self.storage.conn()) - .await - .unwrap() - .max - .map(|max| max as u64) + sqlx::query!( + r#" + SELECT + MAX(INDEX) AS "max?" + FROM + initial_writes + "#, + ) + .fetch_one(self.storage.conn()) + .await + .unwrap() + .max + .map(|max| max as u64) } pub async fn initial_writes_for_batch( @@ -107,9 +131,17 @@ impl StorageLogsDedupDal<'_, '_> { l1_batch_number: L1BatchNumber, ) -> Vec<(H256, u64)> { sqlx::query!( - "SELECT hashed_key, index FROM initial_writes \ - WHERE l1_batch_number = $1 \ - ORDER BY index", + r#" + SELECT + hashed_key, + INDEX + FROM + initial_writes + WHERE + l1_batch_number = $1 + ORDER BY + INDEX + "#, l1_batch_number.0 as i64 ) .fetch_all(self.storage.conn()) @@ -122,9 +154,14 @@ impl StorageLogsDedupDal<'_, '_> { pub async fn get_enumeration_index_for_key(&mut self, key: StorageKey) -> Option { sqlx::query!( - "SELECT index \ - FROM initial_writes \ - WHERE hashed_key = $1", + r#" + SELECT + INDEX + FROM + initial_writes + WHERE + hashed_key = $1 + "#, key.hashed_key().0.to_vec() ) .fetch_optional(self.storage.conn()) @@ -137,8 +174,14 @@ impl StorageLogsDedupDal<'_, '_> { pub async fn filter_written_slots(&mut self, hashed_keys: &[H256]) -> HashSet { let hashed_keys: Vec<_> = hashed_keys.iter().map(H256::as_bytes).collect(); sqlx::query!( - "SELECT hashed_key FROM initial_writes \ - WHERE hashed_key = ANY($1)", + r#" + SELECT + hashed_key + FROM + initial_writes + WHERE + hashed_key = ANY ($1) + "#, &hashed_keys as &[&[u8]], ) .fetch_all(self.storage.conn()) diff --git a/core/lib/dal/src/storage_web3_dal.rs b/core/lib/dal/src/storage_web3_dal.rs index 5ba7510b7e0e..c95d4ca73dbb 100644 --- a/core/lib/dal/src/storage_web3_dal.rs +++ b/core/lib/dal/src/storage_web3_dal.rs @@ -60,11 +60,18 @@ impl StorageWeb3Dal<'_, '_> { sqlx::query!( r#" - SELECT value - FROM storage_logs - WHERE storage_logs.hashed_key = $1 AND storage_logs.miniblock_number <= $2 - ORDER BY storage_logs.miniblock_number DESC, storage_logs.operation_number DESC - LIMIT 1 + SELECT + value + FROM + storage_logs + WHERE + storage_logs.hashed_key = $1 + AND storage_logs.miniblock_number <= $2 + ORDER BY + storage_logs.miniblock_number DESC, + storage_logs.operation_number DESC + LIMIT + 1 "#, hashed_key.as_bytes(), block_number.0 as i64 @@ -90,9 +97,23 @@ impl StorageWeb3Dal<'_, '_> { miniblock_number: MiniblockNumber, ) -> Result { let row = sqlx::query!( - "SELECT \ - (SELECT l1_batch_number FROM miniblocks WHERE number = $1) as \"block_batch?\", \ - (SELECT MAX(number) + 1 FROM l1_batches) as \"max_batch?\"", + r#" + SELECT + ( + SELECT + l1_batch_number + FROM + miniblocks + WHERE + number = $1 + ) AS "block_batch?", + ( + SELECT + MAX(number) + 1 + FROM + l1_batches + ) AS "max_batch?" + "#, miniblock_number.0 as i64 ) .fetch_one(self.storage.conn()) @@ -110,7 +131,14 @@ impl StorageWeb3Dal<'_, '_> { ) -> Result, SqlxError> { let hashed_key = key.hashed_key(); let row = sqlx::query!( - "SELECT l1_batch_number FROM initial_writes WHERE hashed_key = $1", + r#" + SELECT + l1_batch_number + FROM + initial_writes + WHERE + hashed_key = $1 + "#, hashed_key.as_bytes(), ) .instrument("get_l1_batch_number_for_initial_write") @@ -129,7 +157,14 @@ impl StorageWeb3Dal<'_, '_> { miniblock_numbers: ops::RangeInclusive, ) -> Vec { sqlx::query!( - "SELECT DISTINCT hashed_key FROM storage_logs WHERE miniblock_number BETWEEN $1 and $2", + r#" + SELECT DISTINCT + hashed_key + FROM + storage_logs + WHERE + miniblock_number BETWEEN $1 AND $2 + "#, miniblock_numbers.start().0 as i64, miniblock_numbers.end().0 as i64 ) @@ -151,19 +186,28 @@ impl StorageWeb3Dal<'_, '_> { let hashed_key = get_code_key(&address).hashed_key(); { sqlx::query!( - " - SELECT bytecode FROM ( - SELECT * FROM storage_logs + r#" + SELECT + bytecode + FROM + ( + SELECT + * + FROM + storage_logs WHERE - storage_logs.hashed_key = $1 AND - storage_logs.miniblock_number <= $2 + storage_logs.hashed_key = $1 + AND storage_logs.miniblock_number <= $2 ORDER BY - storage_logs.miniblock_number DESC, storage_logs.operation_number DESC - LIMIT 1 + storage_logs.miniblock_number DESC, + storage_logs.operation_number DESC + LIMIT + 1 ) t JOIN factory_deps ON value = factory_deps.bytecode_hash - WHERE value != $3 - ", + WHERE + value != $3 + "#, hashed_key.as_bytes(), block_number.0 as i64, FAILED_CONTRACT_DEPLOYMENT_BYTECODE_HASH.as_bytes(), @@ -183,7 +227,15 @@ impl StorageWeb3Dal<'_, '_> { ) -> Result>, SqlxError> { { sqlx::query!( - "SELECT bytecode FROM factory_deps WHERE bytecode_hash = $1 AND miniblock_number <= $2", + r#" + SELECT + bytecode + FROM + factory_deps + WHERE + bytecode_hash = $1 + AND miniblock_number <= $2 + "#, hash.as_bytes(), block_number.0 as i64 ) diff --git a/core/lib/dal/src/sync_dal.rs b/core/lib/dal/src/sync_dal.rs index bf6eeb88cdbb..4d50f2855bbf 100644 --- a/core/lib/dal/src/sync_dal.rs +++ b/core/lib/dal/src/sync_dal.rs @@ -23,22 +23,42 @@ impl SyncDal<'_, '_> { let latency = MethodLatency::new("sync_dal_sync_block"); let storage_block_details = sqlx::query_as!( StorageSyncBlock, - "SELECT miniblocks.number, \ - COALESCE(miniblocks.l1_batch_number, (SELECT (max(number) + 1) FROM l1_batches)) as \"l1_batch_number!\", \ - (SELECT max(m2.number) FROM miniblocks m2 WHERE miniblocks.l1_batch_number = m2.l1_batch_number) as \"last_batch_miniblock?\", \ - miniblocks.timestamp, \ - miniblocks.l1_gas_price, \ - miniblocks.l2_fair_gas_price, \ - miniblocks.bootloader_code_hash, \ - miniblocks.default_aa_code_hash, \ - miniblocks.virtual_blocks, \ - miniblocks.hash, \ - miniblocks.consensus, \ - miniblocks.protocol_version as \"protocol_version!\", \ - l1_batches.fee_account_address as \"fee_account_address?\" \ - FROM miniblocks \ - LEFT JOIN l1_batches ON miniblocks.l1_batch_number = l1_batches.number \ - WHERE miniblocks.number = $1", + r#" + SELECT + miniblocks.number, + COALESCE( + miniblocks.l1_batch_number, + ( + SELECT + (MAX(number) + 1) + FROM + l1_batches + ) + ) AS "l1_batch_number!", + ( + SELECT + MAX(m2.number) + FROM + miniblocks m2 + WHERE + miniblocks.l1_batch_number = m2.l1_batch_number + ) AS "last_batch_miniblock?", + miniblocks.timestamp, + miniblocks.l1_gas_price, + miniblocks.l2_fair_gas_price, + miniblocks.bootloader_code_hash, + miniblocks.default_aa_code_hash, + miniblocks.virtual_blocks, + miniblocks.hash, + miniblocks.consensus, + miniblocks.protocol_version AS "protocol_version!", + l1_batches.fee_account_address AS "fee_account_address?" + FROM + miniblocks + LEFT JOIN l1_batches ON miniblocks.l1_batch_number = l1_batches.number + WHERE + miniblocks.number = $1 + "#, block_number.0 as i64 ) .instrument("sync_dal_sync_block.block") @@ -52,7 +72,16 @@ impl SyncDal<'_, '_> { let transactions = if include_transactions { let transactions = sqlx::query_as!( StorageTransaction, - r#"SELECT * FROM transactions WHERE miniblock_number = $1 ORDER BY index_in_block"#, + r#" + SELECT + * + FROM + transactions + WHERE + miniblock_number = $1 + ORDER BY + index_in_block + "#, block_number.0 as i64 ) .instrument("sync_dal_sync_block.transactions") diff --git a/core/lib/dal/src/tokens_dal.rs b/core/lib/dal/src/tokens_dal.rs index 5c0f306cc05d..d66ebf89e536 100644 --- a/core/lib/dal/src/tokens_dal.rs +++ b/core/lib/dal/src/tokens_dal.rs @@ -63,10 +63,17 @@ impl TokensDal<'_, '_> { ) { { sqlx::query!( - "UPDATE tokens SET token_list_name = $2, token_list_symbol = $3, - token_list_decimals = $4, well_known = true, updated_at = now() - WHERE l1_address = $1 - ", + r#" + UPDATE tokens + SET + token_list_name = $2, + token_list_symbol = $3, + token_list_decimals = $4, + well_known = TRUE, + updated_at = NOW() + WHERE + l1_address = $1 + "#, l1_address.as_bytes(), metadata.name, metadata.symbol, @@ -80,11 +87,20 @@ impl TokensDal<'_, '_> { pub async fn get_well_known_token_addresses(&mut self) -> Vec<(Address, Address)> { { - let records = - sqlx::query!("SELECT l1_address, l2_address FROM tokens WHERE well_known = true") - .fetch_all(self.storage.conn()) - .await - .unwrap(); + let records = sqlx::query!( + r#" + SELECT + l1_address, + l2_address + FROM + tokens + WHERE + well_known = TRUE + "# + ) + .fetch_all(self.storage.conn()) + .await + .unwrap(); let addresses: Vec<(Address, Address)> = records .into_iter() .map(|record| { @@ -100,10 +116,17 @@ impl TokensDal<'_, '_> { pub async fn get_all_l2_token_addresses(&mut self) -> Vec
{ { - let records = sqlx::query!("SELECT l2_address FROM tokens") - .fetch_all(self.storage.conn()) - .await - .unwrap(); + let records = sqlx::query!( + r#" + SELECT + l2_address + FROM + tokens + "# + ) + .fetch_all(self.storage.conn()) + .await + .unwrap(); let addresses: Vec
= records .into_iter() .map(|record| Address::from_slice(&record.l2_address)) @@ -114,10 +137,19 @@ impl TokensDal<'_, '_> { pub async fn get_unknown_l1_token_addresses(&mut self) -> Vec
{ { - let records = sqlx::query!("SELECT l1_address FROM tokens WHERE well_known = false") - .fetch_all(self.storage.conn()) - .await - .unwrap(); + let records = sqlx::query!( + r#" + SELECT + l1_address + FROM + tokens + WHERE + well_known = FALSE + "# + ) + .fetch_all(self.storage.conn()) + .await + .unwrap(); let addresses: Vec
= records .into_iter() .map(|record| Address::from_slice(&record.l1_address)) @@ -130,7 +162,14 @@ impl TokensDal<'_, '_> { { let min_volume = ratio_to_big_decimal(min_volume, STORED_USD_PRICE_PRECISION); let records = sqlx::query!( - "SELECT l1_address FROM tokens WHERE market_volume > $1", + r#" + SELECT + l1_address + FROM + tokens + WHERE + market_volume > $1 + "#, min_volume ) .fetch_all(self.storage.conn()) @@ -147,11 +186,19 @@ impl TokensDal<'_, '_> { pub async fn set_l1_token_price(&mut self, l1_address: &Address, price: TokenPrice) { { sqlx::query!( - "UPDATE tokens SET usd_price = $2, usd_price_updated_at = $3, updated_at = now() WHERE l1_address = $1", - l1_address.as_bytes(), - ratio_to_big_decimal(&price.usd_price, STORED_USD_PRICE_PRECISION), - price.last_updated.naive_utc(), - ) + r#" + UPDATE tokens + SET + usd_price = $2, + usd_price_updated_at = $3, + updated_at = NOW() + WHERE + l1_address = $1 + "#, + l1_address.as_bytes(), + ratio_to_big_decimal(&price.usd_price, STORED_USD_PRICE_PRECISION), + price.last_updated.naive_utc(), + ) .execute(self.storage.conn()) .await .unwrap(); @@ -161,20 +208,29 @@ impl TokensDal<'_, '_> { pub async fn rollback_tokens(&mut self, block_number: MiniblockNumber) { { sqlx::query!( - " - DELETE FROM tokens - WHERE l2_address IN - ( - SELECT substring(key, 12, 20) FROM storage_logs - WHERE storage_logs.address = $1 AND miniblock_number > $2 AND NOT EXISTS ( - SELECT 1 FROM storage_logs as s - WHERE - s.hashed_key = storage_logs.hashed_key AND - (s.miniblock_number, s.operation_number) >= (storage_logs.miniblock_number, storage_logs.operation_number) AND - s.value = $3 - ) + r#" + DELETE FROM tokens + WHERE + l2_address IN ( + SELECT + SUBSTRING(key, 12, 20) + FROM + storage_logs + WHERE + storage_logs.address = $1 + AND miniblock_number > $2 + AND NOT EXISTS ( + SELECT + 1 + FROM + storage_logs AS s + WHERE + s.hashed_key = storage_logs.hashed_key + AND (s.miniblock_number, s.operation_number) >= (storage_logs.miniblock_number, storage_logs.operation_number) + AND s.value = $3 + ) ) - ", + "#, ACCOUNT_CODE_STORAGE_ADDRESS.as_bytes(), block_number.0 as i64, FAILED_CONTRACT_DEPLOYMENT_BYTECODE_HASH.as_bytes() diff --git a/core/lib/dal/src/tokens_web3_dal.rs b/core/lib/dal/src/tokens_web3_dal.rs index 753f57c85c63..c3421c646791 100644 --- a/core/lib/dal/src/tokens_web3_dal.rs +++ b/core/lib/dal/src/tokens_web3_dal.rs @@ -14,9 +14,20 @@ impl TokensWeb3Dal<'_, '_> { pub async fn get_well_known_tokens(&mut self) -> Result, SqlxError> { { let records = sqlx::query!( - "SELECT l1_address, l2_address, name, symbol, decimals FROM tokens - WHERE well_known = true - ORDER BY symbol" + r#" + SELECT + l1_address, + l2_address, + NAME, + symbol, + decimals + FROM + tokens + WHERE + well_known = TRUE + ORDER BY + symbol + "# ) .fetch_all(self.storage.conn()) .await?; @@ -43,7 +54,15 @@ impl TokensWeb3Dal<'_, '_> { { let storage_price = sqlx::query_as!( StorageTokenPrice, - "SELECT usd_price, usd_price_updated_at FROM tokens WHERE l2_address = $1", + r#" + SELECT + usd_price, + usd_price_updated_at + FROM + tokens + WHERE + l2_address = $1 + "#, l2_address.as_bytes(), ) .fetch_optional(self.storage.conn()) diff --git a/core/lib/dal/src/transactions_dal.rs b/core/lib/dal/src/transactions_dal.rs index 78da3e0fc045..7041d4e20ac7 100644 --- a/core/lib/dal/src/transactions_dal.rs +++ b/core/lib/dal/src/transactions_dal.rs @@ -80,43 +80,57 @@ impl TransactionsDal<'_, '_> { let received_at = NaiveDateTime::from_timestamp_opt(secs, nanosecs).unwrap(); sqlx::query!( - " - INSERT INTO transactions - ( - hash, - is_priority, - initiator_address, - - gas_limit, - max_fee_per_gas, - gas_per_pubdata_limit, - - data, - priority_op_id, - full_fee, - layer_2_tip_fee, - contract_address, - l1_block_number, - value, - - paymaster, - paymaster_input, - tx_format, - - l1_tx_mint, - l1_tx_refund_recipient, - - received_at, - created_at, - updated_at - ) + r#" + INSERT INTO + transactions ( + hash, + is_priority, + initiator_address, + gas_limit, + max_fee_per_gas, + gas_per_pubdata_limit, + data, + priority_op_id, + full_fee, + layer_2_tip_fee, + contract_address, + l1_block_number, + value, + paymaster, + paymaster_input, + tx_format, + l1_tx_mint, + l1_tx_refund_recipient, + received_at, + created_at, + updated_at + ) VALUES ( - $1, TRUE, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, - $13, $14, $15, $16, $17, $18, now(), now() + $1, + TRUE, + $2, + $3, + $4, + $5, + $6, + $7, + $8, + $9, + $10, + $11, + $12, + $13, + $14, + $15, + $16, + $17, + $18, + NOW(), + NOW() ) ON CONFLICT (hash) DO NOTHING - ", + "#, tx_hash_bytes, sender, gas_limit, @@ -166,41 +180,53 @@ impl TransactionsDal<'_, '_> { let received_at = NaiveDateTime::from_timestamp_opt(secs, nanosecs).unwrap(); sqlx::query!( - " - INSERT INTO transactions - ( - hash, - is_priority, - initiator_address, - - gas_limit, - max_fee_per_gas, - gas_per_pubdata_limit, - - data, - upgrade_id, - contract_address, - l1_block_number, - value, - - paymaster, - paymaster_input, - tx_format, - - l1_tx_mint, - l1_tx_refund_recipient, - - received_at, - created_at, - updated_at - ) + r#" + INSERT INTO + transactions ( + hash, + is_priority, + initiator_address, + gas_limit, + max_fee_per_gas, + gas_per_pubdata_limit, + data, + upgrade_id, + contract_address, + l1_block_number, + value, + paymaster, + paymaster_input, + tx_format, + l1_tx_mint, + l1_tx_refund_recipient, + received_at, + created_at, + updated_at + ) VALUES ( - $1, TRUE, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, - $13, $14, $15, $16, now(), now() + $1, + TRUE, + $2, + $3, + $4, + $5, + $6, + $7, + $8, + $9, + $10, + $11, + $12, + $13, + $14, + $15, + $16, + NOW(), + NOW() ) ON CONFLICT (hash) DO NOTHING - ", + "#, tx_hash, sender, gas_limit, @@ -263,59 +289,87 @@ impl TransactionsDal<'_, '_> { // It is worth mentioning that if WHERE clause conditions are not met, None will be returned. let query_result = sqlx::query!( r#" - INSERT INTO transactions - ( - hash, - is_priority, - initiator_address, - nonce, - signature, - gas_limit, - max_fee_per_gas, - max_priority_fee_per_gas, - gas_per_pubdata_limit, - input, - data, - tx_format, - contract_address, - value, - paymaster, - paymaster_input, - execution_info, - received_at, - created_at, - updated_at - ) + INSERT INTO + transactions ( + hash, + is_priority, + initiator_address, + nonce, + signature, + gas_limit, + max_fee_per_gas, + max_priority_fee_per_gas, + gas_per_pubdata_limit, + input, + data, + tx_format, + contract_address, + value, + paymaster, + paymaster_input, + execution_info, + received_at, + created_at, + updated_at + ) VALUES ( - $1, FALSE, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, - jsonb_build_object('gas_used', $16::bigint, 'storage_writes', $17::int, 'contracts_used', $18::int), - $19, now(), now() + $1, + FALSE, + $2, + $3, + $4, + $5, + $6, + $7, + $8, + $9, + $10, + $11, + $12, + $13, + $14, + $15, + JSONB_BUILD_OBJECT('gas_used', $16::BIGINT, 'storage_writes', $17::INT, 'contracts_used', $18::INT), + $19, + NOW(), + NOW() ) - ON CONFLICT - (initiator_address, nonce) - DO UPDATE - SET hash=$1, - signature=$4, - gas_limit=$5, - max_fee_per_gas=$6, - max_priority_fee_per_gas=$7, - gas_per_pubdata_limit=$8, - input=$9, - data=$10, - tx_format=$11, - contract_address=$12, - value=$13, - paymaster=$14, - paymaster_input=$15, - execution_info=jsonb_build_object('gas_used', $16::bigint, 'storage_writes', $17::int, 'contracts_used', $18::int), - in_mempool=FALSE, - received_at=$19, - created_at=now(), - updated_at=now(), - error = NULL - WHERE transactions.is_priority = FALSE AND transactions.miniblock_number IS NULL - RETURNING (SELECT hash FROM transactions WHERE transactions.initiator_address = $2 AND transactions.nonce = $3) IS NOT NULL as "is_replaced!" + ON CONFLICT (initiator_address, nonce) DO + UPDATE + SET + hash = $1, + signature = $4, + gas_limit = $5, + max_fee_per_gas = $6, + max_priority_fee_per_gas = $7, + gas_per_pubdata_limit = $8, + input = $9, + data = $10, + tx_format = $11, + contract_address = $12, + value = $13, + paymaster = $14, + paymaster_input = $15, + execution_info = JSONB_BUILD_OBJECT('gas_used', $16::BIGINT, 'storage_writes', $17::INT, 'contracts_used', $18::INT), + in_mempool = FALSE, + received_at = $19, + created_at = NOW(), + updated_at = NOW(), + error = NULL + WHERE + transactions.is_priority = FALSE + AND transactions.miniblock_number IS NULL + RETURNING + ( + SELECT + hash + FROM + transactions + WHERE + transactions.initiator_address = $2 + AND transactions.nonce = $3 + ) IS NOT NULL AS "is_replaced!" "#, tx_hash.as_bytes(), initiator_address.as_bytes(), @@ -387,19 +441,21 @@ impl TransactionsDal<'_, '_> { let hashes: Vec<_> = transactions.iter().map(|tx| tx.hash.as_bytes()).collect(); let l1_batch_tx_indexes: Vec<_> = (0..transactions.len() as i32).collect(); sqlx::query!( - " - UPDATE transactions - SET - l1_batch_number = $3, - l1_batch_tx_index = data_table.l1_batch_tx_index, - updated_at = now() - FROM - (SELECT - UNNEST($1::int[]) AS l1_batch_tx_index, - UNNEST($2::bytea[]) AS hash - ) AS data_table - WHERE transactions.hash=data_table.hash - ", + r#" + UPDATE transactions + SET + l1_batch_number = $3, + l1_batch_tx_index = data_table.l1_batch_tx_index, + updated_at = NOW() + FROM + ( + SELECT + UNNEST($1::INT[]) AS l1_batch_tx_index, + UNNEST($2::bytea[]) AS hash + ) AS data_table + WHERE + transactions.hash = data_table.hash + "#, &l1_batch_tx_indexes, &hashes as &[&[u8]], block_number.0 as i64 @@ -549,60 +605,65 @@ impl TransactionsDal<'_, '_> { // Note, that transactions are updated in order of their hashes to avoid deadlocks with other UPDATE queries. sqlx::query!( r#" - UPDATE transactions - SET - hash = data_table.hash, - signature = data_table.signature, - gas_limit = data_table.gas_limit, - max_fee_per_gas = data_table.max_fee_per_gas, - max_priority_fee_per_gas = data_table.max_priority_fee_per_gas, - gas_per_pubdata_limit = data_table.gas_per_pubdata_limit, - input = data_table.input, - data = data_table.data, - tx_format = data_table.tx_format, - miniblock_number = $21, - index_in_block = data_table.index_in_block, - error = NULLIF(data_table.error, ''), - effective_gas_price = data_table.effective_gas_price, - execution_info = data_table.new_execution_info, - refunded_gas = data_table.refunded_gas, - value = data_table.value, - contract_address = data_table.contract_address, - paymaster = data_table.paymaster, - paymaster_input = data_table.paymaster_input, - in_mempool = FALSE, - updated_at = now() - FROM - ( - SELECT data_table_temp.* FROM ( + UPDATE transactions + SET + hash = data_table.hash, + signature = data_table.signature, + gas_limit = data_table.gas_limit, + max_fee_per_gas = data_table.max_fee_per_gas, + max_priority_fee_per_gas = data_table.max_priority_fee_per_gas, + gas_per_pubdata_limit = data_table.gas_per_pubdata_limit, + input = data_table.input, + data = data_table.data, + tx_format = data_table.tx_format, + miniblock_number = $21, + index_in_block = data_table.index_in_block, + error = NULLIF(data_table.error, ''), + effective_gas_price = data_table.effective_gas_price, + execution_info = data_table.new_execution_info, + refunded_gas = data_table.refunded_gas, + value = data_table.value, + contract_address = data_table.contract_address, + paymaster = data_table.paymaster, + paymaster_input = data_table.paymaster_input, + in_mempool = FALSE, + updated_at = NOW() + FROM + ( + SELECT + data_table_temp.* + FROM + ( SELECT UNNEST($1::bytea[]) AS initiator_address, - UNNEST($2::int[]) AS nonce, + UNNEST($2::INT[]) AS nonce, UNNEST($3::bytea[]) AS hash, UNNEST($4::bytea[]) AS signature, - UNNEST($5::numeric[]) AS gas_limit, - UNNEST($6::numeric[]) AS max_fee_per_gas, - UNNEST($7::numeric[]) AS max_priority_fee_per_gas, - UNNEST($8::numeric[]) AS gas_per_pubdata_limit, - UNNEST($9::int[]) AS tx_format, - UNNEST($10::integer[]) AS index_in_block, - UNNEST($11::varchar[]) AS error, - UNNEST($12::numeric[]) AS effective_gas_price, + UNNEST($5::NUMERIC[]) AS gas_limit, + UNNEST($6::NUMERIC[]) AS max_fee_per_gas, + UNNEST($7::NUMERIC[]) AS max_priority_fee_per_gas, + UNNEST($8::NUMERIC[]) AS gas_per_pubdata_limit, + UNNEST($9::INT[]) AS tx_format, + UNNEST($10::INTEGER[]) AS index_in_block, + UNNEST($11::VARCHAR[]) AS error, + UNNEST($12::NUMERIC[]) AS effective_gas_price, UNNEST($13::jsonb[]) AS new_execution_info, UNNEST($14::bytea[]) AS input, UNNEST($15::jsonb[]) AS data, - UNNEST($16::bigint[]) as refunded_gas, - UNNEST($17::numeric[]) as value, - UNNEST($18::bytea[]) as contract_address, - UNNEST($19::bytea[]) as paymaster, - UNNEST($20::bytea[]) as paymaster_input + UNNEST($16::BIGINT[]) AS refunded_gas, + UNNEST($17::NUMERIC[]) AS value, + UNNEST($18::bytea[]) AS contract_address, + UNNEST($19::bytea[]) AS paymaster, + UNNEST($20::bytea[]) AS paymaster_input ) AS data_table_temp JOIN transactions ON transactions.initiator_address = data_table_temp.initiator_address - AND transactions.nonce = data_table_temp.nonce - ORDER BY transactions.hash - ) AS data_table - WHERE transactions.initiator_address=data_table.initiator_address - AND transactions.nonce=data_table.nonce + AND transactions.nonce = data_table_temp.nonce + ORDER BY + transactions.hash + ) AS data_table + WHERE + transactions.initiator_address = data_table.initiator_address + AND transactions.nonce = data_table.nonce "#, &l2_initiators, &l2_nonces, @@ -635,27 +696,28 @@ impl TransactionsDal<'_, '_> { if !l1_hashes.is_empty() { sqlx::query!( r#" - UPDATE transactions - SET - miniblock_number = $1, - index_in_block = data_table.index_in_block, - error = NULLIF(data_table.error, ''), - in_mempool=FALSE, - execution_info = execution_info || data_table.new_execution_info, - refunded_gas = data_table.refunded_gas, - effective_gas_price = data_table.effective_gas_price, - updated_at = now() - FROM - ( - SELECT - UNNEST($2::bytea[]) AS hash, - UNNEST($3::integer[]) AS index_in_block, - UNNEST($4::varchar[]) AS error, - UNNEST($5::jsonb[]) AS new_execution_info, - UNNEST($6::bigint[]) as refunded_gas, - UNNEST($7::numeric[]) as effective_gas_price - ) AS data_table - WHERE transactions.hash = data_table.hash + UPDATE transactions + SET + miniblock_number = $1, + index_in_block = data_table.index_in_block, + error = NULLIF(data_table.error, ''), + in_mempool = FALSE, + execution_info = execution_info || data_table.new_execution_info, + refunded_gas = data_table.refunded_gas, + effective_gas_price = data_table.effective_gas_price, + updated_at = NOW() + FROM + ( + SELECT + UNNEST($2::bytea[]) AS hash, + UNNEST($3::INTEGER[]) AS index_in_block, + UNNEST($4::VARCHAR[]) AS error, + UNNEST($5::jsonb[]) AS new_execution_info, + UNNEST($6::BIGINT[]) AS refunded_gas, + UNNEST($7::NUMERIC[]) AS effective_gas_price + ) AS data_table + WHERE + transactions.hash = data_table.hash "#, miniblock_number.0 as i32, &l1_hashes, @@ -673,27 +735,28 @@ impl TransactionsDal<'_, '_> { if !upgrade_hashes.is_empty() { sqlx::query!( r#" - UPDATE transactions - SET - miniblock_number = $1, - index_in_block = data_table.index_in_block, - error = NULLIF(data_table.error, ''), - in_mempool=FALSE, - execution_info = execution_info || data_table.new_execution_info, - refunded_gas = data_table.refunded_gas, - effective_gas_price = data_table.effective_gas_price, - updated_at = now() - FROM - ( - SELECT - UNNEST($2::bytea[]) AS hash, - UNNEST($3::integer[]) AS index_in_block, - UNNEST($4::varchar[]) AS error, - UNNEST($5::jsonb[]) AS new_execution_info, - UNNEST($6::bigint[]) as refunded_gas, - UNNEST($7::numeric[]) as effective_gas_price - ) AS data_table - WHERE transactions.hash = data_table.hash + UPDATE transactions + SET + miniblock_number = $1, + index_in_block = data_table.index_in_block, + error = NULLIF(data_table.error, ''), + in_mempool = FALSE, + execution_info = execution_info || data_table.new_execution_info, + refunded_gas = data_table.refunded_gas, + effective_gas_price = data_table.effective_gas_price, + updated_at = NOW() + FROM + ( + SELECT + UNNEST($2::bytea[]) AS hash, + UNNEST($3::INTEGER[]) AS index_in_block, + UNNEST($4::VARCHAR[]) AS error, + UNNEST($5::jsonb[]) AS new_execution_info, + UNNEST($6::BIGINT[]) AS refunded_gas, + UNNEST($7::NUMERIC[]) AS effective_gas_price + ) AS data_table + WHERE + transactions.hash = data_table.hash "#, miniblock_number.0 as i32, &upgrade_hashes, @@ -711,11 +774,14 @@ impl TransactionsDal<'_, '_> { if !bytea_call_traces.is_empty() { sqlx::query!( r#" - INSERT INTO call_traces (tx_hash, call_trace) - SELECT u.tx_hash, u.call_trace - FROM UNNEST($1::bytea[], $2::bytea[]) - AS u(tx_hash, call_trace) - "#, + INSERT INTO + call_traces (tx_hash, call_trace) + SELECT + u.tx_hash, + u.call_trace + FROM + UNNEST($1::bytea[], $2::bytea[]) AS u (tx_hash, call_trace) + "#, &call_traces_tx_hashes, &bytea_call_traces ) @@ -735,9 +801,14 @@ impl TransactionsDal<'_, '_> { // and we will update nothing. // These txs don't affect the state, so we can just easily skip this update. sqlx::query!( - "UPDATE transactions - SET error = $1, updated_at = now() - WHERE hash = $2", + r#" + UPDATE transactions + SET + error = $1, + updated_at = NOW() + WHERE + hash = $2 + "#, error, transaction_hash.0.to_vec() ) @@ -750,19 +821,30 @@ impl TransactionsDal<'_, '_> { pub async fn reset_transactions_state(&mut self, miniblock_number: MiniblockNumber) { { let tx_hashes = sqlx::query!( - "UPDATE transactions - SET l1_batch_number = NULL, miniblock_number = NULL, error = NULL, index_in_block = NULL, execution_info = '{}' - WHERE miniblock_number > $1 - RETURNING hash - ", + r#" + UPDATE transactions + SET + l1_batch_number = NULL, + miniblock_number = NULL, + error = NULL, + index_in_block = NULL, + execution_info = '{}' + WHERE + miniblock_number > $1 + RETURNING + hash + "#, miniblock_number.0 as i64 ) .fetch_all(self.storage.conn()) .await .unwrap(); sqlx::query!( - "DELETE FROM call_traces - WHERE tx_hash = ANY($1)", + r#" + DELETE FROM call_traces + WHERE + tx_hash = ANY ($1) + "#, &tx_hashes .iter() .map(|tx| tx.hash.clone()) @@ -778,10 +860,16 @@ impl TransactionsDal<'_, '_> { { let stuck_tx_timeout = pg_interval_from_duration(stuck_tx_timeout); sqlx::query!( - "DELETE FROM transactions \ - WHERE miniblock_number IS NULL AND received_at < now() - $1::interval \ - AND is_priority=false AND error IS NULL \ - RETURNING hash", + r#" + DELETE FROM transactions + WHERE + miniblock_number IS NULL + AND received_at < NOW() - $1::INTERVAL + AND is_priority = FALSE + AND error IS NULL + RETURNING + hash + "#, stuck_tx_timeout ) .fetch_all(self.storage.conn()) @@ -806,9 +894,16 @@ impl TransactionsDal<'_, '_> { let stashed_addresses: Vec<_> = stashed_accounts.into_iter().map(|a| a.0.to_vec()).collect(); sqlx::query!( - "UPDATE transactions SET in_mempool = FALSE \ - FROM UNNEST ($1::bytea[]) AS s(address) \ - WHERE transactions.in_mempool = TRUE AND transactions.initiator_address = s.address", + r#" + UPDATE transactions + SET + in_mempool = FALSE + FROM + UNNEST($1::bytea[]) AS s (address) + WHERE + transactions.in_mempool = TRUE + AND transactions.initiator_address = s.address + "#, &stashed_addresses, ) .execute(self.storage.conn()) @@ -818,8 +913,12 @@ impl TransactionsDal<'_, '_> { let purged_addresses: Vec<_> = purged_accounts.into_iter().map(|a| a.0.to_vec()).collect(); sqlx::query!( - "DELETE FROM transactions \ - WHERE in_mempool = TRUE AND initiator_address = ANY($1)", + r#" + DELETE FROM transactions + WHERE + in_mempool = TRUE + AND initiator_address = ANY ($1) + "#, &purged_addresses[..] ) .execute(self.storage.conn()) @@ -829,22 +928,47 @@ impl TransactionsDal<'_, '_> { // Note, that transactions are updated in order of their hashes to avoid deadlocks with other UPDATE queries. let transactions = sqlx::query_as!( StorageTransaction, - "UPDATE transactions - SET in_mempool = TRUE - FROM ( - SELECT hash FROM ( - SELECT hash - FROM transactions - WHERE miniblock_number IS NULL AND in_mempool = FALSE AND error IS NULL - AND (is_priority = TRUE OR (max_fee_per_gas >= $2 and gas_per_pubdata_limit >= $3)) - AND tx_format != $4 - ORDER BY is_priority DESC, priority_op_id, received_at - LIMIT $1 - ) as subquery1 - ORDER BY hash - ) as subquery2 - WHERE transactions.hash = subquery2.hash - RETURNING transactions.*", + r#" + UPDATE transactions + SET + in_mempool = TRUE + FROM + ( + SELECT + hash + FROM + ( + SELECT + hash + FROM + transactions + WHERE + miniblock_number IS NULL + AND in_mempool = FALSE + AND error IS NULL + AND ( + is_priority = TRUE + OR ( + max_fee_per_gas >= $2 + AND gas_per_pubdata_limit >= $3 + ) + ) + AND tx_format != $4 + ORDER BY + is_priority DESC, + priority_op_id, + received_at + LIMIT + $1 + ) AS subquery1 + ORDER BY + hash + ) AS subquery2 + WHERE + transactions.hash = subquery2.hash + RETURNING + transactions.* + "#, limit as i32, BigDecimal::from(fee_per_gas), BigDecimal::from(gas_per_pubdata), @@ -865,7 +989,15 @@ impl TransactionsDal<'_, '_> { let storage_keys: Vec<_> = nonce_keys.keys().map(|key| key.0.to_vec()).collect(); let nonces: HashMap<_, _> = sqlx::query!( - r#"SELECT hashed_key, value as "value!" FROM storage WHERE hashed_key = ANY($1)"#, + r#" + SELECT + hashed_key, + value AS "value!" + FROM + storage + WHERE + hashed_key = ANY ($1) + "#, &storage_keys, ) .fetch_all(self.storage.conn()) @@ -889,20 +1021,36 @@ impl TransactionsDal<'_, '_> { pub async fn reset_mempool(&mut self) { { - sqlx::query!("UPDATE transactions SET in_mempool = FALSE WHERE in_mempool = TRUE") - .execute(self.storage.conn()) - .await - .unwrap(); + sqlx::query!( + r#" + UPDATE transactions + SET + in_mempool = FALSE + WHERE + in_mempool = TRUE + "# + ) + .execute(self.storage.conn()) + .await + .unwrap(); } } pub async fn get_last_processed_l1_block(&mut self) -> Option { { sqlx::query!( - "SELECT l1_block_number FROM transactions - WHERE priority_op_id IS NOT NULL - ORDER BY priority_op_id DESC - LIMIT 1" + r#" + SELECT + l1_block_number + FROM + transactions + WHERE + priority_op_id IS NOT NULL + ORDER BY + priority_op_id DESC + LIMIT + 1 + "# ) .fetch_optional(self.storage.conn()) .await @@ -914,7 +1062,14 @@ impl TransactionsDal<'_, '_> { pub async fn last_priority_id(&mut self) -> Option { { let op_id = sqlx::query!( - r#"SELECT MAX(priority_op_id) as "op_id" from transactions where is_priority = true"# + r#" + SELECT + MAX(priority_op_id) AS "op_id" + FROM + transactions + WHERE + is_priority = TRUE + "# ) .fetch_optional(self.storage.conn()) .await @@ -927,21 +1082,34 @@ impl TransactionsDal<'_, '_> { pub async fn next_priority_id(&mut self) -> PriorityOpId { { sqlx::query!( - r#"SELECT MAX(priority_op_id) as "op_id" from transactions where is_priority = true AND miniblock_number IS NOT NULL"# + r#" + SELECT + MAX(priority_op_id) AS "op_id" + FROM + transactions + WHERE + is_priority = TRUE + AND miniblock_number IS NOT NULL + "# ) - .fetch_optional(self.storage.conn()) - .await - .unwrap() - .and_then(|row| row.op_id) - .map(|value| PriorityOpId((value + 1) as u64)) - .unwrap_or_default() + .fetch_optional(self.storage.conn()) + .await + .unwrap() + .and_then(|row| row.op_id) + .map(|value| PriorityOpId((value + 1) as u64)) + .unwrap_or_default() } } pub async fn insert_trace(&mut self, hash: H256, trace: VmExecutionTrace) { { sqlx::query!( - "INSERT INTO transaction_traces (tx_hash, trace, created_at, updated_at) VALUES ($1, $2, now(), now())", + r#" + INSERT INTO + transaction_traces (tx_hash, trace, created_at, updated_at) + VALUES + ($1, $2, NOW(), NOW()) + "#, hash.as_bytes(), serde_json::to_value(trace).unwrap() ) @@ -954,7 +1122,14 @@ impl TransactionsDal<'_, '_> { pub async fn get_trace(&mut self, hash: H256) -> Option { { let trace = sqlx::query!( - "SELECT trace FROM transaction_traces WHERE tx_hash = $1", + r#" + SELECT + trace + FROM + transaction_traces + WHERE + tx_hash = $1 + "#, hash.as_bytes() ) .fetch_optional(self.storage.conn()) @@ -977,9 +1152,18 @@ impl TransactionsDal<'_, '_> { ) -> anyhow::Result> { let transactions = sqlx::query_as!( StorageTransaction, - "SELECT * FROM transactions \ - WHERE miniblock_number IS NOT NULL AND l1_batch_number IS NULL \ - ORDER BY miniblock_number, index_in_block", + r#" + SELECT + * + FROM + transactions + WHERE + miniblock_number IS NOT NULL + AND l1_batch_number IS NULL + ORDER BY + miniblock_number, + index_in_block + "#, ) .fetch_all(self.storage.conn()) .await?; @@ -996,9 +1180,17 @@ impl TransactionsDal<'_, '_> { ) -> anyhow::Result> { let transactions = sqlx::query_as!( StorageTransaction, - "SELECT * FROM transactions \ - WHERE l1_batch_number = $1 \ - ORDER BY miniblock_number, index_in_block", + r#" + SELECT + * + FROM + transactions + WHERE + l1_batch_number = $1 + ORDER BY + miniblock_number, + index_in_block + "#, l1_batch_number.0 as i64, ) .fetch_all(self.storage.conn()) @@ -1034,7 +1226,17 @@ impl TransactionsDal<'_, '_> { .context("No last transaction found for miniblock")? .0; let miniblock_data = sqlx::query!( - "SELECT timestamp, virtual_blocks FROM miniblocks WHERE number BETWEEN $1 AND $2 ORDER BY number", + r#" + SELECT + timestamp, + virtual_blocks + FROM + miniblocks + WHERE + number BETWEEN $1 AND $2 + ORDER BY + number + "#, from_miniblock.0 as i64, to_miniblock.0 as i64, ) @@ -1042,9 +1244,16 @@ impl TransactionsDal<'_, '_> { .await?; let prev_hashes = sqlx::query!( - "SELECT hash FROM miniblocks \ - WHERE number BETWEEN $1 AND $2 \ - ORDER BY number", + r#" + SELECT + hash + FROM + miniblocks + WHERE + number BETWEEN $1 AND $2 + ORDER BY + number + "#, from_miniblock.0 as i64 - 1, to_miniblock.0 as i64 - 1, ) @@ -1082,28 +1291,41 @@ impl TransactionsDal<'_, '_> { { sqlx::query!( r#" - SELECT miniblock_number as "miniblock_number!", - hash, index_in_block as "index_in_block!", l1_batch_tx_index as "l1_batch_tx_index!" - FROM transactions - WHERE l1_batch_number = $1 - ORDER BY miniblock_number, index_in_block + SELECT + miniblock_number AS "miniblock_number!", + hash, + index_in_block AS "index_in_block!", + l1_batch_tx_index AS "l1_batch_tx_index!" + FROM + transactions + WHERE + l1_batch_number = $1 + ORDER BY + miniblock_number, + index_in_block "#, l1_batch_number.0 as i64 ) - .fetch_all(self.storage.conn()) - .await - .unwrap() - .into_iter() - .group_by(|tx| tx.miniblock_number) - .into_iter() - .map(|(miniblock_number, rows)| { - ( - MiniblockNumber(miniblock_number as u32), - rows.map(|row| (H256::from_slice(&row.hash), row.index_in_block as u32, row.l1_batch_tx_index as u16)) - .collect::>(), - ) - }) - .collect() + .fetch_all(self.storage.conn()) + .await + .unwrap() + .into_iter() + .group_by(|tx| tx.miniblock_number) + .into_iter() + .map(|(miniblock_number, rows)| { + ( + MiniblockNumber(miniblock_number as u32), + rows.map(|row| { + ( + H256::from_slice(&row.hash), + row.index_in_block as u32, + row.l1_batch_tx_index as u16, + ) + }) + .collect::>(), + ) + }) + .collect() } } @@ -1112,8 +1334,12 @@ impl TransactionsDal<'_, '_> { sqlx::query_as!( CallTrace, r#" - SELECT * FROM call_traces - WHERE tx_hash = $1 + SELECT + * + FROM + call_traces + WHERE + tx_hash = $1 "#, tx_hash.as_bytes() ) @@ -1128,8 +1354,12 @@ impl TransactionsDal<'_, '_> { sqlx::query_as!( StorageTransaction, r#" - SELECT * FROM transactions - WHERE hash = $1 + SELECT + * + FROM + transactions + WHERE + hash = $1 "#, hash.as_bytes() ) diff --git a/core/lib/dal/src/transactions_web3_dal.rs b/core/lib/dal/src/transactions_web3_dal.rs index 0fc2c09f5977..3580a3c9a39d 100644 --- a/core/lib/dal/src/transactions_web3_dal.rs +++ b/core/lib/dal/src/transactions_web3_dal.rs @@ -31,34 +31,43 @@ impl TransactionsWeb3Dal<'_, '_> { { let receipt = sqlx::query!( r#" - WITH sl AS ( - SELECT * FROM storage_logs - WHERE storage_logs.address = $1 AND storage_logs.tx_hash = $2 - ORDER BY storage_logs.miniblock_number DESC, storage_logs.operation_number DESC - LIMIT 1 - ) + WITH + sl AS ( + SELECT + * + FROM + storage_logs + WHERE + storage_logs.address = $1 + AND storage_logs.tx_hash = $2 + ORDER BY + storage_logs.miniblock_number DESC, + storage_logs.operation_number DESC + LIMIT + 1 + ) SELECT - transactions.hash as tx_hash, - transactions.index_in_block as index_in_block, - transactions.l1_batch_tx_index as l1_batch_tx_index, - transactions.miniblock_number as block_number, - transactions.error as error, - transactions.effective_gas_price as effective_gas_price, - transactions.initiator_address as initiator_address, - transactions.data->'to' as "transfer_to?", - transactions.data->'contractAddress' as "execute_contract_address?", - transactions.tx_format as "tx_format?", - transactions.refunded_gas as refunded_gas, - transactions.gas_limit as gas_limit, - miniblocks.hash as "block_hash?", - miniblocks.l1_batch_number as "l1_batch_number?", - sl.key as "contract_address?" - FROM transactions - LEFT JOIN miniblocks - ON miniblocks.number = transactions.miniblock_number - LEFT JOIN sl - ON sl.value != $3 - WHERE transactions.hash = $2 + transactions.hash AS tx_hash, + transactions.index_in_block AS index_in_block, + transactions.l1_batch_tx_index AS l1_batch_tx_index, + transactions.miniblock_number AS block_number, + transactions.error AS error, + transactions.effective_gas_price AS effective_gas_price, + transactions.initiator_address AS initiator_address, + transactions.data -> 'to' AS "transfer_to?", + transactions.data -> 'contractAddress' AS "execute_contract_address?", + transactions.tx_format AS "tx_format?", + transactions.refunded_gas AS refunded_gas, + transactions.gas_limit AS gas_limit, + miniblocks.hash AS "block_hash?", + miniblocks.l1_batch_number AS "l1_batch_number?", + sl.key AS "contract_address?" + FROM + transactions + LEFT JOIN miniblocks ON miniblocks.number = transactions.miniblock_number + LEFT JOIN sl ON sl.value != $3 + WHERE + transactions.hash = $2 "#, ACCOUNT_CODE_STORAGE_ADDRESS.as_bytes(), hash.as_bytes(), @@ -129,13 +138,26 @@ impl TransactionsWeb3Dal<'_, '_> { StorageWeb3Log, r#" SELECT - address, topic1, topic2, topic3, topic4, value, - Null::bytea as "block_hash", Null::bigint as "l1_batch_number?", - miniblock_number, tx_hash, tx_index_in_block, - event_index_in_block, event_index_in_tx - FROM events - WHERE tx_hash = $1 - ORDER BY miniblock_number ASC, event_index_in_block ASC + address, + topic1, + topic2, + topic3, + topic4, + value, + NULL::bytea AS "block_hash", + NULL::BIGINT AS "l1_batch_number?", + miniblock_number, + tx_hash, + tx_index_in_block, + event_index_in_block, + event_index_in_tx + FROM + events + WHERE + tx_hash = $1 + ORDER BY + miniblock_number ASC, + event_index_in_block ASC "#, hash.as_bytes() ) @@ -223,25 +245,37 @@ impl TransactionsWeb3Dal<'_, '_> { let storage_tx_details: Option = sqlx::query_as!( StorageTransactionDetails, r#" - SELECT transactions.is_priority, - transactions.initiator_address, - transactions.gas_limit, - transactions.gas_per_pubdata_limit, - transactions.received_at, - transactions.miniblock_number, - transactions.error, - transactions.effective_gas_price, - transactions.refunded_gas, - commit_tx.tx_hash as "eth_commit_tx_hash?", - prove_tx.tx_hash as "eth_prove_tx_hash?", - execute_tx.tx_hash as "eth_execute_tx_hash?" - FROM transactions + SELECT + transactions.is_priority, + transactions.initiator_address, + transactions.gas_limit, + transactions.gas_per_pubdata_limit, + transactions.received_at, + transactions.miniblock_number, + transactions.error, + transactions.effective_gas_price, + transactions.refunded_gas, + commit_tx.tx_hash AS "eth_commit_tx_hash?", + prove_tx.tx_hash AS "eth_prove_tx_hash?", + execute_tx.tx_hash AS "eth_execute_tx_hash?" + FROM + transactions LEFT JOIN miniblocks ON miniblocks.number = transactions.miniblock_number LEFT JOIN l1_batches ON l1_batches.number = miniblocks.l1_batch_number - LEFT JOIN eth_txs_history as commit_tx ON (l1_batches.eth_commit_tx_id = commit_tx.eth_tx_id AND commit_tx.confirmed_at IS NOT NULL) - LEFT JOIN eth_txs_history as prove_tx ON (l1_batches.eth_prove_tx_id = prove_tx.eth_tx_id AND prove_tx.confirmed_at IS NOT NULL) - LEFT JOIN eth_txs_history as execute_tx ON (l1_batches.eth_execute_tx_id = execute_tx.eth_tx_id AND execute_tx.confirmed_at IS NOT NULL) - WHERE transactions.hash = $1 + LEFT JOIN eth_txs_history AS commit_tx ON ( + l1_batches.eth_commit_tx_id = commit_tx.eth_tx_id + AND commit_tx.confirmed_at IS NOT NULL + ) + LEFT JOIN eth_txs_history AS prove_tx ON ( + l1_batches.eth_prove_tx_id = prove_tx.eth_tx_id + AND prove_tx.confirmed_at IS NOT NULL + ) + LEFT JOIN eth_txs_history AS execute_tx ON ( + l1_batches.eth_execute_tx_id = execute_tx.eth_tx_id + AND execute_tx.confirmed_at IS NOT NULL + ) + WHERE + transactions.hash = $1 "#, hash.as_bytes() ) @@ -263,12 +297,20 @@ impl TransactionsWeb3Dal<'_, '_> { limit: Option, ) -> Result<(Vec, Option), SqlxError> { let records = sqlx::query!( - "SELECT transactions.hash, transactions.received_at \ - FROM transactions \ - LEFT JOIN miniblocks ON miniblocks.number = miniblock_number \ - WHERE received_at > $1 \ - ORDER BY received_at ASC \ - LIMIT $2", + r#" + SELECT + transactions.hash, + transactions.received_at + FROM + transactions + LEFT JOIN miniblocks ON miniblocks.number = miniblock_number + WHERE + received_at > $1 + ORDER BY + received_at ASC + LIMIT + $2 + "#, from_timestamp, limit.map(|limit| limit as i64) ) @@ -306,11 +348,22 @@ impl TransactionsWeb3Dal<'_, '_> { // Query is fast because we have an index on (`initiator_address`, `nonce`) // and it cannot return more than `max_nonce_ahead` nonces. let non_rejected_nonces: Vec = sqlx::query!( - "SELECT nonce as \"nonce!\" FROM transactions \ - WHERE initiator_address = $1 AND nonce >= $2 \ - AND is_priority = FALSE \ - AND (miniblock_number IS NOT NULL OR error IS NULL) \ - ORDER BY nonce", + r#" + SELECT + nonce AS "nonce!" + FROM + transactions + WHERE + initiator_address = $1 + AND nonce >= $2 + AND is_priority = FALSE + AND ( + miniblock_number IS NOT NULL + OR error IS NULL + ) + ORDER BY + nonce + "#, initiator_address.as_bytes(), latest_nonce as i64 ) @@ -341,9 +394,16 @@ impl TransactionsWeb3Dal<'_, '_> { ) -> Result, SqlxError> { let rows = sqlx::query_as!( StorageTransaction, - "SELECT * FROM transactions \ - WHERE miniblock_number = $1 \ - ORDER BY index_in_block", + r#" + SELECT + * + FROM + transactions + WHERE + miniblock_number = $1 + ORDER BY + index_in_block + "#, miniblock.0 as i64 ) .fetch_all(self.storage.conn()) diff --git a/core/lib/object_store/Cargo.toml b/core/lib/object_store/Cargo.toml index bd071d0d0024..2efe6e603db0 100644 --- a/core/lib/object_store/Cargo.toml +++ b/core/lib/object_store/Cargo.toml @@ -13,6 +13,7 @@ categories = ["cryptography"] vise = { git = "https://github.com/matter-labs/vise.git", version = "0.1.0", rev = "dd05139b76ab0843443ab3ff730174942c825dae" } zksync_config = { path = "../config" } zksync_types = { path = "../types" } +zksync_protobuf = { version = "0.1.0", git = "https://github.com/matter-labs/era-consensus.git", rev = "49b1a98f80d0e9f74fdceadece4283e745c71599" } anyhow = "1.0" async-trait = "0.1" @@ -24,6 +25,7 @@ serde_json = "1.0" flate2 = "1.0.28" tokio = { version = "1.21.2", features = ["full"] } tracing = "0.1" +prost = "0.12.1" [dev-dependencies] tempdir = "0.3.7" diff --git a/core/lib/object_store/src/objects.rs b/core/lib/object_store/src/objects.rs index 89241c7edf7c..dc9865a7c7c2 100644 --- a/core/lib/object_store/src/objects.rs +++ b/core/lib/object_store/src/objects.rs @@ -1,8 +1,11 @@ //! Stored objects. -use std::io::Read; +use std::io::{Read, Write}; +use anyhow::Context; use flate2::{read::GzDecoder, write::GzEncoder, Compression}; +use prost::Message; +use zksync_protobuf::{decode, ProtoFmt}; use zksync_types::{ aggregated_operations::L1BatchProofForL1, proofs::{AggregationRound, PrepareBasicCircuitsJob}, @@ -76,13 +79,13 @@ impl StoredObject for SnapshotFactoryDependencies { type Key<'a> = L1BatchNumber; fn encode_key(key: Self::Key<'_>) -> String { - format!("snapshot_l1_batch_{key}_factory_deps.json.gzip") + format!("snapshot_l1_batch_{key}_factory_deps.proto.gzip") } - //TODO use better language agnostic serialization format like protobuf fn serialize(&self) -> Result, BoxedError> { let mut encoder = GzEncoder::new(Vec::new(), Compression::default()); - serde_json::to_writer(&mut encoder, self).map_err(BoxedError::from)?; + let encoded_bytes = self.build().encode_to_vec(); + encoder.write_all(&encoded_bytes)?; encoder.finish().map_err(From::from) } @@ -92,7 +95,9 @@ impl StoredObject for SnapshotFactoryDependencies { decoder .read_to_end(&mut decompressed_bytes) .map_err(BoxedError::from)?; - serde_json::from_slice(&decompressed_bytes).map_err(From::from) + decode(&decompressed_bytes[..]) + .context("deserialization of Message to SnapshotFactoryDependencies") + .map_err(From::from) } } @@ -102,15 +107,15 @@ impl StoredObject for SnapshotStorageLogsChunk { fn encode_key(key: Self::Key<'_>) -> String { format!( - "snapshot_l1_batch_{}_storage_logs_part_{:0>4}.json.gzip", + "snapshot_l1_batch_{}_storage_logs_part_{:0>4}.proto.gzip", key.l1_batch_number, key.chunk_id ) } - //TODO use better language agnostic serialization format like protobuf fn serialize(&self) -> Result, BoxedError> { let mut encoder = GzEncoder::new(Vec::new(), Compression::default()); - serde_json::to_writer(&mut encoder, self).map_err(BoxedError::from)?; + let encoded_bytes = self.build().encode_to_vec(); + encoder.write_all(&encoded_bytes)?; encoder.finish().map_err(From::from) } @@ -120,7 +125,9 @@ impl StoredObject for SnapshotStorageLogsChunk { decoder .read_to_end(&mut decompressed_bytes) .map_err(BoxedError::from)?; - serde_json::from_slice(&decompressed_bytes).map_err(From::from) + decode(&decompressed_bytes[..]) + .context("deserialization of Message to SnapshotStorageLogsChunk") + .map_err(From::from) } } @@ -311,7 +318,13 @@ impl dyn ObjectStore + '_ { #[cfg(test)] mod tests { + use zksync_types::{ + snapshots::{SnapshotFactoryDependency, SnapshotStorageLog}, + AccountTreeId, Bytes, StorageKey, H160, H256, + }; + use super::*; + use crate::ObjectStoreFactory; #[test] fn test_storage_logs_filesnames_generate_corretly() { @@ -328,16 +341,63 @@ mod tests { chunk_id: 5, }); assert_eq!( - "snapshot_l1_batch_42_storage_logs_part_0097.json.gzip", + "snapshot_l1_batch_42_storage_logs_part_0097.proto.gzip", filename1 ); assert_eq!( - "snapshot_l1_batch_3_storage_logs_part_0531.json.gzip", + "snapshot_l1_batch_3_storage_logs_part_0531.proto.gzip", filename2 ); assert_eq!( - "snapshot_l1_batch_567_storage_logs_part_0005.json.gzip", + "snapshot_l1_batch_567_storage_logs_part_0005.proto.gzip", filename3 ); } + + #[tokio::test] + async fn test_storage_logs_can_be_serialized_and_deserialized() { + let store = ObjectStoreFactory::mock().create_store().await; + let key = SnapshotStorageLogsStorageKey { + l1_batch_number: L1BatchNumber(567), + chunk_id: 5, + }; + let storage_logs = SnapshotStorageLogsChunk { + storage_logs: vec![ + SnapshotStorageLog { + key: StorageKey::new(AccountTreeId::new(H160::random()), H256::random()), + value: H256::random(), + l1_batch_number_of_initial_write: L1BatchNumber(123), + enumeration_index: 234, + }, + SnapshotStorageLog { + key: StorageKey::new(AccountTreeId::new(H160::random()), H256::random()), + value: H256::random(), + l1_batch_number_of_initial_write: L1BatchNumber(345), + enumeration_index: 456, + }, + ], + }; + store.put(key, &storage_logs).await.unwrap(); + let reconstructed_storage_logs = store.get(key).await.unwrap(); + assert_eq!(storage_logs, reconstructed_storage_logs); + } + + #[tokio::test] + async fn test_factory_deps_can_be_serialized_and_deserialized() { + let store = ObjectStoreFactory::mock().create_store().await; + let key = L1BatchNumber(123); + let factory_deps = SnapshotFactoryDependencies { + factory_deps: vec![ + SnapshotFactoryDependency { + bytecode: Bytes(vec![1, 51, 101, 201, 255]), + }, + SnapshotFactoryDependency { + bytecode: Bytes(vec![2, 52, 102, 202, 255]), + }, + ], + }; + store.put(key, &factory_deps).await.unwrap(); + let reconstructed_factory_deps = store.get(key).await.unwrap(); + assert_eq!(factory_deps, reconstructed_factory_deps); + } } diff --git a/core/lib/state/src/test_utils.rs b/core/lib/state/src/test_utils.rs index 3a100c505698..2a5664ae0602 100644 --- a/core/lib/state/src/test_utils.rs +++ b/core/lib/state/src/test_utils.rs @@ -35,7 +35,6 @@ pub(crate) async fn prepare_postgres(conn: &mut StorageProcessor<'_>) { } pub(crate) fn gen_storage_logs(indices: ops::Range) -> Vec { - // Addresses and keys of storage logs must be sorted for the `multi_block_workflow` test. let mut accounts = [ "4b3af74f66ab1f0da3f2e4ec7a3cb99baf1af7b2", "ef4bb7b21c5fe7432a7d63876cc59ecc23b46636", diff --git a/core/lib/types/Cargo.toml b/core/lib/types/Cargo.toml index 9eaab556565f..903520764597 100644 --- a/core/lib/types/Cargo.toml +++ b/core/lib/types/Cargo.toml @@ -36,6 +36,7 @@ strum = { version = "0.24", features = ["derive"] } thiserror = "1.0" num_enum = "0.6" hex = "0.4" +prost = "0.12.1" # Crypto stuff # TODO (PLA-440): remove parity-crypto diff --git a/core/lib/types/build.rs b/core/lib/types/build.rs new file mode 100644 index 000000000000..62a98bd982c7 --- /dev/null +++ b/core/lib/types/build.rs @@ -0,0 +1,12 @@ +//! Generates rust code from protobufs. +fn main() { + zksync_protobuf_build::Config { + input_root: "src/proto".into(), + proto_root: "zksync/types".into(), + dependencies: vec![], + protobuf_crate: "::zksync_protobuf".parse().unwrap(), + is_public: false, + } + .generate() + .expect("generate()"); +} diff --git a/core/lib/types/src/lib.rs b/core/lib/types/src/lib.rs index 32a62c4df804..a7d7e71e0eff 100644 --- a/core/lib/types/src/lib.rs +++ b/core/lib/types/src/lib.rs @@ -56,6 +56,7 @@ pub mod api; pub mod eth_sender; pub mod helpers; pub mod proofs; +pub mod proto; pub mod prover_server_api; pub mod transaction_request; pub mod utils; diff --git a/core/lib/types/src/proto/mod.proto b/core/lib/types/src/proto/mod.proto new file mode 100644 index 000000000000..163215bb1237 --- /dev/null +++ b/core/lib/types/src/proto/mod.proto @@ -0,0 +1,23 @@ +syntax = "proto3"; + +package zksync.types; + +message SnapshotStorageLogsChunk { + repeated SnapshotStorageLog storage_logs = 1; +} + +message SnapshotStorageLog { + optional bytes account_address = 1; // required; H160 + optional bytes storage_key = 2; // required; H256 + optional bytes storage_value = 3; // required; H256 + optional uint32 l1_batch_number_of_initial_write = 4; // required + optional uint64 enumeration_index = 5; // required +} + +message SnapshotFactoryDependencies { + repeated SnapshotFactoryDependency factory_deps = 1; +} + +message SnapshotFactoryDependency { + optional bytes bytecode = 1; // required +} diff --git a/core/lib/types/src/proto/mod.rs b/core/lib/types/src/proto/mod.rs new file mode 100644 index 000000000000..9f44835b29cf --- /dev/null +++ b/core/lib/types/src/proto/mod.rs @@ -0,0 +1,3 @@ +#![allow(warnings)] + +include!(concat!(env!("OUT_DIR"), "/src/proto/gen.rs")); diff --git a/core/lib/types/src/snapshots.rs b/core/lib/types/src/snapshots.rs index 794480ea550c..fd6cd939b478 100644 --- a/core/lib/types/src/snapshots.rs +++ b/core/lib/types/src/snapshots.rs @@ -1,7 +1,11 @@ +use std::convert::TryFrom; + +use anyhow::Context; use serde::{Deserialize, Serialize}; -use zksync_basic_types::{L1BatchNumber, MiniblockNumber}; +use zksync_basic_types::{AccountTreeId, L1BatchNumber, MiniblockNumber}; +use zksync_protobuf::{required, ProtoFmt}; -use crate::{commitment::L1BatchWithMetadata, StorageKey, StorageValue}; +use crate::{commitment::L1BatchWithMetadata, Bytes, StorageKey, StorageValue}; #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] @@ -38,21 +42,19 @@ pub struct SnapshotStorageLogsChunkMetadata { pub filepath: String, } -#[derive(Debug, Clone, Copy, Serialize, Deserialize)] +#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq)] #[serde(rename_all = "camelCase")] pub struct SnapshotStorageLogsStorageKey { pub l1_batch_number: L1BatchNumber, pub chunk_id: u64, } -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(rename_all = "camelCase")] +#[derive(Debug, Clone, PartialEq)] pub struct SnapshotStorageLogsChunk { pub storage_logs: Vec, } -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(rename_all = "camelCase")] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct SnapshotStorageLog { pub key: StorageKey, pub value: StorageValue, @@ -60,14 +62,113 @@ pub struct SnapshotStorageLog { pub enumeration_index: u64, } -#[derive(Debug, Serialize, Deserialize)] -#[serde(rename_all = "camelCase")] +#[derive(Debug, PartialEq)] pub struct SnapshotFactoryDependencies { pub factory_deps: Vec, } -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(rename_all = "camelCase")] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct SnapshotFactoryDependency { - pub bytecode: Vec, + pub bytecode: Bytes, +} + +impl ProtoFmt for SnapshotFactoryDependency { + type Proto = crate::proto::SnapshotFactoryDependency; + + fn read(r: &Self::Proto) -> anyhow::Result { + Ok(Self { + bytecode: Bytes(required(&r.bytecode).context("bytecode")?.clone()), + }) + } + fn build(&self) -> Self::Proto { + Self::Proto { + bytecode: Some(self.bytecode.0.as_slice().into()), + } + } +} + +impl ProtoFmt for SnapshotFactoryDependencies { + type Proto = crate::proto::SnapshotFactoryDependencies; + + fn read(r: &Self::Proto) -> anyhow::Result { + let mut factory_deps = Vec::with_capacity(r.factory_deps.len()); + for (i, factory_dep) in r.factory_deps.iter().enumerate() { + factory_deps.push( + SnapshotFactoryDependency::read(factory_dep) + .with_context(|| format!("factory_deps[{i}]"))?, + ) + } + Ok(Self { factory_deps }) + } + fn build(&self) -> Self::Proto { + Self::Proto { + factory_deps: self + .factory_deps + .iter() + .map(SnapshotFactoryDependency::build) + .collect(), + } + } +} + +impl ProtoFmt for SnapshotStorageLog { + type Proto = crate::proto::SnapshotStorageLog; + + fn read(r: &Self::Proto) -> anyhow::Result { + Ok(Self { + key: StorageKey::new( + AccountTreeId::new( + required(&r.account_address) + .and_then(|bytes| Ok(<[u8; 20]>::try_from(bytes.as_slice())?.into())) + .context("account_address")?, + ), + required(&r.storage_key) + .and_then(|bytes| Ok(<[u8; 32]>::try_from(bytes.as_slice())?.into())) + .context("storage_key")?, + ), + value: required(&r.storage_value) + .and_then(|bytes| Ok(<[u8; 32]>::try_from(bytes.as_slice())?.into())) + .context("storage_value")?, + l1_batch_number_of_initial_write: L1BatchNumber( + *required(&r.l1_batch_number_of_initial_write) + .context("l1_batch_number_of_initial_write")?, + ), + enumeration_index: *required(&r.enumeration_index).context("enumeration_index")?, + }) + } + + fn build(&self) -> Self::Proto { + Self::Proto { + account_address: Some(self.key.address().as_bytes().into()), + storage_key: Some(self.key.key().as_bytes().into()), + storage_value: Some(self.value.as_bytes().into()), + l1_batch_number_of_initial_write: Some(self.l1_batch_number_of_initial_write.0), + enumeration_index: Some(self.enumeration_index), + } + } +} + +impl ProtoFmt for SnapshotStorageLogsChunk { + type Proto = crate::proto::SnapshotStorageLogsChunk; + + fn read(r: &Self::Proto) -> anyhow::Result { + let mut storage_logs = Vec::with_capacity(r.storage_logs.len()); + for (i, storage_log) in r.storage_logs.iter().enumerate() { + storage_logs.push( + SnapshotStorageLog::read(storage_log) + .with_context(|| format!("storage_log[{i}]"))?, + ) + } + Ok(Self { storage_logs }) + } + + fn build(&self) -> Self::Proto { + Self::Proto { + storage_logs: self + .storage_logs + .iter() + .map(SnapshotStorageLog::build) + .collect(), + } + } } diff --git a/core/lib/types/src/system_contracts.rs b/core/lib/types/src/system_contracts.rs index 7e896b83bc22..7cd4107ad41e 100644 --- a/core/lib/types/src/system_contracts.rs +++ b/core/lib/types/src/system_contracts.rs @@ -10,8 +10,9 @@ use zksync_system_constants::{ use crate::{ block::DeployedContract, ACCOUNT_CODE_STORAGE_ADDRESS, BOOTLOADER_ADDRESS, COMPLEX_UPGRADER_ADDRESS, CONTRACT_DEPLOYER_ADDRESS, ECRECOVER_PRECOMPILE_ADDRESS, - IMMUTABLE_SIMULATOR_STORAGE_ADDRESS, KECCAK256_PRECOMPILE_ADDRESS, KNOWN_CODES_STORAGE_ADDRESS, - L1_MESSENGER_ADDRESS, L2_ETH_TOKEN_ADDRESS, MSG_VALUE_SIMULATOR_ADDRESS, NONCE_HOLDER_ADDRESS, + EC_ADD_PRECOMPILE_ADDRESS, EC_MUL_PRECOMPILE_ADDRESS, IMMUTABLE_SIMULATOR_STORAGE_ADDRESS, + KECCAK256_PRECOMPILE_ADDRESS, KNOWN_CODES_STORAGE_ADDRESS, L1_MESSENGER_ADDRESS, + L2_ETH_TOKEN_ADDRESS, MSG_VALUE_SIMULATOR_ADDRESS, NONCE_HOLDER_ADDRESS, SHA256_PRECOMPILE_ADDRESS, SYSTEM_CONTEXT_ADDRESS, }; @@ -23,7 +24,7 @@ use crate::{ pub const TX_NONCE_INCREMENT: U256 = U256([1, 0, 0, 0]); // 1 pub const DEPLOYMENT_NONCE_INCREMENT: U256 = U256([0, 0, 1, 0]); // 2^128 -static SYSTEM_CONTRACT_LIST: [(&str, &str, Address, ContractLanguage); 18] = [ +static SYSTEM_CONTRACT_LIST: [(&str, &str, Address, ContractLanguage); 20] = [ ( "", "AccountCodeStorage", @@ -90,6 +91,18 @@ static SYSTEM_CONTRACT_LIST: [(&str, &str, Address, ContractLanguage); 18] = [ ECRECOVER_PRECOMPILE_ADDRESS, ContractLanguage::Yul, ), + ( + "precompiles/", + "EcAdd", + EC_ADD_PRECOMPILE_ADDRESS, + ContractLanguage::Yul, + ), + ( + "precompiles/", + "EcMul", + EC_MUL_PRECOMPILE_ADDRESS, + ContractLanguage::Yul, + ), ( "", "SystemContext", diff --git a/core/lib/utils/src/misc.rs b/core/lib/utils/src/misc.rs index 887413a6f45e..94f7a9adc09d 100644 --- a/core/lib/utils/src/misc.rs +++ b/core/lib/utils/src/misc.rs @@ -26,7 +26,7 @@ pub fn expand_memory_contents(packed: &[(usize, U256)], memory_size_bytes: usize value.to_big_endian(&mut result[(offset * 32)..(offset + 1) * 32]); } - result.to_vec() + result } #[cfg(test)] diff --git a/core/lib/zksync_core/src/eth_sender/aggregator.rs b/core/lib/zksync_core/src/eth_sender/aggregator.rs index cd8a057974a2..0f9fa54a157b 100644 --- a/core/lib/zksync_core/src/eth_sender/aggregator.rs +++ b/core/lib/zksync_core/src/eth_sender/aggregator.rs @@ -94,7 +94,6 @@ impl Aggregator { pub async fn get_next_ready_operation( &mut self, storage: &mut StorageProcessor<'_>, - prover_storage: &mut StorageProcessor<'_>, base_system_contracts_hashes: BaseSystemContractsHashes, protocol_version_id: ProtocolVersionId, l1_verifier_config: L1VerifierConfig, @@ -116,7 +115,6 @@ impl Aggregator { } else if let Some(op) = self .get_proof_operation( storage, - prover_storage, *self.config.aggregated_proof_sizes.iter().max().unwrap(), last_sealed_l1_batch_number, l1_verifier_config, @@ -229,7 +227,6 @@ impl Aggregator { async fn load_real_proof_operation( storage: &mut StorageProcessor<'_>, - prover_storage: &mut StorageProcessor<'_>, l1_verifier_config: L1VerifierConfig, proof_loading_mode: &ProofLoadingMode, blob_store: &dyn ObjectStore, @@ -265,10 +262,7 @@ impl Aggregator { } let proofs = match proof_loading_mode { ProofLoadingMode::OldProofFromDb => { - prover_storage - .prover_dal() - .get_final_proofs_for_blocks(batch_to_prove, batch_to_prove) - .await + unreachable!("OldProofFromDb is not supported anymore") } ProofLoadingMode::FriProofFromGcs => { load_wrapped_fri_proofs_for_range(batch_to_prove, batch_to_prove, blob_store).await @@ -344,7 +338,6 @@ impl Aggregator { async fn get_proof_operation( &mut self, storage: &mut StorageProcessor<'_>, - prover_storage: &mut StorageProcessor<'_>, limit: usize, last_sealed_l1_batch: L1BatchNumber, l1_verifier_config: L1VerifierConfig, @@ -353,7 +346,6 @@ impl Aggregator { ProofSendingMode::OnlyRealProofs => { Self::load_real_proof_operation( storage, - prover_storage, l1_verifier_config, &self.config.proof_loading_mode, &*self.blob_store, @@ -379,7 +371,6 @@ impl Aggregator { // if there is a sampled proof then send it, otherwise check for skipped ones. if let Some(op) = Self::load_real_proof_operation( storage, - prover_storage, l1_verifier_config, &self.config.proof_loading_mode, &*self.blob_store, diff --git a/core/lib/zksync_core/src/eth_sender/eth_tx_aggregator.rs b/core/lib/zksync_core/src/eth_sender/eth_tx_aggregator.rs index 43b1e51da10d..49ba4129dfc5 100644 --- a/core/lib/zksync_core/src/eth_sender/eth_tx_aggregator.rs +++ b/core/lib/zksync_core/src/eth_sender/eth_tx_aggregator.rs @@ -73,26 +73,18 @@ impl EthTxAggregator { pub async fn run( mut self, pool: ConnectionPool, - prover_pool: ConnectionPool, eth_client: E, stop_receiver: watch::Receiver, ) -> anyhow::Result<()> { loop { let mut storage = pool.access_storage_tagged("eth_sender").await.unwrap(); - let mut prover_storage = prover_pool - .access_storage_tagged("eth_sender") - .await - .unwrap(); if *stop_receiver.borrow() { tracing::info!("Stop signal received, eth_tx_aggregator is shutting down"); break; } - if let Err(err) = self - .loop_iteration(&mut storage, &mut prover_storage, ð_client) - .await - { + if let Err(err) = self.loop_iteration(&mut storage, ð_client).await { // Web3 API request failures can cause this, // and anything more important is already properly reported. tracing::warn!("eth_sender error {err:?}"); @@ -355,7 +347,6 @@ impl EthTxAggregator { async fn loop_iteration( &mut self, storage: &mut StorageProcessor<'_>, - prover_storage: &mut StorageProcessor<'_>, eth_client: &E, ) -> Result<(), ETHSenderError> { let MulticallData { @@ -388,7 +379,6 @@ impl EthTxAggregator { .aggregator .get_next_ready_operation( storage, - prover_storage, base_system_contracts_hashes, protocol_version_id, l1_verifier_config, diff --git a/core/lib/zksync_core/src/house_keeper/blocks_state_reporter.rs b/core/lib/zksync_core/src/house_keeper/blocks_state_reporter.rs index 190764ec57d8..91c4a80b047c 100644 --- a/core/lib/zksync_core/src/house_keeper/blocks_state_reporter.rs +++ b/core/lib/zksync_core/src/house_keeper/blocks_state_reporter.rs @@ -36,13 +36,6 @@ impl L1BatchMetricsReporter { .unwrap(), BlockStage::MetadataCalculated, ), - ( - conn.blocks_dal() - .get_last_l1_batch_number_with_witness_inputs() - .await - .unwrap(), - BlockStage::MerkleProofCalculated, - ), ]; let eth_stats = conn.eth_sender_dal().get_eth_l1_batches().await.unwrap(); diff --git a/core/lib/zksync_core/src/lib.rs b/core/lib/zksync_core/src/lib.rs index 8e02098dd591..ba58f4f0df71 100644 --- a/core/lib/zksync_core/src/lib.rs +++ b/core/lib/zksync_core/src/lib.rs @@ -555,10 +555,6 @@ pub async fn initialize_components( .build() .await .context("failed to build eth_sender_pool")?; - let eth_sender_prover_pool = ConnectionPool::singleton(postgres_config.prover_url()?) - .build() - .await - .context("failed to build eth_sender_prover_pool")?; let eth_sender = configs .eth_sender_config @@ -590,7 +586,6 @@ pub async fn initialize_components( ); task_futures.push(tokio::spawn(eth_tx_aggregator_actor.run( eth_sender_pool, - eth_sender_prover_pool, eth_client, stop_receiver.clone(), ))); diff --git a/core/lib/zksync_core/src/metrics.rs b/core/lib/zksync_core/src/metrics.rs index 8a6fd30a8197..b55c8c8f065f 100644 --- a/core/lib/zksync_core/src/metrics.rs +++ b/core/lib/zksync_core/src/metrics.rs @@ -59,7 +59,6 @@ pub(crate) enum BlockStage { Sealed, Tree, MetadataCalculated, - MerkleProofCalculated, L1 { l1_stage: BlockL1Stage, tx_type: AggregatedActionType, @@ -72,7 +71,6 @@ impl fmt::Display for BlockStage { Self::Sealed => formatter.write_str("sealed"), Self::Tree => formatter.write_str("tree"), Self::MetadataCalculated => formatter.write_str("metadata_calculated"), - Self::MerkleProofCalculated => formatter.write_str("merkle_proof_calculated"), Self::L1 { l1_stage, tx_type } => { let l1_stage = match l1_stage { BlockL1Stage::Saved => "save", // not "saved" for backward compatibility diff --git a/core/lib/zksync_core/src/sync_layer/fetcher.rs b/core/lib/zksync_core/src/sync_layer/fetcher.rs index 4321a5d35335..a60e1c0f2e85 100644 --- a/core/lib/zksync_core/src/sync_layer/fetcher.rs +++ b/core/lib/zksync_core/src/sync_layer/fetcher.rs @@ -130,10 +130,15 @@ impl FetcherCursor { assert_eq!(block.number, self.next_miniblock); let local_block_hash = block.compute_hash(self.prev_miniblock_hash); if let Some(reference_hash) = block.reference_hash { - assert_eq!( - local_block_hash, reference_hash, - "Mismatch between the locally computed and received miniblock hash for {block:?}" - ); + if local_block_hash != reference_hash { + // This is a warning, not an assertion because hash mismatch may occur after a reorg. + // Indeed, `self.prev_miniblock_hash` may differ from the hash of the updated previous miniblock. + tracing::warn!( + "Mismatch between the locally computed and received miniblock hash for {block:?}; \ + local_block_hash = {local_block_hash:?}, prev_miniblock_hash = {:?}", + self.prev_miniblock_hash + ); + } } let mut new_actions = Vec::new(); diff --git a/core/tests/ts-integration/tests/api/snapshots-creator.test.ts b/core/tests/ts-integration/tests/api/snapshots-creator.test.ts index 1938a53e80a5..63d55a3d8a9b 100644 --- a/core/tests/ts-integration/tests/api/snapshots-creator.test.ts +++ b/core/tests/ts-integration/tests/api/snapshots-creator.test.ts @@ -1,7 +1,9 @@ import { TestMaster } from '../../src/index'; import fs from 'fs'; import * as zlib from 'zlib'; +import * as protobuf from 'protobufjs'; import { snapshots_creator } from 'zk/build/run/run'; +import path from 'path'; describe('Snapshots API tests', () => { let testMaster: TestMaster; @@ -15,13 +17,11 @@ describe('Snapshots API tests', () => { }); async function runCreator() { - console.log('Starting creator'); await snapshots_creator(); } async function rpcRequest(name: string, params: any) { const response = await testMaster.mainAccount().provider.send(name, params); - console.log(response); return response; } @@ -33,14 +33,14 @@ describe('Snapshots API tests', () => { return rpcRequest('snapshots_getSnapshot', [snapshotL1Batch]); } - async function decompressGzip(filePath: string): Promise { + async function decompressGzip(filePath: string): Promise { return new Promise((resolve, reject) => { const readStream = fs.createReadStream(filePath); const gunzip = zlib.createGunzip(); - let data = ''; + let chunks: Uint8Array[] = []; - gunzip.on('data', (chunk) => (data += chunk.toString())); - gunzip.on('end', () => resolve(data)); + gunzip.on('data', (chunk) => chunks.push(chunk)); + gunzip.on('end', () => resolve(Buffer.concat(chunks))); gunzip.on('error', reject); readStream.pipe(gunzip); @@ -57,18 +57,19 @@ describe('Snapshots API tests', () => { const fullSnapshot = await getSnapshot(l1BatchNumber); const miniblockNumber = fullSnapshot.miniblockNumber; + const protoPath = path.join(process.env.ZKSYNC_HOME as string, 'core/lib/types/src/proto/mod.proto'); + const root = await protobuf.load(protoPath); + const SnapshotStorageLogsChunk = root.lookupType('zksync.types.SnapshotStorageLogsChunk'); + expect(fullSnapshot.l1BatchNumber).toEqual(l1BatchNumber); for (let chunkMetadata of fullSnapshot.storageLogsChunks) { - console.log(`Verifying ${chunkMetadata.filepath}`); - let path = `${process.env.ZKSYNC_HOME}/${chunkMetadata.filepath}`; - - let output = JSON.parse(await decompressGzip(path)); + const chunkPath = path.join(process.env.ZKSYNC_HOME as string, chunkMetadata.filepath); + const output = SnapshotStorageLogsChunk.decode(await decompressGzip(chunkPath)) as any; expect(output['storageLogs'].length > 0); - for (const storageLog of output['storageLogs'] as any[]) { - const snapshotAccountAddress = storageLog['key']['account']['address']; - const snapshotKey = storageLog['key']['key']; - const snapshotValue = storageLog['value']; + const snapshotAccountAddress = '0x' + storageLog['accountAddress'].toString('hex'); + const snapshotKey = '0x' + storageLog['storageKey'].toString('hex'); + const snapshotValue = '0x' + storageLog['storageValue'].toString('hex'); const snapshotL1BatchNumber = storageLog['l1BatchNumberOfInitialWrite']; const valueOnBlockchain = await testMaster .mainAccount() diff --git a/docker/snapshots-creator/Dockerfile b/docker/snapshots-creator/Dockerfile new file mode 100644 index 000000000000..897f28f87800 --- /dev/null +++ b/docker/snapshots-creator/Dockerfile @@ -0,0 +1,28 @@ +# syntax=docker/dockerfile:experimental +FROM debian:bookworm-slim as builder + +WORKDIR /usr/src/zksync +COPY . . + +RUN apt-get update && apt-get install -y curl clang openssl libssl-dev gcc g++ \ + pkg-config build-essential libclang-dev linux-libc-dev liburing-dev && \ + rm -rf /var/lib/apt/lists/* + +ENV RUSTUP_HOME=/usr/local/rustup \ + CARGO_HOME=/usr/local/cargo \ + PATH=/usr/local/cargo/bin:$PATH + +RUN curl https://sh.rustup.rs -sSf | bash -s -- -y && \ + rustup install nightly-2023-08-21 && \ + rustup default nightly-2023-08-21 + +RUN cargo build --release --bin snapshots_creator + +FROM debian:bookworm-slim + +RUN apt-get update && apt-get install -y curl libpq5 liburing-dev ca-certificates && \ + rm -rf /var/lib/apt/lists/* + +COPY --from=builder /usr/src/zksync/target/release/snapshots_creator /usr/bin + +ENTRYPOINT ["snapshots_creator"] diff --git a/infrastructure/zk/package.json b/infrastructure/zk/package.json index 2240c96a2b72..7e2f70d82cba 100644 --- a/infrastructure/zk/package.json +++ b/infrastructure/zk/package.json @@ -20,7 +20,8 @@ "node-fetch": "^2.6.1", "pg": "^8.11.3", "tabtab": "^3.0.2", - "zksync-web3": "^0.15.5" + "zksync-web3": "^0.15.5", + "protobufjs": "^7.2.5" }, "devDependencies": { "@matterlabs/hardhat-zksync-solc": "^0.3.15", @@ -32,4 +33,4 @@ "hardhat": "=2.16.0", "typescript": "^4.3.5" } -} \ No newline at end of file +} diff --git a/infrastructure/zk/src/docker.ts b/infrastructure/zk/src/docker.ts index dbb598da3106..c0c45c918a50 100644 --- a/infrastructure/zk/src/docker.ts +++ b/infrastructure/zk/src/docker.ts @@ -17,7 +17,8 @@ const IMAGES = [ 'prover-gpu-fri', 'witness-vector-generator', 'prover-fri-gateway', - 'proof-fri-compressor' + 'proof-fri-compressor', + 'snapshots-creator' ]; const UNIX_TIMESTAMP = Date.now(); @@ -78,7 +79,8 @@ function defaultTagList(image: string, imageTagSha: string, imageTagShaTS: strin 'prover-gpu-fri', 'witness-vector-generator', 'prover-fri-gateway', - 'proof-fri-compressor' + 'proof-fri-compressor', + 'snapshots-creator' ].includes(image) ? ['latest', 'latest2.0', `2.0-${imageTagSha}`, `${imageTagSha}`, `2.0-${imageTagShaTS}`, `${imageTagShaTS}`] : [`latest2.0`, 'latest']; diff --git a/infrastructure/zk/src/fmt.ts b/infrastructure/zk/src/fmt.ts index 896ef28dbbd8..0ecb5542547c 100644 --- a/infrastructure/zk/src/fmt.ts +++ b/infrastructure/zk/src/fmt.ts @@ -1,5 +1,6 @@ import { Command } from 'commander'; import * as utils from './utils'; +import { formatSqlxQueries } from './format_sql'; const EXTENSIONS = ['ts', 'md', 'sol', 'js']; const CONFIG_PATH = 'etc/prettier-config'; @@ -61,6 +62,12 @@ export async function rustfmt(check: boolean = false) { await utils.spawn(command); } +export async function runAllRustFormatters(check: boolean = false) { + // we need to run those two steps one by one as they operate on the same set of files + await formatSqlxQueries(check); + await rustfmt(check); +} + const ARGS = [...EXTENSIONS, 'rust', 'l1-contracts', 'l2-contracts', 'system-contracts']; export const command = new Command('fmt') @@ -71,7 +78,7 @@ export const command = new Command('fmt') if (extension) { switch (extension) { case 'rust': - await rustfmt(cmd.check); + await runAllRustFormatters(cmd.check); break; case 'l1-contracts': await prettierL1Contracts(cmd.check); @@ -89,7 +96,7 @@ export const command = new Command('fmt') } else { // Run all the checks concurrently. const promises = EXTENSIONS.map((ext) => prettier(ext, cmd.check)); - promises.push(rustfmt(cmd.check)); + promises.push(runAllRustFormatters(cmd.check)); promises.push(prettierL1Contracts(cmd.check)); promises.push(prettierL2Contracts(cmd.check)); promises.push(prettierSystemContracts(cmd.check)); @@ -115,5 +122,5 @@ command .command('rustfmt') .option('--check') .action(async (cmd: Command) => { - await rustfmt(cmd.check); + await runAllRustFormatters(cmd.check); }); diff --git a/infrastructure/zk/src/format_sql.ts b/infrastructure/zk/src/format_sql.ts new file mode 100644 index 000000000000..5753b44218c0 --- /dev/null +++ b/infrastructure/zk/src/format_sql.ts @@ -0,0 +1,170 @@ +import * as fs from 'fs'; +import * as utils from './utils'; +import { format } from 'sql-formatter'; + +function formatQuery(query: string) { + let formattedQuery = query; + try { + formattedQuery = format(query, { + language: 'postgresql', + tabWidth: 4, + keywordCase: 'upper', + expressionWidth: 80, + indentStyle: 'standard' + }); + } catch { + console.error(`Unable to format:\n${query}\n`); + } + + // sql-formatter is not smart enough to identify whether something is used as a keyword or a column name + const keywordToLower = ['STORAGE', 'TIMESTAMP', 'INPUT', 'DATA', 'ZONE', 'VALUE', 'DEPTH', 'KEY']; + for (const keyword of keywordToLower) { + // we replace keyword but only if it's not part of a longer word + formattedQuery = formattedQuery.replace(RegExp(`\\b${keyword}\\b`, 'g'), keyword.toLowerCase()); + } + + const formattedLines = formattedQuery.split('\n'); + + const minIndent = Math.min(...formattedLines.map((line) => line.search(/\S/))); + formattedQuery = formattedQuery + .split('\n') + .map((line) => line.slice(minIndent)) + .join('\n'); + + return formattedQuery; +} + +function extractQueryFromRustString(query: string): string { + query = query.trim(); + if (query.endsWith(',')) { + query = query.slice(0, query.length - 1); + } + //removing quotes + if (!query.startsWith('r#')) { + query = query.slice(1, query.length - 1); + } else { + query = query.slice(3, query.length - 2); + } + + //getting rid of all "\" characters, both from escapes and line breaks + query = query.replace(/\\/g, ''); + + return query; +} + +function embedTextInsideRustString(query: string) { + return 'r#"\n' + query + '\n"#'; +} + +function addIndent(query: string, indent: number) { + return query + .split('\n') + .map((line) => ' '.repeat(indent) + line) + .join('\n'); +} + +function formatRustStringQuery(query: string) { + const baseIndent = query.search(/\S/); + const rawQuery = extractQueryFromRustString(query); + const formattedQuery = formatQuery(rawQuery); + const reconstructedRustString = embedTextInsideRustString(formattedQuery); + + return addIndent(reconstructedRustString, baseIndent); +} + +function formatOneLineQuery(line: string): string { + const isRawString = line.includes('sqlx::query!(r'); + const queryStart = isRawString ? line.indexOf('r#"') : line.indexOf('"'); + const baseIndent = line.search(/\S/) + 4; + const prefix = line.slice(0, queryStart); + line = line.slice(queryStart); + const queryEnd = isRawString ? line.indexOf('"#') + 2 : line.slice(1).search(/(^|[^\\])"/) + 3; + const suffix = line.slice(queryEnd); + const query = line.slice(0, queryEnd); + let formattedQuery = formatRustStringQuery(query); + formattedQuery = addIndent(formattedQuery, baseIndent); + + return prefix + '\n' + formattedQuery + '\n' + suffix; +} +async function formatFile(filePath: string, check: boolean) { + const content = await fs.promises.readFile(filePath, { encoding: 'utf-8' }); + let linesToQuery = null; + let isInsideQuery = false; + let isRawString = false; + let builtQuery = ''; + + let modifiedFile = ''; + for (const line of content.split('\n')) { + if (line.includes('sqlx::query!("') || line.includes('sqlx::query!(r')) { + modifiedFile += formatOneLineQuery(line) + '\n'; + continue; + } + + if (line.endsWith('sqlx::query!(')) { + linesToQuery = 1; + isRawString = false; + builtQuery = ''; + } + if (line.endsWith('sqlx::query_as!(')) { + linesToQuery = 2; + isRawString = false; + builtQuery = ''; + } + + if (linesToQuery !== null) { + if (linesToQuery === 0) { + isInsideQuery = true; + linesToQuery = null; + if (line.includes('r#"')) { + isRawString = true; + } + } else { + linesToQuery -= 1; + } + } + + if (isInsideQuery) { + const queryNotEmpty = builtQuery || line.trim().length > 1; + const rawStringQueryEnded = line.endsWith('"#,') || line.endsWith('"#'); + const regularStringQueryEnded = (line.endsWith('",') || line.endsWith('"')) && queryNotEmpty; + builtQuery += line + '\n'; + const lineEndIsNotEscape = !line.endsWith('\\"') && !line.endsWith('\\",'); + if ( + (isRawString && rawStringQueryEnded) || + (!isRawString && regularStringQueryEnded && lineEndIsNotEscape) + ) { + isInsideQuery = false; + let endedWithComma = builtQuery.trimEnd().endsWith(','); + modifiedFile += formatRustStringQuery(builtQuery).trimEnd(); + modifiedFile += endedWithComma ? ',' : ''; + modifiedFile += '\n'; + } + } else { + modifiedFile += line + '\n'; + } + } + modifiedFile = modifiedFile.slice(0, modifiedFile.length - 1); + + if (!check) { + await fs.promises.writeFile(filePath, modifiedFile); + } else { + if (content !== modifiedFile) { + console.warn(`Sqlx query format issues found in ${filePath}.`); + } + } + return content === modifiedFile; +} + +export async function formatSqlxQueries(check: boolean) { + process.chdir(`${process.env.ZKSYNC_HOME}`); + const { stdout: filesRaw } = await utils.exec('find core/lib/dal -type f -name "*.rs"'); + const files = filesRaw.trim().split('\n'); + const formatResults = await Promise.all(files.map((file) => formatFile(file, check))); + if (check) { + if (!formatResults.includes(false)) { + console.log('All files contain correctly formatted sqlx queries!'); + } else { + throw new Error('Some files contain incorrectly formatted sql queries'); + } + } +} diff --git a/package.json b/package.json index f256abbc4c66..929d1fced007 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,7 @@ "npm-run-all": "^4.1.5", "prettier": "^2.3.2", "prettier-plugin-solidity": "=1.0.0-dev.22", - "solhint": "^3.3.2" + "solhint": "^3.3.2", + "sql-formatter": "^13.1.0" } } diff --git a/yarn.lock b/yarn.lock index f4966b9c5237..c5a31df28224 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2103,6 +2103,59 @@ picocolors "^1.0.0" tslib "^2.6.0" +"@protobufjs/aspromise@^1.1.1", "@protobufjs/aspromise@^1.1.2": + version "1.1.2" + resolved "https://registry.yarnpkg.com/@protobufjs/aspromise/-/aspromise-1.1.2.tgz#9b8b0cc663d669a7d8f6f5d0893a14d348f30fbf" + integrity sha512-j+gKExEuLmKwvz3OgROXtrJ2UG2x8Ch2YZUxahh+s1F2HZ+wAceUNLkvy6zKCPVRkU++ZWQrdxsUeQXmcg4uoQ== + +"@protobufjs/base64@^1.1.2": + version "1.1.2" + resolved "https://registry.yarnpkg.com/@protobufjs/base64/-/base64-1.1.2.tgz#4c85730e59b9a1f1f349047dbf24296034bb2735" + integrity sha512-AZkcAA5vnN/v4PDqKyMR5lx7hZttPDgClv83E//FMNhR2TMcLUhfRUBHCmSl0oi9zMgDDqRUJkSxO3wm85+XLg== + +"@protobufjs/codegen@^2.0.4": + version "2.0.4" + resolved "https://registry.yarnpkg.com/@protobufjs/codegen/-/codegen-2.0.4.tgz#7ef37f0d010fb028ad1ad59722e506d9262815cb" + integrity sha512-YyFaikqM5sH0ziFZCN3xDC7zeGaB/d0IUb9CATugHWbd1FRFwWwt4ld4OYMPWu5a3Xe01mGAULCdqhMlPl29Jg== + +"@protobufjs/eventemitter@^1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@protobufjs/eventemitter/-/eventemitter-1.1.0.tgz#355cbc98bafad5978f9ed095f397621f1d066b70" + integrity sha512-j9ednRT81vYJ9OfVuXG6ERSTdEL1xVsNgqpkxMsbIabzSo3goCjDIveeGv5d03om39ML71RdmrGNjG5SReBP/Q== + +"@protobufjs/fetch@^1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@protobufjs/fetch/-/fetch-1.1.0.tgz#ba99fb598614af65700c1619ff06d454b0d84c45" + integrity sha512-lljVXpqXebpsijW71PZaCYeIcE5on1w5DlQy5WH6GLbFryLUrBD4932W/E2BSpfRJWseIL4v/KPgBFxDOIdKpQ== + dependencies: + "@protobufjs/aspromise" "^1.1.1" + "@protobufjs/inquire" "^1.1.0" + +"@protobufjs/float@^1.0.2": + version "1.0.2" + resolved "https://registry.yarnpkg.com/@protobufjs/float/-/float-1.0.2.tgz#5e9e1abdcb73fc0a7cb8b291df78c8cbd97b87d1" + integrity sha512-Ddb+kVXlXst9d+R9PfTIxh1EdNkgoRe5tOX6t01f1lYWOvJnSPDBlG241QLzcyPdoNTsblLUdujGSE4RzrTZGQ== + +"@protobufjs/inquire@^1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@protobufjs/inquire/-/inquire-1.1.0.tgz#ff200e3e7cf2429e2dcafc1140828e8cc638f089" + integrity sha512-kdSefcPdruJiFMVSbn801t4vFK7KB/5gd2fYvrxhuJYg8ILrmn9SKSX2tZdV6V+ksulWqS7aXjBcRXl3wHoD9Q== + +"@protobufjs/path@^1.1.2": + version "1.1.2" + resolved "https://registry.yarnpkg.com/@protobufjs/path/-/path-1.1.2.tgz#6cc2b20c5c9ad6ad0dccfd21ca7673d8d7fbf68d" + integrity sha512-6JOcJ5Tm08dOHAbdR3GrvP+yUUfkjG5ePsHYczMFLq3ZmMkAD98cDgcT2iA1lJ9NVwFd4tH/iSSoe44YWkltEA== + +"@protobufjs/pool@^1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@protobufjs/pool/-/pool-1.1.0.tgz#09fd15f2d6d3abfa9b65bc366506d6ad7846ff54" + integrity sha512-0kELaGSIDBKvcgS4zkjz1PeddatrjYcmMWOlAuAPwAeccUrPHdUqo/J6LiymHHEiJT5NrF1UVwxY14f+fy4WQw== + +"@protobufjs/utf8@^1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@protobufjs/utf8/-/utf8-1.1.0.tgz#a777360b5b39a1a2e5106f8e858f2fd2d060c570" + integrity sha512-Vvn3zZrhQZkkBE8LSuW3em98c0FwgO4nxzv6OdSxPKJIEKY2bGbHn+mhGIPerzI4twdxaP8/0+06HBpwf345Lw== + "@resolver-engine/core@^0.3.3": version "0.3.3" resolved "https://registry.yarnpkg.com/@resolver-engine/core/-/core-0.3.3.tgz#590f77d85d45bc7ecc4e06c654f41345db6ca967" @@ -2572,6 +2625,13 @@ dependencies: undici-types "~5.26.4" +"@types/node@>=13.7.0": + version "20.10.4" + resolved "https://registry.yarnpkg.com/@types/node/-/node-20.10.4.tgz#b246fd84d55d5b1b71bf51f964bd514409347198" + integrity sha512-D08YG6rr8X90YB56tSIuBaddy/UXAA9RKJoFvrsnogAum/0pmjkgi4+2nx96A330FmioegBWmEYQ+syqCFaveg== + dependencies: + undici-types "~5.26.4" + "@types/node@^10.0.3": version "10.17.60" resolved "https://registry.yarnpkg.com/@types/node/-/node-10.17.60.tgz#35f3d6213daed95da7f0f73e75bcc6980e90597b" @@ -5408,6 +5468,11 @@ dir-glob@^3.0.1: dependencies: path-type "^4.0.0" +discontinuous-range@1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/discontinuous-range/-/discontinuous-range-1.0.0.tgz#e38331f0844bba49b9a9cb71c771585aab1bc65a" + integrity sha512-c68LpLbO+7kP/b1Hr1qs8/BJ09F5khZGTxqxZuhzxpmwJKOgRFHJWIb9/KmqnqHhLdO55aOxFH/EGBvUQbL/RQ== + docker-modem@^1.0.8: version "1.0.9" resolved "https://registry.yarnpkg.com/docker-modem/-/docker-modem-1.0.9.tgz#a1f13e50e6afb6cf3431b2d5e7aac589db6aaba8" @@ -7258,6 +7323,11 @@ get-port@^3.1.0: resolved "https://registry.yarnpkg.com/get-port/-/get-port-3.2.0.tgz#dd7ce7de187c06c8bf353796ac71e099f0980ebc" integrity sha512-x5UJKlgeUiNT8nyo/AcnwLnZuZNcSjSw0kogRB+Whd1fjjFq4B1hySFxSFWWSn4mIBzg3sRNUDFYc4g5gjPoLg== +get-stdin@=8.0.0: + version "8.0.0" + resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-8.0.0.tgz#cbad6a73feb75f6eeb22ba9e01f89aa28aa97a53" + integrity sha512-sY22aA6xchAzprjyqmSEQv4UbAAzRN0L2dQB0NlN5acTTK9Don6nhoc3eAbUnpZiCANAMfd/+40kVdKfFygohg== + get-stdin@~5.0.1: version "5.0.1" resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-5.0.1.tgz#122e161591e21ff4c52530305693f20e6393a398" @@ -9557,6 +9627,11 @@ log-symbols@4.1.0: chalk "^4.1.0" is-unicode-supported "^0.1.0" +long@^5.0.0: + version "5.2.3" + resolved "https://registry.yarnpkg.com/long/-/long-5.2.3.tgz#a3ba97f3877cf1d778eccbcb048525ebb77499e1" + integrity sha512-lcHwpNoggQTObv5apGNCTdJrO69eHOZMi4BNC+rTLER8iHAqGrUVeLh/irVIM7zTw2bOXA8T6uNPeujwOLg/2Q== + looper@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/looper/-/looper-2.0.0.tgz#66cd0c774af3d4fedac53794f742db56da8f09ec" @@ -10153,6 +10228,11 @@ module-error@^1.0.1, module-error@^1.0.2: resolved "https://registry.yarnpkg.com/module-error/-/module-error-1.0.2.tgz#8d1a48897ca883f47a45816d4fb3e3c6ba404d86" integrity sha512-0yuvsqSCv8LbaOKhnsQ/T5JhyFlCYLPXK3U2sgV10zoKQwzs/MyfuQUOZQ1V/6OCOJsK/TRgNVrPuPDqtdMFtA== +moo@^0.5.0: + version "0.5.2" + resolved "https://registry.yarnpkg.com/moo/-/moo-0.5.2.tgz#f9fe82473bc7c184b0d32e2215d3f6e67278733c" + integrity sha512-iSAJLHYKnX41mKcJKjqvnAN9sf0LMDTXDEvFv+ffuRR9a1MIuXLjMNL6EsnDHSkKLTWNqQQ5uo61P4EbU4NU+Q== + ms@2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" @@ -10269,6 +10349,16 @@ natural-compare@^1.4.0: resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7" integrity sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw== +nearley@^2.20.1: + version "2.20.1" + resolved "https://registry.yarnpkg.com/nearley/-/nearley-2.20.1.tgz#246cd33eff0d012faf197ff6774d7ac78acdd474" + integrity sha512-+Mc8UaAebFzgV+KpI5n7DasuuQCHA89dmwm7JXw3TV43ukfNQ9DnBH3Mdb2g/I4Fdxc26pwimBWvjIw0UAILSQ== + dependencies: + commander "^2.19.0" + moo "^0.5.0" + railroad-diagrams "^1.0.0" + randexp "0.4.6" + negotiator@0.6.3: version "0.6.3" resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.3.tgz#58e323a72fedc0d6f9cd4d31fe49f51479590ccd" @@ -11245,6 +11335,24 @@ proper-lockfile@^4.1.2: retry "^0.12.0" signal-exit "^3.0.2" +protobufjs@^7.2.5: + version "7.2.5" + resolved "https://registry.yarnpkg.com/protobufjs/-/protobufjs-7.2.5.tgz#45d5c57387a6d29a17aab6846dcc283f9b8e7f2d" + integrity sha512-gGXRSXvxQ7UiPgfw8gevrfRWcTlSbOFg+p/N+JVJEK5VhueL2miT6qTymqAmjr1Q5WbOCyJbyrk6JfWKwlFn6A== + dependencies: + "@protobufjs/aspromise" "^1.1.2" + "@protobufjs/base64" "^1.1.2" + "@protobufjs/codegen" "^2.0.4" + "@protobufjs/eventemitter" "^1.1.0" + "@protobufjs/fetch" "^1.1.0" + "@protobufjs/float" "^1.0.2" + "@protobufjs/inquire" "^1.1.0" + "@protobufjs/path" "^1.1.2" + "@protobufjs/pool" "^1.1.0" + "@protobufjs/utf8" "^1.1.0" + "@types/node" ">=13.7.0" + long "^5.0.0" + proxy-addr@~2.0.7: version "2.0.7" resolved "https://registry.yarnpkg.com/proxy-addr/-/proxy-addr-2.0.7.tgz#f19fe69ceab311eeb94b42e70e8c2070f9ba1025" @@ -11412,6 +11520,19 @@ quick-lru@^5.1.1: resolved "https://registry.yarnpkg.com/quick-lru/-/quick-lru-5.1.1.tgz#366493e6b3e42a3a6885e2e99d18f80fb7a8c932" integrity sha512-WuyALRjWPDGtt/wzJiadO5AXY+8hZ80hVpe6MyivgraREW751X3SbhRvG3eLKOYN+8VEvqLcf3wdnt44Z4S4SA== +railroad-diagrams@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/railroad-diagrams/-/railroad-diagrams-1.0.0.tgz#eb7e6267548ddedfb899c1b90e57374559cddb7e" + integrity sha512-cz93DjNeLY0idrCNOH6PviZGRN9GJhsdm9hpn1YCS879fj4W+x5IFJhhkRZcwVgMmFF7R82UA/7Oh+R8lLZg6A== + +randexp@0.4.6: + version "0.4.6" + resolved "https://registry.yarnpkg.com/randexp/-/randexp-0.4.6.tgz#e986ad5e5e31dae13ddd6f7b3019aa7c87f60ca3" + integrity sha512-80WNmd9DA0tmZrw9qQa62GPPWfuXJknrmVmLcxvq4uZBdYqb1wYoKTmnlGUchvVWe0XiLupYkBoXVOxz3C8DYQ== + dependencies: + discontinuous-range "1.0.0" + ret "~0.1.10" + randombytes@^2.0.0, randombytes@^2.0.1, randombytes@^2.0.5, randombytes@^2.0.6, randombytes@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/randombytes/-/randombytes-2.1.0.tgz#df6f84372f0270dc65cdf6291349ab7a473d4f2a" @@ -12471,6 +12592,15 @@ sprintf-js@~1.0.2: resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" integrity sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g== +sql-formatter@^13.1.0: + version "13.1.0" + resolved "https://registry.yarnpkg.com/sql-formatter/-/sql-formatter-13.1.0.tgz#272cccd9b249daee601e791cb12eb3c93edfd626" + integrity sha512-/nZQXuN7KzipFNM20ko+dHY4kOr9rymSfZLUDED8rhx3m8OK5y74jcyN+y1L51ZqHqiB0kp40VdpZP99uWvQdA== + dependencies: + argparse "^2.0.1" + get-stdin "=8.0.0" + nearley "^2.20.1" + ssh2@^1.11.0: version "1.14.0" resolved "https://registry.yarnpkg.com/ssh2/-/ssh2-1.14.0.tgz#8f68440e1b768b66942c9e4e4620b2725b3555bb"