From 86442967d7c3b7155ad0b5f92a9a7fb698d075ed Mon Sep 17 00:00:00 2001 From: Daniyar Itegulov Date: Wed, 11 Sep 2024 22:03:51 +1000 Subject: [PATCH 01/14] pre-insert unsealed L1 batches --- ...db7dbe0bb23c4fc87a78be2d01b77da2ecbd3.json | 23 -- ...e1ba189da720b743b2dad90590a9ca2cdfda.json} | 4 +- ...98869d490ea0a96aa9d5b9a22b34ab0f8f47.json} | 4 +- ...f7cd9c8486d1613319e1f6bc038ddff539f8.json} | 4 +- ...9857265d82d3c29ab37a9839a9e97573bfdc.json} | 4 +- ...74eec73885c64f35bc3c07dc0c138edd2abd.json} | 4 +- ...3ba84478b6e56c95dfae6d8cc84e938e80c6.json} | 4 +- ...bc61568110e9bbe688c55862f93fa62a71405.json | 32 +++ ...de1d4ab2889c9dc43d918c403274b00d43d5.json} | 4 +- ...066b50f0c4ce9a0a8ad84b6af1cebcf7d8d4.json} | 4 +- ...526c586708c812dc00b10bf3cd8aa871d9c2.json} | 4 +- ...e6425cf9ec82494fcf9b807a726eecab7adf2.json | 23 ++ ...019baa12323fd3ef381fdacf290a3db3ec77.json} | 4 +- ...994cc05ebeb4e5aeeaee50b7c4d8baf58ca44.json | 33 --- ...ac6f0b00c05229a0bd40902d5fcb1c1bf026.json} | 4 +- ...e2f3aff3a8f6b69d1b8efa00e4339a3558c6.json} | 4 +- ...9af70109c9cb5264dd4fc583f0d139468d986.json | 23 ++ ...e9e81bca99d9d52147c67a817ee2fdbadea1.json} | 4 +- ...ebfcd3b9c287fecde4376afa84c0566a55ef.json} | 4 +- ...1cd8aa22592f0808f3c2f0555ca321459815e.json | 22 ++ ...ddb30ca0d9ea0190786b8e8472c622e98b9c.json} | 4 +- ...952a2099abd396bf36b9fd44b2daf400e3f3.json} | 4 +- ...3cab780f7ed1d91199b4d34011cdc9376c005.json | 22 -- ...5eb148aa6d1dbd69bf3fe48522101a6ea0bcb.json | 23 -- ...2e73723728d6e2061728c030045757016619.json} | 4 +- ...76c368dae5fdd4b47664e00890bd47e21e0c2.json | 17 ++ ...551b2259488f58f23bec8e8a479ccd40374b.json} | 4 +- ...0910112120_unsealed_batches_in_db.down.sql | 2 + ...240910112120_unsealed_batches_in_db.up.sql | 2 + core/lib/dal/src/blocks_dal.rs | 216 ++++++++++++------ core/lib/dal/src/blocks_web3_dal.rs | 2 + core/lib/dal/src/consensus_dal.rs | 2 + core/lib/dal/src/data_availability_dal.rs | 3 +- core/lib/dal/src/protocol_versions_dal.rs | 2 + core/lib/dal/src/storage_web3_dal.rs | 2 + core/lib/dal/src/sync_dal.rs | 2 + core/lib/dal/src/vm_runner_dal.rs | 4 + core/node/genesis/src/lib.rs | 8 + core/node/node_sync/src/external_io.rs | 11 + core/node/state_keeper/src/io/mempool.rs | 7 + core/node/state_keeper/src/io/persistence.rs | 20 +- .../state_keeper/src/io/seal_logic/mod.rs | 2 +- prover/crates/lib/keystore/src/utils.rs | 1 + 43 files changed, 361 insertions(+), 215 deletions(-) delete mode 100644 core/lib/dal/.sqlx/query-00c0389f4cde049078885cdf05bdb7dbe0bb23c4fc87a78be2d01b77da2ecbd3.json rename core/lib/dal/.sqlx/{query-148dd243ab476724a430e74406119a148b59a79b03dacf3b1c32223c5ebf8d4b.json => query-05208ed40e773359f6bd00bf0340e1ba189da720b743b2dad90590a9ca2cdfda.json} (57%) rename core/lib/dal/.sqlx/{query-1ed2d7e5e98b15420a21650809d710ce910d0c9138d85cb55e16459c757dea03.json => query-16ea3cd5a006576fa1ab5895212098869d490ea0a96aa9d5b9a22b34ab0f8f47.json} (53%) rename core/lib/dal/.sqlx/{query-c9e05ebc7b61c1f409c330bc110bed26c831730944237b74bed98869c83b3ca5.json => query-1fa64372eff16b29f9694e54ac7ef7cd9c8486d1613319e1f6bc038ddff539f8.json} (62%) rename core/lib/dal/.sqlx/{query-f91790ae5cc4b087bf942ba52dd63a1e89945f8d5e0f4da42ecf6313c4f5967e.json => query-3900890900bbfbfc98cfb55f94e99857265d82d3c29ab37a9839a9e97573bfdc.json} (68%) rename core/lib/dal/.sqlx/{query-ef70506e90e8add3b95940a7333f8222bd9fbe8ce82d8963f7da03fe6fcf9225.json => query-3d1e4a4229b8483341274f4fdce574eec73885c64f35bc3c07dc0c138edd2abd.json} (58%) rename core/lib/dal/.sqlx/{query-d14b52df2cd9f9e484c60ba00383b438f14b68535111cf2cedd363fc646aac99.json => query-5e8fc8ee5b143a7e0053f7c6f8c93ba84478b6e56c95dfae6d8cc84e938e80c6.json} (57%) create mode 100644 core/lib/dal/.sqlx/query-66aa91ae9f9c54346d9966ea5e0bc61568110e9bbe688c55862f93fa62a71405.json rename core/lib/dal/.sqlx/{query-87b3c0cb253a19ba181406bab5f30198c2651022c65eb9e04125356fcf52ddfc.json => query-6ea2628a9d9e8f10daadc8cdf8bbde1d4ab2889c9dc43d918c403274b00d43d5.json} (57%) rename core/lib/dal/.sqlx/{query-0bdcf87f6910c7222b621f76f71bc6e326e15dca141050bc9d7dacae98a430e8.json => query-8b608466767675e20fd6173ddbe6066b50f0c4ce9a0a8ad84b6af1cebcf7d8d4.json} (73%) rename core/lib/dal/.sqlx/{query-38a8b00e320b16e99f6ea0e5954e2f7e49cd6600bd3d56cf41795c2c9e082e4c.json => query-8f588aa010f42c3b0b68efe6e0e8526c586708c812dc00b10bf3cd8aa871d9c2.json} (73%) create mode 100644 core/lib/dal/.sqlx/query-96adb72bd7d587489637f96e35ae6425cf9ec82494fcf9b807a726eecab7adf2.json rename core/lib/dal/.sqlx/{query-86cbe509988c8775bcf738d5cb1edac2f0db60c263c1564b64c717f8ae53e44d.json => query-9b9e5bf97503ed64128dfb16564c019baa12323fd3ef381fdacf290a3db3ec77.json} (69%) delete mode 100644 core/lib/dal/.sqlx/query-9f2c06e6b14434ac4f3b556dc97994cc05ebeb4e5aeeaee50b7c4d8baf58ca44.json rename core/lib/dal/.sqlx/{query-43c7e352d09f69de1a182196aea4de79b67833f17d252b5b0e8e00cd6e75b5c1.json => query-a47eee902a0109b072365178e073ac6f0b00c05229a0bd40902d5fcb1c1bf026.json} (73%) rename core/lib/dal/.sqlx/{query-928139bf23bd0d57b8dbdb3283b139300ad3b80ac9e70c00864c3d9f6521b028.json => query-b43ebb5b15c6cb7c43005d3cba40e2f3aff3a8f6b69d1b8efa00e4339a3558c6.json} (62%) create mode 100644 core/lib/dal/.sqlx/query-bd0b67812c6e2dfbc77e388837f9af70109c9cb5264dd4fc583f0d139468d986.json rename core/lib/dal/.sqlx/{query-778f92b1ac91e1ae279f588053d75a9ac877fdd28bda99661e423405e695223d.json => query-ce9dff39b1b01d6d6c700755a82fe9e81bca99d9d52147c67a817ee2fdbadea1.json} (63%) rename core/lib/dal/.sqlx/{query-877d20634068170326ab5801b69c70aff49e60b7def3d93b9206e650c259168b.json => query-d38116f1664a3ab88d285297e8caebfcd3b9c287fecde4376afa84c0566a55ef.json} (57%) create mode 100644 core/lib/dal/.sqlx/query-d4545d817e942dddde53f117e801cd8aa22592f0808f3c2f0555ca321459815e.json rename core/lib/dal/.sqlx/{query-2955e976281f9cbd98b7378c5ab52964b268b93c32fd280c49bf9f932884300d.json => query-d47226eb9b1abe6436f5ef76eba9ddb30ca0d9ea0190786b8e8472c622e98b9c.json} (57%) rename core/lib/dal/.sqlx/{query-f6c0b212fad536f46863ce3a6105249bd77b263c4fcef81689f9dcd155064a36.json => query-dd316dbcb309c3f9cd80ba9b3b22952a2099abd396bf36b9fd44b2daf400e3f3.json} (71%) delete mode 100644 core/lib/dal/.sqlx/query-e475ff151b9f6c76f1e4e9ee2283cab780f7ed1d91199b4d34011cdc9376c005.json delete mode 100644 core/lib/dal/.sqlx/query-e7d0b7c132b80195dae7cbf50355eb148aa6d1dbd69bf3fe48522101a6ea0bcb.json rename core/lib/dal/.sqlx/{query-dc481f59aae632ff6f5fa23f5c5c82627a936f7ea9f6c354eca4bea76fac6b10.json => query-eb9bfcb97ab76409c0794ecdc7ae2e73723728d6e2061728c030045757016619.json} (68%) create mode 100644 core/lib/dal/.sqlx/query-eeb101b29c28fd65a93ecbdb21176c368dae5fdd4b47664e00890bd47e21e0c2.json rename core/lib/dal/.sqlx/{query-cb98d84fc34af1e4a4c2f427c5bb4afd384063ae394a847b26304dd18d490ab4.json => query-f724566464e77fedc01169c20ff0551b2259488f58f23bec8e8a479ccd40374b.json} (74%) create mode 100644 core/lib/dal/migrations/20240910112120_unsealed_batches_in_db.down.sql create mode 100644 core/lib/dal/migrations/20240910112120_unsealed_batches_in_db.up.sql diff --git a/core/lib/dal/.sqlx/query-00c0389f4cde049078885cdf05bdb7dbe0bb23c4fc87a78be2d01b77da2ecbd3.json b/core/lib/dal/.sqlx/query-00c0389f4cde049078885cdf05bdb7dbe0bb23c4fc87a78be2d01b77da2ecbd3.json deleted file mode 100644 index d83713192cb4..000000000000 --- a/core/lib/dal/.sqlx/query-00c0389f4cde049078885cdf05bdb7dbe0bb23c4fc87a78be2d01b77da2ecbd3.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "\n WITH\n available_batches AS (\n SELECT\n MAX(number) AS \"last_batch\"\n FROM\n l1_batches\n ),\n processed_batches AS (\n SELECT\n COALESCE(MAX(l1_batch_number), $1) + $2 AS \"last_ready_batch\"\n FROM\n vm_runner_protective_reads\n WHERE\n time_taken IS NOT NULL\n )\n SELECT\n LEAST(last_batch, last_ready_batch) AS \"last_ready_batch!\"\n FROM\n available_batches\n FULL JOIN processed_batches ON TRUE\n ", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "last_ready_batch!", - "type_info": "Int8" - } - ], - "parameters": { - "Left": [ - "Int8", - "Int8" - ] - }, - "nullable": [ - true - ] - }, - "hash": "00c0389f4cde049078885cdf05bdb7dbe0bb23c4fc87a78be2d01b77da2ecbd3" -} diff --git a/core/lib/dal/.sqlx/query-148dd243ab476724a430e74406119a148b59a79b03dacf3b1c32223c5ebf8d4b.json b/core/lib/dal/.sqlx/query-05208ed40e773359f6bd00bf0340e1ba189da720b743b2dad90590a9ca2cdfda.json similarity index 57% rename from core/lib/dal/.sqlx/query-148dd243ab476724a430e74406119a148b59a79b03dacf3b1c32223c5ebf8d4b.json rename to core/lib/dal/.sqlx/query-05208ed40e773359f6bd00bf0340e1ba189da720b743b2dad90590a9ca2cdfda.json index 4f14d753fd6f..c05bf60c219e 100644 --- a/core/lib/dal/.sqlx/query-148dd243ab476724a430e74406119a148b59a79b03dacf3b1c32223c5ebf8d4b.json +++ b/core/lib/dal/.sqlx/query-05208ed40e773359f6bd00bf0340e1ba189da720b743b2dad90590a9ca2cdfda.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n number\n FROM\n l1_batches\n WHERE\n hash IS NOT NULL\n AND commitment IS NULL\n ORDER BY\n number DESC\n LIMIT\n 1\n ", + "query": "\n SELECT\n number\n FROM\n l1_batches\n WHERE\n is_sealed\n AND hash IS NOT NULL\n AND commitment IS NULL\n ORDER BY\n number DESC\n LIMIT\n 1\n ", "describe": { "columns": [ { @@ -16,5 +16,5 @@ false ] }, - "hash": "148dd243ab476724a430e74406119a148b59a79b03dacf3b1c32223c5ebf8d4b" + "hash": "05208ed40e773359f6bd00bf0340e1ba189da720b743b2dad90590a9ca2cdfda" } diff --git a/core/lib/dal/.sqlx/query-1ed2d7e5e98b15420a21650809d710ce910d0c9138d85cb55e16459c757dea03.json b/core/lib/dal/.sqlx/query-16ea3cd5a006576fa1ab5895212098869d490ea0a96aa9d5b9a22b34ab0f8f47.json similarity index 53% rename from core/lib/dal/.sqlx/query-1ed2d7e5e98b15420a21650809d710ce910d0c9138d85cb55e16459c757dea03.json rename to core/lib/dal/.sqlx/query-16ea3cd5a006576fa1ab5895212098869d490ea0a96aa9d5b9a22b34ab0f8f47.json index 9cf4cc1e68e1..36879466039a 100644 --- a/core/lib/dal/.sqlx/query-1ed2d7e5e98b15420a21650809d710ce910d0c9138d85cb55e16459c757dea03.json +++ b/core/lib/dal/.sqlx/query-16ea3cd5a006576fa1ab5895212098869d490ea0a96aa9d5b9a22b34ab0f8f47.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n protocol_version\n FROM\n l1_batches\n ORDER BY\n number DESC\n LIMIT\n 1\n ", + "query": "\n SELECT\n protocol_version\n FROM\n l1_batches\n WHERE\n is_sealed\n ORDER BY\n number DESC\n LIMIT\n 1\n ", "describe": { "columns": [ { @@ -16,5 +16,5 @@ true ] }, - "hash": "1ed2d7e5e98b15420a21650809d710ce910d0c9138d85cb55e16459c757dea03" + "hash": "16ea3cd5a006576fa1ab5895212098869d490ea0a96aa9d5b9a22b34ab0f8f47" } diff --git a/core/lib/dal/.sqlx/query-c9e05ebc7b61c1f409c330bc110bed26c831730944237b74bed98869c83b3ca5.json b/core/lib/dal/.sqlx/query-1fa64372eff16b29f9694e54ac7ef7cd9c8486d1613319e1f6bc038ddff539f8.json similarity index 62% rename from core/lib/dal/.sqlx/query-c9e05ebc7b61c1f409c330bc110bed26c831730944237b74bed98869c83b3ca5.json rename to core/lib/dal/.sqlx/query-1fa64372eff16b29f9694e54ac7ef7cd9c8486d1613319e1f6bc038ddff539f8.json index 433564c6ae05..aa657582690e 100644 --- a/core/lib/dal/.sqlx/query-c9e05ebc7b61c1f409c330bc110bed26c831730944237b74bed98869c83b3ca5.json +++ b/core/lib/dal/.sqlx/query-1fa64372eff16b29f9694e54ac7ef7cd9c8486d1613319e1f6bc038ddff539f8.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n (\n SELECT\n l1_batch_number\n FROM\n miniblocks\n WHERE\n number = $1\n ) AS \"block_batch?\",\n COALESCE(\n (\n SELECT\n MAX(number) + 1\n FROM\n l1_batches\n ),\n (\n SELECT\n MAX(l1_batch_number) + 1\n FROM\n snapshot_recovery\n ),\n 0\n ) AS \"pending_batch!\"\n ", + "query": "\n SELECT\n (\n SELECT\n l1_batch_number\n FROM\n miniblocks\n WHERE\n number = $1\n ) AS \"block_batch?\",\n COALESCE(\n (\n SELECT\n MAX(number) + 1\n FROM\n l1_batches\n WHERE\n is_sealed\n ),\n (\n SELECT\n MAX(l1_batch_number) + 1\n FROM\n snapshot_recovery\n ),\n 0\n ) AS \"pending_batch!\"\n ", "describe": { "columns": [ { @@ -24,5 +24,5 @@ null ] }, - "hash": "c9e05ebc7b61c1f409c330bc110bed26c831730944237b74bed98869c83b3ca5" + "hash": "1fa64372eff16b29f9694e54ac7ef7cd9c8486d1613319e1f6bc038ddff539f8" } diff --git a/core/lib/dal/.sqlx/query-f91790ae5cc4b087bf942ba52dd63a1e89945f8d5e0f4da42ecf6313c4f5967e.json b/core/lib/dal/.sqlx/query-3900890900bbfbfc98cfb55f94e99857265d82d3c29ab37a9839a9e97573bfdc.json similarity index 68% rename from core/lib/dal/.sqlx/query-f91790ae5cc4b087bf942ba52dd63a1e89945f8d5e0f4da42ecf6313c4f5967e.json rename to core/lib/dal/.sqlx/query-3900890900bbfbfc98cfb55f94e99857265d82d3c29ab37a9839a9e97573bfdc.json index cdf4b166270d..965ab97b63f7 100644 --- a/core/lib/dal/.sqlx/query-f91790ae5cc4b087bf942ba52dd63a1e89945f8d5e0f4da42ecf6313c4f5967e.json +++ b/core/lib/dal/.sqlx/query-3900890900bbfbfc98cfb55f94e99857265d82d3c29ab37a9839a9e97573bfdc.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n MIN(number) AS \"number\"\n FROM\n l1_batches\n WHERE\n hash IS NOT NULL\n ", + "query": "\n SELECT\n MIN(number) AS \"number\"\n FROM\n l1_batches\n WHERE\n is_sealed\n AND hash IS NOT NULL\n ", "describe": { "columns": [ { @@ -16,5 +16,5 @@ null ] }, - "hash": "f91790ae5cc4b087bf942ba52dd63a1e89945f8d5e0f4da42ecf6313c4f5967e" + "hash": "3900890900bbfbfc98cfb55f94e99857265d82d3c29ab37a9839a9e97573bfdc" } diff --git a/core/lib/dal/.sqlx/query-ef70506e90e8add3b95940a7333f8222bd9fbe8ce82d8963f7da03fe6fcf9225.json b/core/lib/dal/.sqlx/query-3d1e4a4229b8483341274f4fdce574eec73885c64f35bc3c07dc0c138edd2abd.json similarity index 58% rename from core/lib/dal/.sqlx/query-ef70506e90e8add3b95940a7333f8222bd9fbe8ce82d8963f7da03fe6fcf9225.json rename to core/lib/dal/.sqlx/query-3d1e4a4229b8483341274f4fdce574eec73885c64f35bc3c07dc0c138edd2abd.json index cf102b828aa8..0a836c3324ad 100644 --- a/core/lib/dal/.sqlx/query-ef70506e90e8add3b95940a7333f8222bd9fbe8ce82d8963f7da03fe6fcf9225.json +++ b/core/lib/dal/.sqlx/query-3d1e4a4229b8483341274f4fdce574eec73885c64f35bc3c07dc0c138edd2abd.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "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.fair_pubdata_price,\n miniblocks.bootloader_code_hash,\n miniblocks.default_aa_code_hash,\n miniblocks.protocol_version,\n miniblocks.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 ", + "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 WHERE\n is_sealed\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.fair_pubdata_price,\n miniblocks.bootloader_code_hash,\n miniblocks.default_aa_code_hash,\n miniblocks.protocol_version,\n miniblocks.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 ", "describe": { "columns": [ { @@ -126,5 +126,5 @@ false ] }, - "hash": "ef70506e90e8add3b95940a7333f8222bd9fbe8ce82d8963f7da03fe6fcf9225" + "hash": "3d1e4a4229b8483341274f4fdce574eec73885c64f35bc3c07dc0c138edd2abd" } diff --git a/core/lib/dal/.sqlx/query-d14b52df2cd9f9e484c60ba00383b438f14b68535111cf2cedd363fc646aac99.json b/core/lib/dal/.sqlx/query-5e8fc8ee5b143a7e0053f7c6f8c93ba84478b6e56c95dfae6d8cc84e938e80c6.json similarity index 57% rename from core/lib/dal/.sqlx/query-d14b52df2cd9f9e484c60ba00383b438f14b68535111cf2cedd363fc646aac99.json rename to core/lib/dal/.sqlx/query-5e8fc8ee5b143a7e0053f7c6f8c93ba84478b6e56c95dfae6d8cc84e938e80c6.json index 0370a63d65e3..959571601249 100644 --- a/core/lib/dal/.sqlx/query-d14b52df2cd9f9e484c60ba00383b438f14b68535111cf2cedd363fc646aac99.json +++ b/core/lib/dal/.sqlx/query-5e8fc8ee5b143a7e0053f7c6f8c93ba84478b6e56c95dfae6d8cc84e938e80c6.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "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 ", + "query": "\n SELECT\n timestamp\n FROM\n l1_batches\n WHERE\n is_sealed\n AND eth_execute_tx_id IS NULL\n AND number > 0\n ORDER BY\n number\n LIMIT\n 1\n ", "describe": { "columns": [ { @@ -16,5 +16,5 @@ false ] }, - "hash": "d14b52df2cd9f9e484c60ba00383b438f14b68535111cf2cedd363fc646aac99" + "hash": "5e8fc8ee5b143a7e0053f7c6f8c93ba84478b6e56c95dfae6d8cc84e938e80c6" } diff --git a/core/lib/dal/.sqlx/query-66aa91ae9f9c54346d9966ea5e0bc61568110e9bbe688c55862f93fa62a71405.json b/core/lib/dal/.sqlx/query-66aa91ae9f9c54346d9966ea5e0bc61568110e9bbe688c55862f93fa62a71405.json new file mode 100644 index 000000000000..b9c984920993 --- /dev/null +++ b/core/lib/dal/.sqlx/query-66aa91ae9f9c54346d9966ea5e0bc61568110e9bbe688c55862f93fa62a71405.json @@ -0,0 +1,32 @@ +{ + "db_name": "PostgreSQL", + "query": "\n UPDATE l1_batches\n SET\n l1_tx_count = $2,\n l2_tx_count = $3,\n l2_to_l1_messages = $4,\n bloom = $5,\n priority_ops_onchain_data = $6,\n predicted_commit_gas_cost = $7,\n predicted_prove_gas_cost = $8,\n predicted_execute_gas_cost = $9,\n initial_bootloader_heap_content = $10,\n used_contract_hashes = $11,\n bootloader_code_hash = $12,\n default_aa_code_hash = $13,\n protocol_version = $14,\n system_logs = $15,\n storage_refunds = $16,\n pubdata_costs = $17,\n pubdata_input = $18,\n predicted_circuits_by_type = $19,\n updated_at = NOW(),\n is_sealed = TRUE\n WHERE\n number = $1\n ", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Int8", + "Int4", + "Int4", + "ByteaArray", + "Bytea", + "ByteaArray", + "Int8", + "Int8", + "Int8", + "Jsonb", + "Jsonb", + "Bytea", + "Bytea", + "Int4", + "ByteaArray", + "Int8Array", + "Int8Array", + "Bytea", + "Jsonb" + ] + }, + "nullable": [] + }, + "hash": "66aa91ae9f9c54346d9966ea5e0bc61568110e9bbe688c55862f93fa62a71405" +} diff --git a/core/lib/dal/.sqlx/query-87b3c0cb253a19ba181406bab5f30198c2651022c65eb9e04125356fcf52ddfc.json b/core/lib/dal/.sqlx/query-6ea2628a9d9e8f10daadc8cdf8bbde1d4ab2889c9dc43d918c403274b00d43d5.json similarity index 57% rename from core/lib/dal/.sqlx/query-87b3c0cb253a19ba181406bab5f30198c2651022c65eb9e04125356fcf52ddfc.json rename to core/lib/dal/.sqlx/query-6ea2628a9d9e8f10daadc8cdf8bbde1d4ab2889c9dc43d918c403274b00d43d5.json index 669beb8aa25f..36b8dfcd92aa 100644 --- a/core/lib/dal/.sqlx/query-87b3c0cb253a19ba181406bab5f30198c2651022c65eb9e04125356fcf52ddfc.json +++ b/core/lib/dal/.sqlx/query-6ea2628a9d9e8f10daadc8cdf8bbde1d4ab2889c9dc43d918c403274b00d43d5.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n number\n FROM\n l1_batches\n WHERE\n hash IS NOT NULL\n AND commitment IS NULL\n ORDER BY\n number\n LIMIT\n 1\n ", + "query": "\n SELECT\n number\n FROM\n l1_batches\n WHERE\n is_sealed\n AND hash IS NOT NULL\n AND commitment IS NULL\n ORDER BY\n number\n LIMIT\n 1\n ", "describe": { "columns": [ { @@ -16,5 +16,5 @@ false ] }, - "hash": "87b3c0cb253a19ba181406bab5f30198c2651022c65eb9e04125356fcf52ddfc" + "hash": "6ea2628a9d9e8f10daadc8cdf8bbde1d4ab2889c9dc43d918c403274b00d43d5" } diff --git a/core/lib/dal/.sqlx/query-0bdcf87f6910c7222b621f76f71bc6e326e15dca141050bc9d7dacae98a430e8.json b/core/lib/dal/.sqlx/query-8b608466767675e20fd6173ddbe6066b50f0c4ce9a0a8ad84b6af1cebcf7d8d4.json similarity index 73% rename from core/lib/dal/.sqlx/query-0bdcf87f6910c7222b621f76f71bc6e326e15dca141050bc9d7dacae98a430e8.json rename to core/lib/dal/.sqlx/query-8b608466767675e20fd6173ddbe6066b50f0c4ce9a0a8ad84b6af1cebcf7d8d4.json index e5ed48130726..a326c314c9cf 100644 --- a/core/lib/dal/.sqlx/query-0bdcf87f6910c7222b621f76f71bc6e326e15dca141050bc9d7dacae98a430e8.json +++ b/core/lib/dal/.sqlx/query-8b608466767675e20fd6173ddbe6066b50f0c4ce9a0a8ad84b6af1cebcf7d8d4.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n hash\n FROM\n l1_batches\n WHERE\n number = $1\n ", + "query": "\n SELECT\n hash\n FROM\n l1_batches\n WHERE\n is_sealed\n AND number = $1\n ", "describe": { "columns": [ { @@ -18,5 +18,5 @@ true ] }, - "hash": "0bdcf87f6910c7222b621f76f71bc6e326e15dca141050bc9d7dacae98a430e8" + "hash": "8b608466767675e20fd6173ddbe6066b50f0c4ce9a0a8ad84b6af1cebcf7d8d4" } diff --git a/core/lib/dal/.sqlx/query-38a8b00e320b16e99f6ea0e5954e2f7e49cd6600bd3d56cf41795c2c9e082e4c.json b/core/lib/dal/.sqlx/query-8f588aa010f42c3b0b68efe6e0e8526c586708c812dc00b10bf3cd8aa871d9c2.json similarity index 73% rename from core/lib/dal/.sqlx/query-38a8b00e320b16e99f6ea0e5954e2f7e49cd6600bd3d56cf41795c2c9e082e4c.json rename to core/lib/dal/.sqlx/query-8f588aa010f42c3b0b68efe6e0e8526c586708c812dc00b10bf3cd8aa871d9c2.json index 9b989a9ba251..82af00b56061 100644 --- a/core/lib/dal/.sqlx/query-38a8b00e320b16e99f6ea0e5954e2f7e49cd6600bd3d56cf41795c2c9e082e4c.json +++ b/core/lib/dal/.sqlx/query-8f588aa010f42c3b0b68efe6e0e8526c586708c812dc00b10bf3cd8aa871d9c2.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n MAX(number) AS \"number\"\n FROM\n l1_batches\n ", + "query": "\n SELECT\n MAX(number) AS \"number\"\n FROM\n l1_batches\n WHERE\n is_sealed\n ", "describe": { "columns": [ { @@ -16,5 +16,5 @@ null ] }, - "hash": "38a8b00e320b16e99f6ea0e5954e2f7e49cd6600bd3d56cf41795c2c9e082e4c" + "hash": "8f588aa010f42c3b0b68efe6e0e8526c586708c812dc00b10bf3cd8aa871d9c2" } diff --git a/core/lib/dal/.sqlx/query-96adb72bd7d587489637f96e35ae6425cf9ec82494fcf9b807a726eecab7adf2.json b/core/lib/dal/.sqlx/query-96adb72bd7d587489637f96e35ae6425cf9ec82494fcf9b807a726eecab7adf2.json new file mode 100644 index 000000000000..54b3d8f2c7bf --- /dev/null +++ b/core/lib/dal/.sqlx/query-96adb72bd7d587489637f96e35ae6425cf9ec82494fcf9b807a726eecab7adf2.json @@ -0,0 +1,23 @@ +{ + "db_name": "PostgreSQL", + "query": "\n WITH\n available_batches AS (\n SELECT\n MAX(number) AS \"last_batch\"\n FROM\n l1_batches\n WHERE\n is_sealed\n ),\n processed_batches AS (\n SELECT\n COALESCE(MAX(l1_batch_number), $1) + $2 AS \"last_ready_batch\"\n FROM\n vm_runner_protective_reads\n WHERE\n time_taken IS NOT NULL\n )\n SELECT\n LEAST(last_batch, last_ready_batch) AS \"last_ready_batch!\"\n FROM\n available_batches\n FULL JOIN processed_batches ON TRUE\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "last_ready_batch!", + "type_info": "Int8" + } + ], + "parameters": { + "Left": [ + "Int8", + "Int8" + ] + }, + "nullable": [ + true + ] + }, + "hash": "96adb72bd7d587489637f96e35ae6425cf9ec82494fcf9b807a726eecab7adf2" +} diff --git a/core/lib/dal/.sqlx/query-86cbe509988c8775bcf738d5cb1edac2f0db60c263c1564b64c717f8ae53e44d.json b/core/lib/dal/.sqlx/query-9b9e5bf97503ed64128dfb16564c019baa12323fd3ef381fdacf290a3db3ec77.json similarity index 69% rename from core/lib/dal/.sqlx/query-86cbe509988c8775bcf738d5cb1edac2f0db60c263c1564b64c717f8ae53e44d.json rename to core/lib/dal/.sqlx/query-9b9e5bf97503ed64128dfb16564c019baa12323fd3ef381fdacf290a3db3ec77.json index f97990794423..08e3b4b17a9e 100644 --- a/core/lib/dal/.sqlx/query-86cbe509988c8775bcf738d5cb1edac2f0db60c263c1564b64c717f8ae53e44d.json +++ b/core/lib/dal/.sqlx/query-9b9e5bf97503ed64128dfb16564c019baa12323fd3ef381fdacf290a3db3ec77.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n MIN(number) AS \"min?\"\n FROM\n l1_batches\n WHERE\n protocol_version = $1\n ", + "query": "\n SELECT\n MIN(number) AS \"min?\"\n FROM\n l1_batches\n WHERE\n is_sealed\n AND protocol_version = $1\n ", "describe": { "columns": [ { @@ -18,5 +18,5 @@ null ] }, - "hash": "86cbe509988c8775bcf738d5cb1edac2f0db60c263c1564b64c717f8ae53e44d" + "hash": "9b9e5bf97503ed64128dfb16564c019baa12323fd3ef381fdacf290a3db3ec77" } diff --git a/core/lib/dal/.sqlx/query-9f2c06e6b14434ac4f3b556dc97994cc05ebeb4e5aeeaee50b7c4d8baf58ca44.json b/core/lib/dal/.sqlx/query-9f2c06e6b14434ac4f3b556dc97994cc05ebeb4e5aeeaee50b7c4d8baf58ca44.json deleted file mode 100644 index 54f0d27bab26..000000000000 --- a/core/lib/dal/.sqlx/query-9f2c06e6b14434ac4f3b556dc97994cc05ebeb4e5aeeaee50b7c4d8baf58ca44.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "\n INSERT INTO\n l1_batches (\n number,\n l1_tx_count,\n l2_tx_count,\n timestamp,\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 bootloader_code_hash,\n default_aa_code_hash,\n protocol_version,\n system_logs,\n storage_refunds,\n pubdata_costs,\n pubdata_input,\n predicted_circuits_by_type,\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 NOW(),\n NOW()\n )\n ", - "describe": { - "columns": [], - "parameters": { - "Left": [ - "Int8", - "Int4", - "Int4", - "Int8", - "ByteaArray", - "Bytea", - "ByteaArray", - "Int8", - "Int8", - "Int8", - "Jsonb", - "Jsonb", - "Bytea", - "Bytea", - "Int4", - "ByteaArray", - "Int8Array", - "Int8Array", - "Bytea", - "Jsonb" - ] - }, - "nullable": [] - }, - "hash": "9f2c06e6b14434ac4f3b556dc97994cc05ebeb4e5aeeaee50b7c4d8baf58ca44" -} diff --git a/core/lib/dal/.sqlx/query-43c7e352d09f69de1a182196aea4de79b67833f17d252b5b0e8e00cd6e75b5c1.json b/core/lib/dal/.sqlx/query-a47eee902a0109b072365178e073ac6f0b00c05229a0bd40902d5fcb1c1bf026.json similarity index 73% rename from core/lib/dal/.sqlx/query-43c7e352d09f69de1a182196aea4de79b67833f17d252b5b0e8e00cd6e75b5c1.json rename to core/lib/dal/.sqlx/query-a47eee902a0109b072365178e073ac6f0b00c05229a0bd40902d5fcb1c1bf026.json index 56fcdb389430..9a1b043e5731 100644 --- a/core/lib/dal/.sqlx/query-43c7e352d09f69de1a182196aea4de79b67833f17d252b5b0e8e00cd6e75b5c1.json +++ b/core/lib/dal/.sqlx/query-a47eee902a0109b072365178e073ac6f0b00c05229a0bd40902d5fcb1c1bf026.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n MIN(number) AS \"number\"\n FROM\n l1_batches\n ", + "query": "\n SELECT\n MIN(number) AS \"number\"\n FROM\n l1_batches\n WHERE\n is_sealed\n ", "describe": { "columns": [ { @@ -16,5 +16,5 @@ null ] }, - "hash": "43c7e352d09f69de1a182196aea4de79b67833f17d252b5b0e8e00cd6e75b5c1" + "hash": "a47eee902a0109b072365178e073ac6f0b00c05229a0bd40902d5fcb1c1bf026" } diff --git a/core/lib/dal/.sqlx/query-928139bf23bd0d57b8dbdb3283b139300ad3b80ac9e70c00864c3d9f6521b028.json b/core/lib/dal/.sqlx/query-b43ebb5b15c6cb7c43005d3cba40e2f3aff3a8f6b69d1b8efa00e4339a3558c6.json similarity index 62% rename from core/lib/dal/.sqlx/query-928139bf23bd0d57b8dbdb3283b139300ad3b80ac9e70c00864c3d9f6521b028.json rename to core/lib/dal/.sqlx/query-b43ebb5b15c6cb7c43005d3cba40e2f3aff3a8f6b69d1b8efa00e4339a3558c6.json index e192763b189b..23a893f38761 100644 --- a/core/lib/dal/.sqlx/query-928139bf23bd0d57b8dbdb3283b139300ad3b80ac9e70c00864c3d9f6521b028.json +++ b/core/lib/dal/.sqlx/query-b43ebb5b15c6cb7c43005d3cba40e2f3aff3a8f6b69d1b8efa00e4339a3558c6.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n number,\n pubdata_input\n FROM\n l1_batches\n LEFT JOIN data_availability ON data_availability.l1_batch_number = l1_batches.number\n WHERE\n eth_commit_tx_id IS NULL\n AND number != 0\n AND data_availability.blob_id IS NULL\n AND pubdata_input IS NOT NULL\n ORDER BY\n number\n LIMIT\n $1\n ", + "query": "\n SELECT\n number,\n pubdata_input\n FROM\n l1_batches\n LEFT JOIN data_availability ON data_availability.l1_batch_number = l1_batches.number\n WHERE\n is_sealed\n AND eth_commit_tx_id IS NULL\n AND number != 0\n AND data_availability.blob_id IS NULL\n AND pubdata_input IS NOT NULL\n ORDER BY\n number\n LIMIT\n $1\n ", "describe": { "columns": [ { @@ -24,5 +24,5 @@ true ] }, - "hash": "928139bf23bd0d57b8dbdb3283b139300ad3b80ac9e70c00864c3d9f6521b028" + "hash": "b43ebb5b15c6cb7c43005d3cba40e2f3aff3a8f6b69d1b8efa00e4339a3558c6" } diff --git a/core/lib/dal/.sqlx/query-bd0b67812c6e2dfbc77e388837f9af70109c9cb5264dd4fc583f0d139468d986.json b/core/lib/dal/.sqlx/query-bd0b67812c6e2dfbc77e388837f9af70109c9cb5264dd4fc583f0d139468d986.json new file mode 100644 index 000000000000..bd6d75f69da0 --- /dev/null +++ b/core/lib/dal/.sqlx/query-bd0b67812c6e2dfbc77e388837f9af70109c9cb5264dd4fc583f0d139468d986.json @@ -0,0 +1,23 @@ +{ + "db_name": "PostgreSQL", + "query": "\n WITH\n available_batches AS (\n SELECT\n MAX(number) AS \"last_batch\"\n FROM\n l1_batches\n WHERE\n is_sealed\n ),\n processed_batches AS (\n SELECT\n COALESCE(MAX(l1_batch_number), $1) + $2 AS \"last_ready_batch\"\n FROM\n vm_runner_bwip\n WHERE\n time_taken IS NOT NULL\n )\n SELECT\n LEAST(last_batch, last_ready_batch) AS \"last_ready_batch!\"\n FROM\n available_batches\n FULL JOIN processed_batches ON TRUE\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "last_ready_batch!", + "type_info": "Int8" + } + ], + "parameters": { + "Left": [ + "Int8", + "Int8" + ] + }, + "nullable": [ + true + ] + }, + "hash": "bd0b67812c6e2dfbc77e388837f9af70109c9cb5264dd4fc583f0d139468d986" +} diff --git a/core/lib/dal/.sqlx/query-778f92b1ac91e1ae279f588053d75a9ac877fdd28bda99661e423405e695223d.json b/core/lib/dal/.sqlx/query-ce9dff39b1b01d6d6c700755a82fe9e81bca99d9d52147c67a817ee2fdbadea1.json similarity index 63% rename from core/lib/dal/.sqlx/query-778f92b1ac91e1ae279f588053d75a9ac877fdd28bda99661e423405e695223d.json rename to core/lib/dal/.sqlx/query-ce9dff39b1b01d6d6c700755a82fe9e81bca99d9d52147c67a817ee2fdbadea1.json index aa7d4c65a39d..fdcd5965c862 100644 --- a/core/lib/dal/.sqlx/query-778f92b1ac91e1ae279f588053d75a9ac877fdd28bda99661e423405e695223d.json +++ b/core/lib/dal/.sqlx/query-ce9dff39b1b01d6d6c700755a82fe9e81bca99d9d52147c67a817ee2fdbadea1.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "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 (\n SELECT\n MAX(l1_batch_number) + 1\n FROM\n snapshot_recovery\n )\n ) AS \"l1_batch_number!\",\n (miniblocks.l1_tx_count + miniblocks.l2_tx_count) AS \"tx_count!\",\n miniblocks.timestamp,\n miniblocks.l1_gas_price,\n miniblocks.l2_fair_gas_price,\n miniblocks.fair_pubdata_price,\n miniblocks.bootloader_code_hash,\n miniblocks.default_aa_code_hash,\n miniblocks.virtual_blocks,\n miniblocks.hash,\n miniblocks.protocol_version AS \"protocol_version!\",\n miniblocks.fee_account_address AS \"fee_account_address!\"\n FROM\n miniblocks\n WHERE\n miniblocks.number BETWEEN $1 AND $2\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 WHERE\n is_sealed\n ),\n (\n SELECT\n MAX(l1_batch_number) + 1\n FROM\n snapshot_recovery\n )\n ) AS \"l1_batch_number!\",\n (miniblocks.l1_tx_count + miniblocks.l2_tx_count) AS \"tx_count!\",\n miniblocks.timestamp,\n miniblocks.l1_gas_price,\n miniblocks.l2_fair_gas_price,\n miniblocks.fair_pubdata_price,\n miniblocks.bootloader_code_hash,\n miniblocks.default_aa_code_hash,\n miniblocks.virtual_blocks,\n miniblocks.hash,\n miniblocks.protocol_version AS \"protocol_version!\",\n miniblocks.fee_account_address AS \"fee_account_address!\"\n FROM\n miniblocks\n WHERE\n miniblocks.number BETWEEN $1 AND $2\n ", "describe": { "columns": [ { @@ -91,5 +91,5 @@ false ] }, - "hash": "778f92b1ac91e1ae279f588053d75a9ac877fdd28bda99661e423405e695223d" + "hash": "ce9dff39b1b01d6d6c700755a82fe9e81bca99d9d52147c67a817ee2fdbadea1" } diff --git a/core/lib/dal/.sqlx/query-877d20634068170326ab5801b69c70aff49e60b7def3d93b9206e650c259168b.json b/core/lib/dal/.sqlx/query-d38116f1664a3ab88d285297e8caebfcd3b9c287fecde4376afa84c0566a55ef.json similarity index 57% rename from core/lib/dal/.sqlx/query-877d20634068170326ab5801b69c70aff49e60b7def3d93b9206e650c259168b.json rename to core/lib/dal/.sqlx/query-d38116f1664a3ab88d285297e8caebfcd3b9c287fecde4376afa84c0566a55ef.json index 3052b3a04d1a..15d6096420fb 100644 --- a/core/lib/dal/.sqlx/query-877d20634068170326ab5801b69c70aff49e60b7def3d93b9206e650c259168b.json +++ b/core/lib/dal/.sqlx/query-d38116f1664a3ab88d285297e8caebfcd3b9c287fecde4376afa84c0566a55ef.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "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 ", + "query": "\n SELECT\n timestamp\n FROM\n l1_batches\n WHERE\n is_sealed\n AND eth_commit_tx_id IS NULL\n AND number > 0\n ORDER BY\n number\n LIMIT\n 1\n ", "describe": { "columns": [ { @@ -16,5 +16,5 @@ false ] }, - "hash": "877d20634068170326ab5801b69c70aff49e60b7def3d93b9206e650c259168b" + "hash": "d38116f1664a3ab88d285297e8caebfcd3b9c287fecde4376afa84c0566a55ef" } diff --git a/core/lib/dal/.sqlx/query-d4545d817e942dddde53f117e801cd8aa22592f0808f3c2f0555ca321459815e.json b/core/lib/dal/.sqlx/query-d4545d817e942dddde53f117e801cd8aa22592f0808f3c2f0555ca321459815e.json new file mode 100644 index 000000000000..0aac086f22a9 --- /dev/null +++ b/core/lib/dal/.sqlx/query-d4545d817e942dddde53f117e801cd8aa22592f0808f3c2f0555ca321459815e.json @@ -0,0 +1,22 @@ +{ + "db_name": "PostgreSQL", + "query": "\n SELECT\n COALESCE(\n miniblocks.l1_batch_number,\n (\n SELECT\n (MAX(number) + 1)\n FROM\n l1_batches\n WHERE\n is_sealed\n ),\n (\n SELECT\n MAX(l1_batch_number) + 1\n FROM\n snapshot_recovery\n )\n ) AS \"l1_batch_number!\"\n FROM\n miniblocks\n WHERE\n number = $1\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "l1_batch_number!", + "type_info": "Int8" + } + ], + "parameters": { + "Left": [ + "Int8" + ] + }, + "nullable": [ + null + ] + }, + "hash": "d4545d817e942dddde53f117e801cd8aa22592f0808f3c2f0555ca321459815e" +} diff --git a/core/lib/dal/.sqlx/query-2955e976281f9cbd98b7378c5ab52964b268b93c32fd280c49bf9f932884300d.json b/core/lib/dal/.sqlx/query-d47226eb9b1abe6436f5ef76eba9ddb30ca0d9ea0190786b8e8472c622e98b9c.json similarity index 57% rename from core/lib/dal/.sqlx/query-2955e976281f9cbd98b7378c5ab52964b268b93c32fd280c49bf9f932884300d.json rename to core/lib/dal/.sqlx/query-d47226eb9b1abe6436f5ef76eba9ddb30ca0d9ea0190786b8e8472c622e98b9c.json index 7c3a261d1f6e..baabbdb4f24a 100644 --- a/core/lib/dal/.sqlx/query-2955e976281f9cbd98b7378c5ab52964b268b93c32fd280c49bf9f932884300d.json +++ b/core/lib/dal/.sqlx/query-d47226eb9b1abe6436f5ef76eba9ddb30ca0d9ea0190786b8e8472c622e98b9c.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "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 ", + "query": "\n SELECT\n timestamp\n FROM\n l1_batches\n WHERE\n is_sealed\n AND eth_prove_tx_id IS NULL\n AND number > 0\n ORDER BY\n number\n LIMIT\n 1\n ", "describe": { "columns": [ { @@ -16,5 +16,5 @@ false ] }, - "hash": "2955e976281f9cbd98b7378c5ab52964b268b93c32fd280c49bf9f932884300d" + "hash": "d47226eb9b1abe6436f5ef76eba9ddb30ca0d9ea0190786b8e8472c622e98b9c" } diff --git a/core/lib/dal/.sqlx/query-f6c0b212fad536f46863ce3a6105249bd77b263c4fcef81689f9dcd155064a36.json b/core/lib/dal/.sqlx/query-dd316dbcb309c3f9cd80ba9b3b22952a2099abd396bf36b9fd44b2daf400e3f3.json similarity index 71% rename from core/lib/dal/.sqlx/query-f6c0b212fad536f46863ce3a6105249bd77b263c4fcef81689f9dcd155064a36.json rename to core/lib/dal/.sqlx/query-dd316dbcb309c3f9cd80ba9b3b22952a2099abd396bf36b9fd44b2daf400e3f3.json index f916d0dddcef..f937eea6a514 100644 --- a/core/lib/dal/.sqlx/query-f6c0b212fad536f46863ce3a6105249bd77b263c4fcef81689f9dcd155064a36.json +++ b/core/lib/dal/.sqlx/query-dd316dbcb309c3f9cd80ba9b3b22952a2099abd396bf36b9fd44b2daf400e3f3.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n number,\n l1_tx_count,\n l2_tx_count,\n timestamp\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 ", + "query": "\n SELECT\n number,\n l1_tx_count,\n l2_tx_count,\n timestamp\n FROM\n l1_batches\n WHERE\n is_sealed\n AND (\n eth_commit_tx_id = $1\n OR eth_prove_tx_id = $1\n OR eth_execute_tx_id = $1\n )\n ", "describe": { "columns": [ { @@ -36,5 +36,5 @@ false ] }, - "hash": "f6c0b212fad536f46863ce3a6105249bd77b263c4fcef81689f9dcd155064a36" + "hash": "dd316dbcb309c3f9cd80ba9b3b22952a2099abd396bf36b9fd44b2daf400e3f3" } diff --git a/core/lib/dal/.sqlx/query-e475ff151b9f6c76f1e4e9ee2283cab780f7ed1d91199b4d34011cdc9376c005.json b/core/lib/dal/.sqlx/query-e475ff151b9f6c76f1e4e9ee2283cab780f7ed1d91199b4d34011cdc9376c005.json deleted file mode 100644 index 2598be6267d1..000000000000 --- a/core/lib/dal/.sqlx/query-e475ff151b9f6c76f1e4e9ee2283cab780f7ed1d91199b4d34011cdc9376c005.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "\n SELECT\n COALESCE(\n miniblocks.l1_batch_number,\n (\n SELECT\n (MAX(number) + 1)\n FROM\n l1_batches\n ),\n (\n SELECT\n MAX(l1_batch_number) + 1\n FROM\n snapshot_recovery\n )\n ) AS \"l1_batch_number!\"\n FROM\n miniblocks\n WHERE\n number = $1\n ", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "l1_batch_number!", - "type_info": "Int8" - } - ], - "parameters": { - "Left": [ - "Int8" - ] - }, - "nullable": [ - null - ] - }, - "hash": "e475ff151b9f6c76f1e4e9ee2283cab780f7ed1d91199b4d34011cdc9376c005" -} diff --git a/core/lib/dal/.sqlx/query-e7d0b7c132b80195dae7cbf50355eb148aa6d1dbd69bf3fe48522101a6ea0bcb.json b/core/lib/dal/.sqlx/query-e7d0b7c132b80195dae7cbf50355eb148aa6d1dbd69bf3fe48522101a6ea0bcb.json deleted file mode 100644 index 576484cd4206..000000000000 --- a/core/lib/dal/.sqlx/query-e7d0b7c132b80195dae7cbf50355eb148aa6d1dbd69bf3fe48522101a6ea0bcb.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "\n WITH\n available_batches AS (\n SELECT\n MAX(number) AS \"last_batch\"\n FROM\n l1_batches\n ),\n processed_batches AS (\n SELECT\n COALESCE(MAX(l1_batch_number), $1) + $2 AS \"last_ready_batch\"\n FROM\n vm_runner_bwip\n WHERE\n time_taken IS NOT NULL\n )\n SELECT\n LEAST(last_batch, last_ready_batch) AS \"last_ready_batch!\"\n FROM\n available_batches\n FULL JOIN processed_batches ON TRUE\n ", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "last_ready_batch!", - "type_info": "Int8" - } - ], - "parameters": { - "Left": [ - "Int8", - "Int8" - ] - }, - "nullable": [ - true - ] - }, - "hash": "e7d0b7c132b80195dae7cbf50355eb148aa6d1dbd69bf3fe48522101a6ea0bcb" -} diff --git a/core/lib/dal/.sqlx/query-dc481f59aae632ff6f5fa23f5c5c82627a936f7ea9f6c354eca4bea76fac6b10.json b/core/lib/dal/.sqlx/query-eb9bfcb97ab76409c0794ecdc7ae2e73723728d6e2061728c030045757016619.json similarity index 68% rename from core/lib/dal/.sqlx/query-dc481f59aae632ff6f5fa23f5c5c82627a936f7ea9f6c354eca4bea76fac6b10.json rename to core/lib/dal/.sqlx/query-eb9bfcb97ab76409c0794ecdc7ae2e73723728d6e2061728c030045757016619.json index 77263c2a4dd7..09d730b2ac9e 100644 --- a/core/lib/dal/.sqlx/query-dc481f59aae632ff6f5fa23f5c5c82627a936f7ea9f6c354eca4bea76fac6b10.json +++ b/core/lib/dal/.sqlx/query-eb9bfcb97ab76409c0794ecdc7ae2e73723728d6e2061728c030045757016619.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n MAX(number) AS \"number\"\n FROM\n l1_batches\n WHERE\n hash IS NOT NULL\n ", + "query": "\n SELECT\n MAX(number) AS \"number\"\n FROM\n l1_batches\n WHERE\n is_sealed\n AND hash IS NOT NULL\n ", "describe": { "columns": [ { @@ -16,5 +16,5 @@ null ] }, - "hash": "dc481f59aae632ff6f5fa23f5c5c82627a936f7ea9f6c354eca4bea76fac6b10" + "hash": "eb9bfcb97ab76409c0794ecdc7ae2e73723728d6e2061728c030045757016619" } diff --git a/core/lib/dal/.sqlx/query-eeb101b29c28fd65a93ecbdb21176c368dae5fdd4b47664e00890bd47e21e0c2.json b/core/lib/dal/.sqlx/query-eeb101b29c28fd65a93ecbdb21176c368dae5fdd4b47664e00890bd47e21e0c2.json new file mode 100644 index 000000000000..e7b956a56c77 --- /dev/null +++ b/core/lib/dal/.sqlx/query-eeb101b29c28fd65a93ecbdb21176c368dae5fdd4b47664e00890bd47e21e0c2.json @@ -0,0 +1,17 @@ +{ + "db_name": "PostgreSQL", + "query": "\n INSERT INTO\n l1_batches (\n number,\n timestamp,\n l1_gas_price,\n l2_fair_gas_price,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n initial_bootloader_heap_content,\n used_contract_hashes,\n created_at,\n updated_at,\n is_sealed\n )\n VALUES\n (\n $1,\n $2,\n $3,\n $4,\n 0,\n 0,\n ''::bytea,\n '{}'::bytea[],\n '{}'::jsonb,\n '{}'::jsonb,\n NOW(),\n NOW(),\n FALSE\n )\n ", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Int8", + "Int8", + "Int8", + "Int8" + ] + }, + "nullable": [] + }, + "hash": "eeb101b29c28fd65a93ecbdb21176c368dae5fdd4b47664e00890bd47e21e0c2" +} diff --git a/core/lib/dal/.sqlx/query-cb98d84fc34af1e4a4c2f427c5bb4afd384063ae394a847b26304dd18d490ab4.json b/core/lib/dal/.sqlx/query-f724566464e77fedc01169c20ff0551b2259488f58f23bec8e8a479ccd40374b.json similarity index 74% rename from core/lib/dal/.sqlx/query-cb98d84fc34af1e4a4c2f427c5bb4afd384063ae394a847b26304dd18d490ab4.json rename to core/lib/dal/.sqlx/query-f724566464e77fedc01169c20ff0551b2259488f58f23bec8e8a479ccd40374b.json index 732992595c73..3c519a351622 100644 --- a/core/lib/dal/.sqlx/query-cb98d84fc34af1e4a4c2f427c5bb4afd384063ae394a847b26304dd18d490ab4.json +++ b/core/lib/dal/.sqlx/query-f724566464e77fedc01169c20ff0551b2259488f58f23bec8e8a479ccd40374b.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n timestamp,\n hash\n FROM\n l1_batches\n WHERE\n number = $1\n ", + "query": "\n SELECT\n timestamp,\n hash\n FROM\n l1_batches\n WHERE\n is_sealed\n AND number = $1\n ", "describe": { "columns": [ { @@ -24,5 +24,5 @@ true ] }, - "hash": "cb98d84fc34af1e4a4c2f427c5bb4afd384063ae394a847b26304dd18d490ab4" + "hash": "f724566464e77fedc01169c20ff0551b2259488f58f23bec8e8a479ccd40374b" } diff --git a/core/lib/dal/migrations/20240910112120_unsealed_batches_in_db.down.sql b/core/lib/dal/migrations/20240910112120_unsealed_batches_in_db.down.sql new file mode 100644 index 000000000000..8b7a4c549e88 --- /dev/null +++ b/core/lib/dal/migrations/20240910112120_unsealed_batches_in_db.down.sql @@ -0,0 +1,2 @@ +ALTER TABLE l1_batches + RENAME COLUMN is_sealed TO is_finished; diff --git a/core/lib/dal/migrations/20240910112120_unsealed_batches_in_db.up.sql b/core/lib/dal/migrations/20240910112120_unsealed_batches_in_db.up.sql new file mode 100644 index 000000000000..e6f351b68687 --- /dev/null +++ b/core/lib/dal/migrations/20240910112120_unsealed_batches_in_db.up.sql @@ -0,0 +1,2 @@ +ALTER TABLE l1_batches + RENAME COLUMN is_finished TO is_sealed; diff --git a/core/lib/dal/src/blocks_dal.rs b/core/lib/dal/src/blocks_dal.rs index 1f4cc3b0b98c..bd7ac9466669 100644 --- a/core/lib/dal/src/blocks_dal.rs +++ b/core/lib/dal/src/blocks_dal.rs @@ -20,6 +20,7 @@ use zksync_types::{ StorageOracleInfo, }, commitment::{L1BatchCommitmentArtifacts, L1BatchWithMetadata}, + fee_model::BatchFeeInput, l2_to_l1_log::UserL2ToL1Log, writes::TreeWrite, Address, Bloom, L1BatchNumber, L2BlockNumber, ProtocolVersionId, H256, U256, @@ -105,6 +106,8 @@ impl BlocksDal<'_, '_> { MAX(number) AS "number" FROM l1_batches + WHERE + is_sealed "# ) .instrument("get_sealed_l1_batch_number") @@ -140,6 +143,8 @@ impl BlocksDal<'_, '_> { MIN(number) AS "number" FROM l1_batches + WHERE + is_sealed "# ) .instrument("get_earliest_l1_batch_number") @@ -176,7 +181,8 @@ impl BlocksDal<'_, '_> { FROM l1_batches WHERE - hash IS NOT NULL + is_sealed + AND hash IS NOT NULL "# ) .instrument("get_last_l1_batch_number_with_tree_data") @@ -199,7 +205,8 @@ impl BlocksDal<'_, '_> { FROM l1_batches WHERE - hash IS NOT NULL + is_sealed + AND hash IS NOT NULL AND commitment IS NULL ORDER BY number @@ -227,7 +234,8 @@ impl BlocksDal<'_, '_> { FROM l1_batches WHERE - hash IS NOT NULL + is_sealed + AND hash IS NOT NULL AND commitment IS NULL ORDER BY number DESC @@ -255,7 +263,8 @@ impl BlocksDal<'_, '_> { FROM l1_batches WHERE - hash IS NOT NULL + is_sealed + AND hash IS NOT NULL "# ) .instrument("get_earliest_l1_batch_number_with_metadata") @@ -280,9 +289,12 @@ impl BlocksDal<'_, '_> { FROM l1_batches WHERE - eth_commit_tx_id = $1 - OR eth_prove_tx_id = $1 - OR eth_execute_tx_id = $1 + is_sealed + AND ( + eth_commit_tx_id = $1 + OR eth_prove_tx_id = $1 + OR eth_execute_tx_id = $1 + ) "#, eth_tx_id as i32 ) @@ -557,7 +569,68 @@ impl BlocksDal<'_, '_> { Ok(()) } + /// Inserts an unsealed L1 batch with some basic information (i.e. runtime related data is either + /// null or set to default value for the corresponding type). pub async fn insert_l1_batch( + &mut self, + number: L1BatchNumber, + timestamp: u64, + batch_fee_input: BatchFeeInput, + ) -> DalResult<()> { + let instrumentation = Instrumented::new("insert_l1_batch").with_arg("number", &number); + let query = sqlx::query!( + r#" + INSERT INTO + l1_batches ( + number, + timestamp, + l1_gas_price, + l2_fair_gas_price, + l1_tx_count, + l2_tx_count, + bloom, + priority_ops_onchain_data, + initial_bootloader_heap_content, + used_contract_hashes, + created_at, + updated_at, + is_sealed + ) + VALUES + ( + $1, + $2, + $3, + $4, + 0, + 0, + ''::bytea, + '{}'::bytea[], + '{}'::jsonb, + '{}'::jsonb, + NOW(), + NOW(), + FALSE + ) + "#, + i64::from(number.0), + timestamp as i64, + batch_fee_input.l1_gas_price() as i64, + batch_fee_input.fair_l2_gas_price() as i64, + ); + + let mut transaction = self.storage.start_transaction().await?; + instrumentation + .with(query) + .execute(&mut transaction) + .await?; + transaction.commit().await + } + + /// Marks provided L1 batch as sealed and populates it with all the runtime information. + /// + /// Errors if the batch does not exist. + pub async fn mark_l1_batch_as_sealed( &mut self, header: &L1BatchHeader, initial_bootloader_contents: &[(usize, U256)], @@ -565,9 +638,9 @@ impl BlocksDal<'_, '_> { storage_refunds: &[u32], pubdata_costs: &[i32], predicted_circuits_by_type: CircuitStatistic, // predicted number of circuits for each circuit type - ) -> DalResult<()> { + ) -> anyhow::Result<()> { let initial_bootloader_contents_len = initial_bootloader_contents.len(); - let instrumentation = Instrumented::new("insert_l1_batch") + let instrumentation = Instrumented::new("mark_l1_batch_as_sealed") .with_arg("number", &header.number) .with_arg( "initial_bootloader_contents.len", @@ -594,61 +667,34 @@ impl BlocksDal<'_, '_> { let query = sqlx::query!( r#" - INSERT INTO - l1_batches ( - number, - l1_tx_count, - l2_tx_count, - timestamp, - 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, - bootloader_code_hash, - default_aa_code_hash, - protocol_version, - system_logs, - storage_refunds, - pubdata_costs, - pubdata_input, - predicted_circuits_by_type, - 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, - NOW(), - NOW() - ) + UPDATE l1_batches + SET + l1_tx_count = $2, + l2_tx_count = $3, + l2_to_l1_messages = $4, + bloom = $5, + priority_ops_onchain_data = $6, + predicted_commit_gas_cost = $7, + predicted_prove_gas_cost = $8, + predicted_execute_gas_cost = $9, + initial_bootloader_heap_content = $10, + used_contract_hashes = $11, + bootloader_code_hash = $12, + default_aa_code_hash = $13, + protocol_version = $14, + system_logs = $15, + storage_refunds = $16, + pubdata_costs = $17, + pubdata_input = $18, + predicted_circuits_by_type = $19, + updated_at = NOW(), + is_sealed = TRUE + WHERE + number = $1 "#, i64::from(header.number.0), i32::from(header.l1_tx_count), i32::from(header.l2_tx_count), - header.timestamp as i64, &header.l2_to_l1_messages, header.bloom.as_bytes(), &priority_onchain_data, @@ -666,13 +712,21 @@ impl BlocksDal<'_, '_> { pubdata_input, serde_json::to_value(predicted_circuits_by_type).unwrap(), ); - let mut transaction = self.storage.start_transaction().await?; - instrumentation + let update_result = instrumentation .with(query) .execute(&mut transaction) .await?; - transaction.commit().await + transaction.commit().await?; + + if update_result.rows_affected() == 0 { + anyhow::bail!( + "L1 batch sealing failed: batch #{} was not found", + header.number + ); + } + + Ok(()) } pub async fn insert_l2_block(&mut self, l2_block_header: &L2BlockHeader) -> DalResult<()> { @@ -1697,7 +1751,8 @@ impl BlocksDal<'_, '_> { FROM l1_batches WHERE - number = $1 + is_sealed + AND number = $1 "#, i64::from(number.0) ) @@ -1721,7 +1776,8 @@ impl BlocksDal<'_, '_> { FROM l1_batches WHERE - number = $1 + is_sealed + AND number = $1 "#, i64::from(number.0) ) @@ -2036,7 +2092,8 @@ impl BlocksDal<'_, '_> { FROM l1_batches WHERE - eth_commit_tx_id IS NULL + is_sealed + AND eth_commit_tx_id IS NULL AND number > 0 ORDER BY number @@ -2058,7 +2115,8 @@ impl BlocksDal<'_, '_> { FROM l1_batches WHERE - eth_prove_tx_id IS NULL + is_sealed + AND eth_prove_tx_id IS NULL AND number > 0 ORDER BY number @@ -2080,7 +2138,8 @@ impl BlocksDal<'_, '_> { FROM l1_batches WHERE - eth_execute_tx_id IS NULL + is_sealed + AND eth_execute_tx_id IS NULL AND number > 0 ORDER BY number @@ -2175,7 +2234,8 @@ impl BlocksDal<'_, '_> { FROM l1_batches WHERE - protocol_version = $1 + is_sealed + AND protocol_version = $1 "#, protocol_version as i32 ) @@ -2481,8 +2541,10 @@ impl BlocksDal<'_, '_> { Ok(()) } - pub async fn insert_mock_l1_batch(&mut self, header: &L1BatchHeader) -> DalResult<()> { - self.insert_l1_batch( + pub async fn insert_mock_l1_batch(&mut self, header: &L1BatchHeader) -> anyhow::Result<()> { + self.insert_l1_batch(header.number, header.timestamp, BatchFeeInput::default()) + .await?; + self.mark_l1_batch_as_sealed( header, &[], Default::default(), @@ -2759,7 +2821,11 @@ mod tests { execute: 10, }; conn.blocks_dal() - .insert_l1_batch(&header, &[], predicted_gas, &[], &[], Default::default()) + .insert_l1_batch(header.number, header.timestamp, BatchFeeInput::default()) + .await + .unwrap(); + conn.blocks_dal() + .mark_l1_batch_as_sealed(&header, &[], predicted_gas, &[], &[], Default::default()) .await .unwrap(); @@ -2767,7 +2833,11 @@ mod tests { header.timestamp += 100; predicted_gas += predicted_gas; conn.blocks_dal() - .insert_l1_batch(&header, &[], predicted_gas, &[], &[], Default::default()) + .insert_l1_batch(header.number, header.timestamp, BatchFeeInput::default()) + .await + .unwrap(); + conn.blocks_dal() + .mark_l1_batch_as_sealed(&header, &[], predicted_gas, &[], &[], Default::default()) .await .unwrap(); diff --git a/core/lib/dal/src/blocks_web3_dal.rs b/core/lib/dal/src/blocks_web3_dal.rs index 36a4acc0a6db..96776a378df8 100644 --- a/core/lib/dal/src/blocks_web3_dal.rs +++ b/core/lib/dal/src/blocks_web3_dal.rs @@ -646,6 +646,8 @@ impl BlocksWeb3Dal<'_, '_> { (MAX(number) + 1) FROM l1_batches + WHERE + is_sealed ) ) AS "l1_batch_number!", miniblocks.timestamp, diff --git a/core/lib/dal/src/consensus_dal.rs b/core/lib/dal/src/consensus_dal.rs index 2dca58e2a6a6..036c27d645b6 100644 --- a/core/lib/dal/src/consensus_dal.rs +++ b/core/lib/dal/src/consensus_dal.rs @@ -588,6 +588,8 @@ impl ConsensusDal<'_, '_> { (MAX(number) + 1) FROM l1_batches + WHERE + is_sealed ), ( SELECT diff --git a/core/lib/dal/src/data_availability_dal.rs b/core/lib/dal/src/data_availability_dal.rs index 24048ec4fa19..789803fdb825 100644 --- a/core/lib/dal/src/data_availability_dal.rs +++ b/core/lib/dal/src/data_availability_dal.rs @@ -189,7 +189,8 @@ impl DataAvailabilityDal<'_, '_> { l1_batches LEFT JOIN data_availability ON data_availability.l1_batch_number = l1_batches.number WHERE - eth_commit_tx_id IS NULL + is_sealed + AND eth_commit_tx_id IS NULL AND number != 0 AND data_availability.blob_id IS NULL AND pubdata_input IS NOT NULL diff --git a/core/lib/dal/src/protocol_versions_dal.rs b/core/lib/dal/src/protocol_versions_dal.rs index 8cb5094fd49e..5ade92e94447 100644 --- a/core/lib/dal/src/protocol_versions_dal.rs +++ b/core/lib/dal/src/protocol_versions_dal.rs @@ -373,6 +373,8 @@ impl ProtocolVersionsDal<'_, '_> { protocol_version FROM l1_batches + WHERE + is_sealed ORDER BY number DESC LIMIT diff --git a/core/lib/dal/src/storage_web3_dal.rs b/core/lib/dal/src/storage_web3_dal.rs index f54ac766ee8c..3407adc96974 100644 --- a/core/lib/dal/src/storage_web3_dal.rs +++ b/core/lib/dal/src/storage_web3_dal.rs @@ -178,6 +178,8 @@ impl StorageWeb3Dal<'_, '_> { MAX(number) + 1 FROM l1_batches + WHERE + is_sealed ), ( SELECT diff --git a/core/lib/dal/src/sync_dal.rs b/core/lib/dal/src/sync_dal.rs index ec6ee0f92812..0d60c1f51c38 100644 --- a/core/lib/dal/src/sync_dal.rs +++ b/core/lib/dal/src/sync_dal.rs @@ -35,6 +35,8 @@ impl SyncDal<'_, '_> { (MAX(number) + 1) FROM l1_batches + WHERE + is_sealed ), ( SELECT diff --git a/core/lib/dal/src/vm_runner_dal.rs b/core/lib/dal/src/vm_runner_dal.rs index 37ef1517d54a..79b66caaf698 100644 --- a/core/lib/dal/src/vm_runner_dal.rs +++ b/core/lib/dal/src/vm_runner_dal.rs @@ -42,6 +42,8 @@ impl VmRunnerDal<'_, '_> { MAX(number) AS "last_batch" FROM l1_batches + WHERE + is_sealed ), processed_batches AS ( SELECT @@ -201,6 +203,8 @@ impl VmRunnerDal<'_, '_> { MAX(number) AS "last_batch" FROM l1_batches + WHERE + is_sealed ), processed_batches AS ( SELECT diff --git a/core/node/genesis/src/lib.rs b/core/node/genesis/src/lib.rs index 1f30d314bb06..989da710a36c 100644 --- a/core/node/genesis/src/lib.rs +++ b/core/node/genesis/src/lib.rs @@ -413,6 +413,14 @@ pub async fn create_genesis_l1_batch( transaction .blocks_dal() .insert_l1_batch( + genesis_l1_batch_header.number, + genesis_l1_batch_header.timestamp, + BatchFeeInput::default(), + ) + .await?; + transaction + .blocks_dal() + .mark_l1_batch_as_sealed( &genesis_l1_batch_header, &[], BlockGasCount::default(), diff --git a/core/node/node_sync/src/external_io.rs b/core/node/node_sync/src/external_io.rs index b7b8930c4957..7d10184c8e73 100644 --- a/core/node/node_sync/src/external_io.rs +++ b/core/node/node_sync/src/external_io.rs @@ -236,6 +236,17 @@ impl StateKeeperIO for ExternalIO { "L2 block number mismatch: expected {}, got {first_l2_block_number}", cursor.next_l2_block ); + + self.pool + .connection() + .await? + .blocks_dal() + .insert_l1_batch( + cursor.l1_batch, + params.first_l2_block.timestamp, + params.fee_input, + ) + .await?; return Ok(Some(params)); } other => { diff --git a/core/node/state_keeper/src/io/mempool.rs b/core/node/state_keeper/src/io/mempool.rs index 5734977538bd..ed7bb491ea58 100644 --- a/core/node/state_keeper/src/io/mempool.rs +++ b/core/node/state_keeper/src/io/mempool.rs @@ -203,6 +203,13 @@ impl StateKeeperIO for MempoolIO { continue; } + self.pool + .connection() + .await? + .blocks_dal() + .insert_l1_batch(cursor.l1_batch, timestamp, self.filter.fee_input) + .await?; + return Ok(Some(L1BatchParams { protocol_version, validation_computational_gas_limit: self.validation_computational_gas_limit, diff --git a/core/node/state_keeper/src/io/persistence.rs b/core/node/state_keeper/src/io/persistence.rs index 24b1ffca631c..c1dd7593510c 100644 --- a/core/node/state_keeper/src/io/persistence.rs +++ b/core/node/state_keeper/src/io/persistence.rs @@ -397,7 +397,7 @@ mod tests { let mut output_handler = OutputHandler::new(Box::new(persistence)) .with_handler(Box::new(TreeWritesPersistence::new(pool.clone()))); tokio::spawn(l2_block_sealer.run()); - execute_mock_batch(&mut output_handler).await; + execute_mock_batch(&mut output_handler, &pool).await; // Check that L2 block #1 and L1 batch #1 are persisted. let mut storage = pool.connection().await.unwrap(); @@ -446,9 +446,23 @@ mod tests { assert_eq!(actual_index, expected_index); } - async fn execute_mock_batch(output_handler: &mut OutputHandler) -> H256 { + async fn execute_mock_batch( + output_handler: &mut OutputHandler, + pool: &ConnectionPool, + ) -> H256 { let l1_batch_env = default_l1_batch_env(1, 1, Address::random()); let mut updates = UpdatesManager::new(&l1_batch_env, &default_system_env()); + pool.connection() + .await + .unwrap() + .blocks_dal() + .insert_l1_batch( + l1_batch_env.number, + l1_batch_env.timestamp, + l1_batch_env.fee_input, + ) + .await + .unwrap(); let tx = create_transaction(10, 100); let tx_hash = tx.hash(); @@ -532,7 +546,7 @@ mod tests { let mut output_handler = OutputHandler::new(Box::new(persistence)); tokio::spawn(l2_block_sealer.run()); - let tx_hash = execute_mock_batch(&mut output_handler).await; + let tx_hash = execute_mock_batch(&mut output_handler, &pool).await; // Check that the transaction is persisted. let mut storage = pool.connection().await.unwrap(); diff --git a/core/node/state_keeper/src/io/seal_logic/mod.rs b/core/node/state_keeper/src/io/seal_logic/mod.rs index 0dae7fae908a..e8b45af033c3 100644 --- a/core/node/state_keeper/src/io/seal_logic/mod.rs +++ b/core/node/state_keeper/src/io/seal_logic/mod.rs @@ -141,7 +141,7 @@ impl UpdatesManager { transaction .blocks_dal() - .insert_l1_batch( + .mark_l1_batch_as_sealed( &l1_batch, &final_bootloader_memory, self.pending_l1_gas_count(), diff --git a/prover/crates/lib/keystore/src/utils.rs b/prover/crates/lib/keystore/src/utils.rs index d9bb3b47dbb0..10504292d64f 100644 --- a/prover/crates/lib/keystore/src/utils.rs +++ b/prover/crates/lib/keystore/src/utils.rs @@ -115,6 +115,7 @@ pub fn calculate_snark_vk_hash(keystore: &Keystore) -> anyhow::Result { #[cfg(test)] mod tests { use std::str::FromStr; + use zksync_utils::env::Workspace; use super::*; From 2542b092ae4209fd478929e2794f69de9e8b6c1a Mon Sep 17 00:00:00 2001 From: Daniyar Itegulov Date: Thu, 12 Sep 2024 19:12:41 +1000 Subject: [PATCH 02/14] cover most batch-related queries with `is_sealed` --- ...9566ff0f991165cc8c46b3bf171d18544948.json} | 4 +- ...2734a136e9b912856adfd15330e23919f4be.json} | 4 +- ...ed820f8869acb6f59aa6dd704c0f5b4e45ec.json} | 4 +- ...7791290f3bfff4de742f2a918a3fd4e5608c.json} | 4 +- ...4a4b0e84dd0dbc8115f265188ba286548a41.json} | 4 +- ...599d342aac90c62b2be0df784b7a9166a434.json} | 4 +- ...c5ab362f2450aece13b382b36a0d235c25aa.json} | 4 +- ...3f0d1bd420874dc0b894dc44ad97b262d007.json} | 4 +- ...d0a2b72f141f36a682fb880ad76e19ea6914.json} | 4 +- ...d3b4c514a18d8a33ec978d3e8007af8d0c20.json} | 4 +- ...884fae97f10304b0bc1619a1a662d7d96d5b.json} | 4 +- ...f5295127ea9a4f68aaa1c68131b88891d456.json} | 4 +- ...c058f9ad703461a1f55c534bf3d9f48eb61b.json} | 4 +- ...195f0dc434be64cd34ac84977d1a6731ba12.json} | 4 +- core/lib/dal/src/blocks_dal.rs | 41 +++++++++++++------ 15 files changed, 56 insertions(+), 41 deletions(-) rename core/lib/dal/.sqlx/{query-2eb25bfcfc1114de825dc4eeb0605d7d1c9e649663f6e9444c4425821d0a5b71.json => query-00d2847d75afafffecf96542cfa89566ff0f991165cc8c46b3bf171d18544948.json} (72%) rename core/lib/dal/.sqlx/{query-65736a5b9b4ad364797dbedfc828f24785ae8bd2b4579203f05379e757a56f2b.json => query-10c1e781d307512aad982cf582e12734a136e9b912856adfd15330e23919f4be.json} (63%) rename core/lib/dal/.sqlx/{query-cf20dfb2b3d6a770b6f56417d407ad3caf76ed9fed031da9e04313073af2fb4a.json => query-1eb34ecfbe49d5ba063a8f8842eced820f8869acb6f59aa6dd704c0f5b4e45ec.json} (73%) rename core/lib/dal/.sqlx/{query-a2d02b71e3dcc29a2c0c20b44392cfbaf09164aecfa5eed8d7142518ad96abea.json => query-1ec14bf6f71bbab04275ffd90bc17791290f3bfff4de742f2a918a3fd4e5608c.json} (71%) rename core/lib/dal/.sqlx/{query-63f95c6cdcfd933e2cf8f62c0d408f2dce89f7b700896fcc0f242e0e15ba058e.json => query-2015ed86bc3d032e1ca34bd3604b4a4b0e84dd0dbc8115f265188ba286548a41.json} (83%) rename core/lib/dal/.sqlx/{query-25646383ecacf72e3f63b5c93a57a66d1e38fb6ca706c2affd4607d77be38de9.json => query-241a1a4432e12e77a902e13dbe00599d342aac90c62b2be0df784b7a9166a434.json} (73%) rename core/lib/dal/.sqlx/{query-2486f8404e8cfcb9c178acd6dccae32e8812becbe5ce85e63694385f015f2cfe.json => query-25df7ac382631c46d23956ba27d9c5ab362f2450aece13b382b36a0d235c25aa.json} (93%) rename core/lib/dal/.sqlx/{query-730095f41fd5e2ea376fd869887be82028e2865e646677ff67d0720ad17b1eac.json => query-353604cfbdd292fa6a71bae0bdf53f0d1bd420874dc0b894dc44ad97b262d007.json} (72%) rename core/lib/dal/.sqlx/{query-454e16ddb5e85285d0c4b9013bcce5d464ecc55c80b54bc16040226df7e297bd.json => query-883a8ae0dccc2b46ec512625784ed0a2b72f141f36a682fb880ad76e19ea6914.json} (92%) rename core/lib/dal/.sqlx/{query-0c95fbfb3a816bd49fd06e3a4f0a52daa202279bf612a9278f663deb78bc6e41.json => query-8cfde47f25cf65030f34e70edf83d3b4c514a18d8a33ec978d3e8007af8d0c20.json} (72%) rename core/lib/dal/.sqlx/{query-52bb6de515e1edf4dcf34a31600edb31cfd855014dfca5041833b9d5d9f7a55e.json => query-90f729db537d4170599bcbdf7035884fae97f10304b0bc1619a1a662d7d96d5b.json} (95%) rename core/lib/dal/.sqlx/{query-b7cd7c40282c2ca2287eef93ee79c69a9e494bf1f873291b4ae7bf68b7e3c549.json => query-b5b4fc97d4ce204841b2c48d0893f5295127ea9a4f68aaa1c68131b88891d456.json} (87%) rename core/lib/dal/.sqlx/{query-31f12a8c44124bb2ce31889ac5295f3823926f69cb1d54874878e6d6c301bfd8.json => query-cbc0e202a6da5092251f278d7dc5c058f9ad703461a1f55c534bf3d9f48eb61b.json} (74%) rename core/lib/dal/.sqlx/{query-77de28ce78e1e5827f03d7e7550aec881fb5d3cde2f3aad9a5db5629070d6b7c.json => query-f3e9de395a5aeadc8ae8cb95cec8195f0dc434be64cd34ac84977d1a6731ba12.json} (67%) diff --git a/core/lib/dal/.sqlx/query-2eb25bfcfc1114de825dc4eeb0605d7d1c9e649663f6e9444c4425821d0a5b71.json b/core/lib/dal/.sqlx/query-00d2847d75afafffecf96542cfa89566ff0f991165cc8c46b3bf171d18544948.json similarity index 72% rename from core/lib/dal/.sqlx/query-2eb25bfcfc1114de825dc4eeb0605d7d1c9e649663f6e9444c4425821d0a5b71.json rename to core/lib/dal/.sqlx/query-00d2847d75afafffecf96542cfa89566ff0f991165cc8c46b3bf171d18544948.json index 6b0ddef258fc..1cfcb9dbb01d 100644 --- a/core/lib/dal/.sqlx/query-2eb25bfcfc1114de825dc4eeb0605d7d1c9e649663f6e9444c4425821d0a5b71.json +++ b/core/lib/dal/.sqlx/query-00d2847d75afafffecf96542cfa89566ff0f991165cc8c46b3bf171d18544948.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n eth_commit_tx_id\n FROM\n l1_batches\n WHERE\n number = $1\n ", + "query": "\n SELECT\n eth_commit_tx_id\n FROM\n l1_batches\n WHERE\n is_sealed\n AND number = $1\n ", "describe": { "columns": [ { @@ -18,5 +18,5 @@ true ] }, - "hash": "2eb25bfcfc1114de825dc4eeb0605d7d1c9e649663f6e9444c4425821d0a5b71" + "hash": "00d2847d75afafffecf96542cfa89566ff0f991165cc8c46b3bf171d18544948" } diff --git a/core/lib/dal/.sqlx/query-65736a5b9b4ad364797dbedfc828f24785ae8bd2b4579203f05379e757a56f2b.json b/core/lib/dal/.sqlx/query-10c1e781d307512aad982cf582e12734a136e9b912856adfd15330e23919f4be.json similarity index 63% rename from core/lib/dal/.sqlx/query-65736a5b9b4ad364797dbedfc828f24785ae8bd2b4579203f05379e757a56f2b.json rename to core/lib/dal/.sqlx/query-10c1e781d307512aad982cf582e12734a136e9b912856adfd15330e23919f4be.json index af7bff984be5..0edf0f30778b 100644 --- a/core/lib/dal/.sqlx/query-65736a5b9b4ad364797dbedfc828f24785ae8bd2b4579203f05379e757a56f2b.json +++ b/core/lib/dal/.sqlx/query-10c1e781d307512aad982cf582e12734a136e9b912856adfd15330e23919f4be.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n COUNT(*) AS \"count!\"\n FROM\n l1_batches\n WHERE\n number = $1\n AND commitment = $2\n ", + "query": "\n SELECT\n COUNT(*) AS \"count!\"\n FROM\n l1_batches\n WHERE\n is_sealed\n AND number = $1\n AND commitment = $2\n ", "describe": { "columns": [ { @@ -19,5 +19,5 @@ null ] }, - "hash": "65736a5b9b4ad364797dbedfc828f24785ae8bd2b4579203f05379e757a56f2b" + "hash": "10c1e781d307512aad982cf582e12734a136e9b912856adfd15330e23919f4be" } diff --git a/core/lib/dal/.sqlx/query-cf20dfb2b3d6a770b6f56417d407ad3caf76ed9fed031da9e04313073af2fb4a.json b/core/lib/dal/.sqlx/query-1eb34ecfbe49d5ba063a8f8842eced820f8869acb6f59aa6dd704c0f5b4e45ec.json similarity index 73% rename from core/lib/dal/.sqlx/query-cf20dfb2b3d6a770b6f56417d407ad3caf76ed9fed031da9e04313073af2fb4a.json rename to core/lib/dal/.sqlx/query-1eb34ecfbe49d5ba063a8f8842eced820f8869acb6f59aa6dd704c0f5b4e45ec.json index 853acb9f71a6..a101edbb9ea5 100644 --- a/core/lib/dal/.sqlx/query-cf20dfb2b3d6a770b6f56417d407ad3caf76ed9fed031da9e04313073af2fb4a.json +++ b/core/lib/dal/.sqlx/query-1eb34ecfbe49d5ba063a8f8842eced820f8869acb6f59aa6dd704c0f5b4e45ec.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n storage_refunds,\n pubdata_costs\n FROM\n l1_batches\n WHERE\n number = $1\n ", + "query": "\n SELECT\n storage_refunds,\n pubdata_costs\n FROM\n l1_batches\n WHERE\n is_sealed\n AND number = $1\n ", "describe": { "columns": [ { @@ -24,5 +24,5 @@ true ] }, - "hash": "cf20dfb2b3d6a770b6f56417d407ad3caf76ed9fed031da9e04313073af2fb4a" + "hash": "1eb34ecfbe49d5ba063a8f8842eced820f8869acb6f59aa6dd704c0f5b4e45ec" } diff --git a/core/lib/dal/.sqlx/query-a2d02b71e3dcc29a2c0c20b44392cfbaf09164aecfa5eed8d7142518ad96abea.json b/core/lib/dal/.sqlx/query-1ec14bf6f71bbab04275ffd90bc17791290f3bfff4de742f2a918a3fd4e5608c.json similarity index 71% rename from core/lib/dal/.sqlx/query-a2d02b71e3dcc29a2c0c20b44392cfbaf09164aecfa5eed8d7142518ad96abea.json rename to core/lib/dal/.sqlx/query-1ec14bf6f71bbab04275ffd90bc17791290f3bfff4de742f2a918a3fd4e5608c.json index fc36e47b54c8..1078e0b57f61 100644 --- a/core/lib/dal/.sqlx/query-a2d02b71e3dcc29a2c0c20b44392cfbaf09164aecfa5eed8d7142518ad96abea.json +++ b/core/lib/dal/.sqlx/query-1ec14bf6f71bbab04275ffd90bc17791290f3bfff4de742f2a918a3fd4e5608c.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n initial_bootloader_heap_content\n FROM\n l1_batches\n WHERE\n number = $1\n ", + "query": "\n SELECT\n initial_bootloader_heap_content\n FROM\n l1_batches\n WHERE\n is_sealed\n AND number = $1\n ", "describe": { "columns": [ { @@ -18,5 +18,5 @@ false ] }, - "hash": "a2d02b71e3dcc29a2c0c20b44392cfbaf09164aecfa5eed8d7142518ad96abea" + "hash": "1ec14bf6f71bbab04275ffd90bc17791290f3bfff4de742f2a918a3fd4e5608c" } diff --git a/core/lib/dal/.sqlx/query-63f95c6cdcfd933e2cf8f62c0d408f2dce89f7b700896fcc0f242e0e15ba058e.json b/core/lib/dal/.sqlx/query-2015ed86bc3d032e1ca34bd3604b4a4b0e84dd0dbc8115f265188ba286548a41.json similarity index 83% rename from core/lib/dal/.sqlx/query-63f95c6cdcfd933e2cf8f62c0d408f2dce89f7b700896fcc0f242e0e15ba058e.json rename to core/lib/dal/.sqlx/query-2015ed86bc3d032e1ca34bd3604b4a4b0e84dd0dbc8115f265188ba286548a41.json index cb68e7622524..f8dcb32bcbd8 100644 --- a/core/lib/dal/.sqlx/query-63f95c6cdcfd933e2cf8f62c0d408f2dce89f7b700896fcc0f242e0e15ba058e.json +++ b/core/lib/dal/.sqlx/query-2015ed86bc3d032e1ca34bd3604b4a4b0e84dd0dbc8115f265188ba286548a41.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n number,\n l1_batches.timestamp,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n hash,\n commitment,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_merkle_root,\n rollup_last_leaf_index,\n zkporter_is_available,\n l1_batches.bootloader_code_hash,\n l1_batches.default_aa_code_hash,\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 pubdata_input\n FROM\n l1_batches\n LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number\n LEFT JOIN data_availability ON data_availability.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 AND (\n data_availability.inclusion_data IS NOT NULL\n OR $4 IS FALSE\n )\n ORDER BY\n number\n LIMIT\n $5\n ", + "query": "\n SELECT\n number,\n l1_batches.timestamp,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n hash,\n commitment,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_merkle_root,\n rollup_last_leaf_index,\n zkporter_is_available,\n l1_batches.bootloader_code_hash,\n l1_batches.default_aa_code_hash,\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 pubdata_input\n FROM\n l1_batches\n LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number\n LEFT JOIN data_availability ON data_availability.l1_batch_number = l1_batches.number\n JOIN protocol_versions ON protocol_versions.id = l1_batches.protocol_version\n WHERE\n is_sealed\n AND 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 AND (\n data_availability.inclusion_data IS NOT NULL\n OR $4 IS FALSE\n )\n ORDER BY\n number\n LIMIT\n $5\n ", "describe": { "columns": [ { @@ -172,5 +172,5 @@ true ] }, - "hash": "63f95c6cdcfd933e2cf8f62c0d408f2dce89f7b700896fcc0f242e0e15ba058e" + "hash": "2015ed86bc3d032e1ca34bd3604b4a4b0e84dd0dbc8115f265188ba286548a41" } diff --git a/core/lib/dal/.sqlx/query-25646383ecacf72e3f63b5c93a57a66d1e38fb6ca706c2affd4607d77be38de9.json b/core/lib/dal/.sqlx/query-241a1a4432e12e77a902e13dbe00599d342aac90c62b2be0df784b7a9166a434.json similarity index 73% rename from core/lib/dal/.sqlx/query-25646383ecacf72e3f63b5c93a57a66d1e38fb6ca706c2affd4607d77be38de9.json rename to core/lib/dal/.sqlx/query-241a1a4432e12e77a902e13dbe00599d342aac90c62b2be0df784b7a9166a434.json index 8d35e81b216c..213014ebe504 100644 --- a/core/lib/dal/.sqlx/query-25646383ecacf72e3f63b5c93a57a66d1e38fb6ca706c2affd4607d77be38de9.json +++ b/core/lib/dal/.sqlx/query-241a1a4432e12e77a902e13dbe00599d342aac90c62b2be0df784b7a9166a434.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n hash,\n rollup_last_leaf_index\n FROM\n l1_batches\n WHERE\n number = $1\n ", + "query": "\n SELECT\n hash,\n rollup_last_leaf_index\n FROM\n l1_batches\n WHERE\n is_sealed\n AND number = $1\n ", "describe": { "columns": [ { @@ -24,5 +24,5 @@ true ] }, - "hash": "25646383ecacf72e3f63b5c93a57a66d1e38fb6ca706c2affd4607d77be38de9" + "hash": "241a1a4432e12e77a902e13dbe00599d342aac90c62b2be0df784b7a9166a434" } diff --git a/core/lib/dal/.sqlx/query-2486f8404e8cfcb9c178acd6dccae32e8812becbe5ce85e63694385f015f2cfe.json b/core/lib/dal/.sqlx/query-25df7ac382631c46d23956ba27d9c5ab362f2450aece13b382b36a0d235c25aa.json similarity index 93% rename from core/lib/dal/.sqlx/query-2486f8404e8cfcb9c178acd6dccae32e8812becbe5ce85e63694385f015f2cfe.json rename to core/lib/dal/.sqlx/query-25df7ac382631c46d23956ba27d9c5ab362f2450aece13b382b36a0d235c25aa.json index f28e3d044ccc..287f80bd7c38 100644 --- a/core/lib/dal/.sqlx/query-2486f8404e8cfcb9c178acd6dccae32e8812becbe5ce85e63694385f015f2cfe.json +++ b/core/lib/dal/.sqlx/query-25df7ac382631c46d23956ba27d9c5ab362f2450aece13b382b36a0d235c25aa.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n number,\n timestamp,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n hash,\n commitment,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_merkle_root,\n rollup_last_leaf_index,\n zkporter_is_available,\n bootloader_code_hash,\n default_aa_code_hash,\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 pubdata_input\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 ", + "query": "\n SELECT\n number,\n timestamp,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n hash,\n commitment,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_merkle_root,\n rollup_last_leaf_index,\n zkporter_is_available,\n bootloader_code_hash,\n default_aa_code_hash,\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 pubdata_input\n FROM\n l1_batches\n LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number\n WHERE\n is_sealed\n AND number BETWEEN $1 AND $2\n ORDER BY\n number\n LIMIT\n $3\n ", "describe": { "columns": [ { @@ -170,5 +170,5 @@ true ] }, - "hash": "2486f8404e8cfcb9c178acd6dccae32e8812becbe5ce85e63694385f015f2cfe" + "hash": "25df7ac382631c46d23956ba27d9c5ab362f2450aece13b382b36a0d235c25aa" } diff --git a/core/lib/dal/.sqlx/query-730095f41fd5e2ea376fd869887be82028e2865e646677ff67d0720ad17b1eac.json b/core/lib/dal/.sqlx/query-353604cfbdd292fa6a71bae0bdf53f0d1bd420874dc0b894dc44ad97b262d007.json similarity index 72% rename from core/lib/dal/.sqlx/query-730095f41fd5e2ea376fd869887be82028e2865e646677ff67d0720ad17b1eac.json rename to core/lib/dal/.sqlx/query-353604cfbdd292fa6a71bae0bdf53f0d1bd420874dc0b894dc44ad97b262d007.json index e6d2f72575e3..59105e74f687 100644 --- a/core/lib/dal/.sqlx/query-730095f41fd5e2ea376fd869887be82028e2865e646677ff67d0720ad17b1eac.json +++ b/core/lib/dal/.sqlx/query-353604cfbdd292fa6a71bae0bdf53f0d1bd420874dc0b894dc44ad97b262d007.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n tree_writes\n FROM\n l1_batches\n WHERE\n number = $1\n ", + "query": "\n SELECT\n tree_writes\n FROM\n l1_batches\n WHERE\n is_sealed\n AND number = $1\n ", "describe": { "columns": [ { @@ -18,5 +18,5 @@ true ] }, - "hash": "730095f41fd5e2ea376fd869887be82028e2865e646677ff67d0720ad17b1eac" + "hash": "353604cfbdd292fa6a71bae0bdf53f0d1bd420874dc0b894dc44ad97b262d007" } diff --git a/core/lib/dal/.sqlx/query-454e16ddb5e85285d0c4b9013bcce5d464ecc55c80b54bc16040226df7e297bd.json b/core/lib/dal/.sqlx/query-883a8ae0dccc2b46ec512625784ed0a2b72f141f36a682fb880ad76e19ea6914.json similarity index 92% rename from core/lib/dal/.sqlx/query-454e16ddb5e85285d0c4b9013bcce5d464ecc55c80b54bc16040226df7e297bd.json rename to core/lib/dal/.sqlx/query-883a8ae0dccc2b46ec512625784ed0a2b72f141f36a682fb880ad76e19ea6914.json index 4a73fde57e29..2f55e6d1a7d4 100644 --- a/core/lib/dal/.sqlx/query-454e16ddb5e85285d0c4b9013bcce5d464ecc55c80b54bc16040226df7e297bd.json +++ b/core/lib/dal/.sqlx/query-883a8ae0dccc2b46ec512625784ed0a2b72f141f36a682fb880ad76e19ea6914.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n number,\n l1_tx_count,\n l2_tx_count,\n timestamp,\n l2_to_l1_messages,\n bloom,\n priority_ops_onchain_data,\n used_contract_hashes,\n bootloader_code_hash,\n default_aa_code_hash,\n protocol_version,\n system_logs,\n pubdata_input\n FROM\n l1_batches\n WHERE\n number = $1\n ", + "query": "\n SELECT\n number,\n l1_tx_count,\n l2_tx_count,\n timestamp,\n l2_to_l1_messages,\n bloom,\n priority_ops_onchain_data,\n used_contract_hashes,\n bootloader_code_hash,\n default_aa_code_hash,\n protocol_version,\n system_logs,\n pubdata_input\n FROM\n l1_batches\n WHERE\n is_sealed\n AND number = $1\n ", "describe": { "columns": [ { @@ -90,5 +90,5 @@ true ] }, - "hash": "454e16ddb5e85285d0c4b9013bcce5d464ecc55c80b54bc16040226df7e297bd" + "hash": "883a8ae0dccc2b46ec512625784ed0a2b72f141f36a682fb880ad76e19ea6914" } diff --git a/core/lib/dal/.sqlx/query-0c95fbfb3a816bd49fd06e3a4f0a52daa202279bf612a9278f663deb78bc6e41.json b/core/lib/dal/.sqlx/query-8cfde47f25cf65030f34e70edf83d3b4c514a18d8a33ec978d3e8007af8d0c20.json similarity index 72% rename from core/lib/dal/.sqlx/query-0c95fbfb3a816bd49fd06e3a4f0a52daa202279bf612a9278f663deb78bc6e41.json rename to core/lib/dal/.sqlx/query-8cfde47f25cf65030f34e70edf83d3b4c514a18d8a33ec978d3e8007af8d0c20.json index 100761f54b41..ea2b51d69d1a 100644 --- a/core/lib/dal/.sqlx/query-0c95fbfb3a816bd49fd06e3a4f0a52daa202279bf612a9278f663deb78bc6e41.json +++ b/core/lib/dal/.sqlx/query-8cfde47f25cf65030f34e70edf83d3b4c514a18d8a33ec978d3e8007af8d0c20.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n protocol_version\n FROM\n l1_batches\n WHERE\n number = $1\n ", + "query": "\n SELECT\n protocol_version\n FROM\n l1_batches\n WHERE\n is_sealed\n AND number = $1\n ", "describe": { "columns": [ { @@ -18,5 +18,5 @@ true ] }, - "hash": "0c95fbfb3a816bd49fd06e3a4f0a52daa202279bf612a9278f663deb78bc6e41" + "hash": "8cfde47f25cf65030f34e70edf83d3b4c514a18d8a33ec978d3e8007af8d0c20" } diff --git a/core/lib/dal/.sqlx/query-52bb6de515e1edf4dcf34a31600edb31cfd855014dfca5041833b9d5d9f7a55e.json b/core/lib/dal/.sqlx/query-90f729db537d4170599bcbdf7035884fae97f10304b0bc1619a1a662d7d96d5b.json similarity index 95% rename from core/lib/dal/.sqlx/query-52bb6de515e1edf4dcf34a31600edb31cfd855014dfca5041833b9d5d9f7a55e.json rename to core/lib/dal/.sqlx/query-90f729db537d4170599bcbdf7035884fae97f10304b0bc1619a1a662d7d96d5b.json index b872e2ce6297..26afdd5a24f9 100644 --- a/core/lib/dal/.sqlx/query-52bb6de515e1edf4dcf34a31600edb31cfd855014dfca5041833b9d5d9f7a55e.json +++ b/core/lib/dal/.sqlx/query-90f729db537d4170599bcbdf7035884fae97f10304b0bc1619a1a662d7d96d5b.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n number,\n timestamp,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n hash,\n commitment,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_merkle_root,\n rollup_last_leaf_index,\n zkporter_is_available,\n bootloader_code_hash,\n default_aa_code_hash,\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 pubdata_input\n FROM\n l1_batches\n LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number\n WHERE\n number = $1\n ", + "query": "\n SELECT\n number,\n timestamp,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n hash,\n commitment,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_merkle_root,\n rollup_last_leaf_index,\n zkporter_is_available,\n bootloader_code_hash,\n default_aa_code_hash,\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 pubdata_input\n FROM\n l1_batches\n LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number\n WHERE\n is_sealed\n AND number = $1\n ", "describe": { "columns": [ { @@ -168,5 +168,5 @@ true ] }, - "hash": "52bb6de515e1edf4dcf34a31600edb31cfd855014dfca5041833b9d5d9f7a55e" + "hash": "90f729db537d4170599bcbdf7035884fae97f10304b0bc1619a1a662d7d96d5b" } diff --git a/core/lib/dal/.sqlx/query-b7cd7c40282c2ca2287eef93ee79c69a9e494bf1f873291b4ae7bf68b7e3c549.json b/core/lib/dal/.sqlx/query-b5b4fc97d4ce204841b2c48d0893f5295127ea9a4f68aaa1c68131b88891d456.json similarity index 87% rename from core/lib/dal/.sqlx/query-b7cd7c40282c2ca2287eef93ee79c69a9e494bf1f873291b4ae7bf68b7e3c549.json rename to core/lib/dal/.sqlx/query-b5b4fc97d4ce204841b2c48d0893f5295127ea9a4f68aaa1c68131b88891d456.json index ed4744206a48..330aec476824 100644 --- a/core/lib/dal/.sqlx/query-b7cd7c40282c2ca2287eef93ee79c69a9e494bf1f873291b4ae7bf68b7e3c549.json +++ b/core/lib/dal/.sqlx/query-b5b4fc97d4ce204841b2c48d0893f5295127ea9a4f68aaa1c68131b88891d456.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n number,\n l1_batches.timestamp,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n hash,\n commitment,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_merkle_root,\n rollup_last_leaf_index,\n zkporter_is_available,\n l1_batches.bootloader_code_hash,\n l1_batches.default_aa_code_hash,\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 pubdata_input\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 ", + "query": "\n SELECT\n number,\n l1_batches.timestamp,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n hash,\n commitment,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_merkle_root,\n rollup_last_leaf_index,\n zkporter_is_available,\n l1_batches.bootloader_code_hash,\n l1_batches.default_aa_code_hash,\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 pubdata_input\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 is_sealed\n AND 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 ", "describe": { "columns": [ { @@ -171,5 +171,5 @@ true ] }, - "hash": "b7cd7c40282c2ca2287eef93ee79c69a9e494bf1f873291b4ae7bf68b7e3c549" + "hash": "b5b4fc97d4ce204841b2c48d0893f5295127ea9a4f68aaa1c68131b88891d456" } diff --git a/core/lib/dal/.sqlx/query-31f12a8c44124bb2ce31889ac5295f3823926f69cb1d54874878e6d6c301bfd8.json b/core/lib/dal/.sqlx/query-cbc0e202a6da5092251f278d7dc5c058f9ad703461a1f55c534bf3d9f48eb61b.json similarity index 74% rename from core/lib/dal/.sqlx/query-31f12a8c44124bb2ce31889ac5295f3823926f69cb1d54874878e6d6c301bfd8.json rename to core/lib/dal/.sqlx/query-cbc0e202a6da5092251f278d7dc5c058f9ad703461a1f55c534bf3d9f48eb61b.json index c63ea98db44b..8f6d1cf7a5f6 100644 --- a/core/lib/dal/.sqlx/query-31f12a8c44124bb2ce31889ac5295f3823926f69cb1d54874878e6d6c301bfd8.json +++ b/core/lib/dal/.sqlx/query-cbc0e202a6da5092251f278d7dc5c058f9ad703461a1f55c534bf3d9f48eb61b.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n COUNT(*) AS \"count!\"\n FROM\n l1_batches\n ", + "query": "\n SELECT\n COUNT(*) AS \"count!\"\n FROM\n l1_batches\n WHERE\n is_sealed\n ", "describe": { "columns": [ { @@ -16,5 +16,5 @@ null ] }, - "hash": "31f12a8c44124bb2ce31889ac5295f3823926f69cb1d54874878e6d6c301bfd8" + "hash": "cbc0e202a6da5092251f278d7dc5c058f9ad703461a1f55c534bf3d9f48eb61b" } diff --git a/core/lib/dal/.sqlx/query-77de28ce78e1e5827f03d7e7550aec881fb5d3cde2f3aad9a5db5629070d6b7c.json b/core/lib/dal/.sqlx/query-f3e9de395a5aeadc8ae8cb95cec8195f0dc434be64cd34ac84977d1a6731ba12.json similarity index 67% rename from core/lib/dal/.sqlx/query-77de28ce78e1e5827f03d7e7550aec881fb5d3cde2f3aad9a5db5629070d6b7c.json rename to core/lib/dal/.sqlx/query-f3e9de395a5aeadc8ae8cb95cec8195f0dc434be64cd34ac84977d1a6731ba12.json index 6fc747ea1237..f46b4091935d 100644 --- a/core/lib/dal/.sqlx/query-77de28ce78e1e5827f03d7e7550aec881fb5d3cde2f3aad9a5db5629070d6b7c.json +++ b/core/lib/dal/.sqlx/query-f3e9de395a5aeadc8ae8cb95cec8195f0dc434be64cd34ac84977d1a6731ba12.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n (tree_writes IS NOT NULL) AS \"tree_writes_are_present!\"\n FROM\n l1_batches\n WHERE\n number = $1\n ", + "query": "\n SELECT\n (tree_writes IS NOT NULL) AS \"tree_writes_are_present!\"\n FROM\n l1_batches\n WHERE\n is_sealed\n AND number = $1\n ", "describe": { "columns": [ { @@ -18,5 +18,5 @@ null ] }, - "hash": "77de28ce78e1e5827f03d7e7550aec881fb5d3cde2f3aad9a5db5629070d6b7c" + "hash": "f3e9de395a5aeadc8ae8cb95cec8195f0dc434be64cd34ac84977d1a6731ba12" } diff --git a/core/lib/dal/src/blocks_dal.rs b/core/lib/dal/src/blocks_dal.rs index bd7ac9466669..24b2f40ebd75 100644 --- a/core/lib/dal/src/blocks_dal.rs +++ b/core/lib/dal/src/blocks_dal.rs @@ -90,6 +90,8 @@ impl BlocksDal<'_, '_> { COUNT(*) AS "count!" FROM l1_batches + WHERE + is_sealed "# ) .instrument("is_genesis_needed") @@ -350,7 +352,8 @@ impl BlocksDal<'_, '_> { l1_batches LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number WHERE - number = $1 + is_sealed + AND number = $1 "#, i64::from(number.0) ) @@ -384,7 +387,8 @@ impl BlocksDal<'_, '_> { FROM l1_batches WHERE - number = $1 + is_sealed + AND number = $1 "#, i64::from(number.0) ) @@ -417,7 +421,8 @@ impl BlocksDal<'_, '_> { FROM l1_batches WHERE - number = $1 + is_sealed + AND number = $1 "#, i64::from(number.0) ) @@ -448,7 +453,8 @@ impl BlocksDal<'_, '_> { FROM l1_batches WHERE - number = $1 + is_sealed + AND number = $1 "#, i64::from(number.0) ) @@ -1015,7 +1021,8 @@ impl BlocksDal<'_, '_> { FROM l1_batches WHERE - number = $1 + is_sealed + AND number = $1 AND commitment = $2 "#, i64::from(number.0), @@ -1173,7 +1180,8 @@ impl BlocksDal<'_, '_> { FROM l1_batches WHERE - number = $1 + is_sealed + AND number = $1 "#, i64::from(l1_batch_number.0) ) @@ -1556,7 +1564,8 @@ impl BlocksDal<'_, '_> { l1_batches LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number WHERE - number BETWEEN $1 AND $2 + is_sealed + AND number BETWEEN $1 AND $2 ORDER BY number LIMIT @@ -1621,7 +1630,8 @@ impl BlocksDal<'_, '_> { 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 + is_sealed + AND eth_commit_tx_id IS NULL AND number != 0 AND protocol_versions.bootloader_code_hash = $1 AND protocol_versions.default_account_code_hash = $2 @@ -1700,7 +1710,8 @@ impl BlocksDal<'_, '_> { LEFT JOIN data_availability ON data_availability.l1_batch_number = l1_batches.number JOIN protocol_versions ON protocol_versions.id = l1_batches.protocol_version WHERE - eth_commit_tx_id IS NULL + is_sealed + AND eth_commit_tx_id IS NULL AND number != 0 AND protocol_versions.bootloader_code_hash = $1 AND protocol_versions.default_account_code_hash = $2 @@ -1837,7 +1848,8 @@ impl BlocksDal<'_, '_> { FROM l1_batches WHERE - number = $1 + is_sealed + AND number = $1 "#, i64::from(number.0) ) @@ -2164,7 +2176,8 @@ impl BlocksDal<'_, '_> { FROM l1_batches WHERE - number = $1 + is_sealed + AND number = $1 "#, i64::from(l1_batch_number.0) ) @@ -2335,7 +2348,8 @@ impl BlocksDal<'_, '_> { FROM l1_batches WHERE - number = $1 + is_sealed + AND number = $1 "#, i64::from(l1_batch_number.0), ) @@ -2362,7 +2376,8 @@ impl BlocksDal<'_, '_> { FROM l1_batches WHERE - number = $1 + is_sealed + AND number = $1 "#, i64::from(l1_batch_number.0), ) From 07aa85989b2106f08ddbbf6331e16d8b16f614eb Mon Sep 17 00:00:00 2001 From: Daniyar Itegulov Date: Thu, 12 Sep 2024 19:50:07 +1000 Subject: [PATCH 03/14] fmt --- zk_toolbox/crates/zk_supervisor/src/commands/test/rust.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zk_toolbox/crates/zk_supervisor/src/commands/test/rust.rs b/zk_toolbox/crates/zk_supervisor/src/commands/test/rust.rs index c42f95e8e3b5..3ac331becc9f 100644 --- a/zk_toolbox/crates/zk_supervisor/src/commands/test/rust.rs +++ b/zk_toolbox/crates/zk_supervisor/src/commands/test/rust.rs @@ -12,8 +12,8 @@ use crate::{ dals::{Dal, CORE_DAL_PATH, PROVER_DAL_PATH}, defaults::{TEST_DATABASE_PROVER_URL, TEST_DATABASE_SERVER_URL}, messages::{ - MSG_CHAIN_NOT_FOUND_ERR, MSG_POSTGRES_CONFIG_NOT_FOUND_ERR, - MSG_RESETTING_TEST_DATABASES, MSG_UNIT_TESTS_RUN_SUCCESS, MSG_USING_CARGO_NEXTEST, + MSG_CHAIN_NOT_FOUND_ERR, MSG_POSTGRES_CONFIG_NOT_FOUND_ERR, MSG_RESETTING_TEST_DATABASES, + MSG_UNIT_TESTS_RUN_SUCCESS, MSG_USING_CARGO_NEXTEST, }, }; From e2c0941e1b892ccfba87603f83951cd6f5cb622f Mon Sep 17 00:00:00 2001 From: Daniyar Itegulov Date: Fri, 13 Sep 2024 12:07:12 +1000 Subject: [PATCH 04/14] revert unnecessary dal changes --- ...c6e326e15dca141050bc9d7dacae98a430e8.json} | 4 +- ...9a148b59a79b03dacf3b1c32223c5ebf8d4b.json} | 4 +- ...e32e8812becbe5ce85e63694385f015f2cfe.json} | 4 +- ...a66d1e38fb6ca706c2affd4607d77be38de9.json} | 4 +- ...5d7d1c9e649663f6e9444c4425821d0a5b71.json} | 4 +- ...8f2dce89f7b700896fcc0f242e0e15ba058e.json} | 4 +- ...f24785ae8bd2b4579203f05379e757a56f2b.json} | 4 +- ...e82028e2865e646677ff67d0720ad17b1eac.json} | 4 +- ...ec881fb5d3cde2f3aad9a5db5629070d6b7c.json} | 4 +- ...0198c2651022c65eb9e04125356fcf52ddfc.json} | 4 +- ...39300ad3b80ac9e70c00864c3d9f6521b028.json} | 4 +- ...c69a9e494bf1f873291b4ae7bf68b7e3c549.json} | 4 +- ...4afd384063ae394a847b26304dd18d490ab4.json} | 4 +- ...e34fc2b97636f33696eaa2a7b1e81b783b650.json | 18 +++++ ...82627a936f7ea9f6c354eca4bea76fac6b10.json} | 4 +- ...76c368dae5fdd4b47664e00890bd47e21e0c2.json | 17 ----- ...249bd77b263c4fcef81689f9dcd155064a36.json} | 4 +- ...3a1e89945f8d5e0f4da42ecf6313c4f5967e.json} | 4 +- ...0910112120_unsealed_batches_in_db.down.sql | 2 + ...240910112120_unsealed_batches_in_db.up.sql | 2 + core/lib/dal/src/blocks_dal.rs | 75 +++++++------------ core/lib/dal/src/data_availability_dal.rs | 3 +- 22 files changed, 82 insertions(+), 99 deletions(-) rename core/lib/dal/.sqlx/{query-8b608466767675e20fd6173ddbe6066b50f0c4ce9a0a8ad84b6af1cebcf7d8d4.json => query-0bdcf87f6910c7222b621f76f71bc6e326e15dca141050bc9d7dacae98a430e8.json} (73%) rename core/lib/dal/.sqlx/{query-6ea2628a9d9e8f10daadc8cdf8bbde1d4ab2889c9dc43d918c403274b00d43d5.json => query-148dd243ab476724a430e74406119a148b59a79b03dacf3b1c32223c5ebf8d4b.json} (57%) rename core/lib/dal/.sqlx/{query-25df7ac382631c46d23956ba27d9c5ab362f2450aece13b382b36a0d235c25aa.json => query-2486f8404e8cfcb9c178acd6dccae32e8812becbe5ce85e63694385f015f2cfe.json} (93%) rename core/lib/dal/.sqlx/{query-241a1a4432e12e77a902e13dbe00599d342aac90c62b2be0df784b7a9166a434.json => query-25646383ecacf72e3f63b5c93a57a66d1e38fb6ca706c2affd4607d77be38de9.json} (73%) rename core/lib/dal/.sqlx/{query-00d2847d75afafffecf96542cfa89566ff0f991165cc8c46b3bf171d18544948.json => query-2eb25bfcfc1114de825dc4eeb0605d7d1c9e649663f6e9444c4425821d0a5b71.json} (72%) rename core/lib/dal/.sqlx/{query-2015ed86bc3d032e1ca34bd3604b4a4b0e84dd0dbc8115f265188ba286548a41.json => query-63f95c6cdcfd933e2cf8f62c0d408f2dce89f7b700896fcc0f242e0e15ba058e.json} (83%) rename core/lib/dal/.sqlx/{query-10c1e781d307512aad982cf582e12734a136e9b912856adfd15330e23919f4be.json => query-65736a5b9b4ad364797dbedfc828f24785ae8bd2b4579203f05379e757a56f2b.json} (63%) rename core/lib/dal/.sqlx/{query-353604cfbdd292fa6a71bae0bdf53f0d1bd420874dc0b894dc44ad97b262d007.json => query-730095f41fd5e2ea376fd869887be82028e2865e646677ff67d0720ad17b1eac.json} (72%) rename core/lib/dal/.sqlx/{query-f3e9de395a5aeadc8ae8cb95cec8195f0dc434be64cd34ac84977d1a6731ba12.json => query-77de28ce78e1e5827f03d7e7550aec881fb5d3cde2f3aad9a5db5629070d6b7c.json} (67%) rename core/lib/dal/.sqlx/{query-05208ed40e773359f6bd00bf0340e1ba189da720b743b2dad90590a9ca2cdfda.json => query-87b3c0cb253a19ba181406bab5f30198c2651022c65eb9e04125356fcf52ddfc.json} (57%) rename core/lib/dal/.sqlx/{query-b43ebb5b15c6cb7c43005d3cba40e2f3aff3a8f6b69d1b8efa00e4339a3558c6.json => query-928139bf23bd0d57b8dbdb3283b139300ad3b80ac9e70c00864c3d9f6521b028.json} (62%) rename core/lib/dal/.sqlx/{query-b5b4fc97d4ce204841b2c48d0893f5295127ea9a4f68aaa1c68131b88891d456.json => query-b7cd7c40282c2ca2287eef93ee79c69a9e494bf1f873291b4ae7bf68b7e3c549.json} (87%) rename core/lib/dal/.sqlx/{query-f724566464e77fedc01169c20ff0551b2259488f58f23bec8e8a479ccd40374b.json => query-cb98d84fc34af1e4a4c2f427c5bb4afd384063ae394a847b26304dd18d490ab4.json} (74%) create mode 100644 core/lib/dal/.sqlx/query-d1c7dcad34897fda05776667f1ce34fc2b97636f33696eaa2a7b1e81b783b650.json rename core/lib/dal/.sqlx/{query-eb9bfcb97ab76409c0794ecdc7ae2e73723728d6e2061728c030045757016619.json => query-dc481f59aae632ff6f5fa23f5c5c82627a936f7ea9f6c354eca4bea76fac6b10.json} (68%) delete mode 100644 core/lib/dal/.sqlx/query-eeb101b29c28fd65a93ecbdb21176c368dae5fdd4b47664e00890bd47e21e0c2.json rename core/lib/dal/.sqlx/{query-dd316dbcb309c3f9cd80ba9b3b22952a2099abd396bf36b9fd44b2daf400e3f3.json => query-f6c0b212fad536f46863ce3a6105249bd77b263c4fcef81689f9dcd155064a36.json} (71%) rename core/lib/dal/.sqlx/{query-3900890900bbfbfc98cfb55f94e99857265d82d3c29ab37a9839a9e97573bfdc.json => query-f91790ae5cc4b087bf942ba52dd63a1e89945f8d5e0f4da42ecf6313c4f5967e.json} (68%) diff --git a/core/lib/dal/.sqlx/query-8b608466767675e20fd6173ddbe6066b50f0c4ce9a0a8ad84b6af1cebcf7d8d4.json b/core/lib/dal/.sqlx/query-0bdcf87f6910c7222b621f76f71bc6e326e15dca141050bc9d7dacae98a430e8.json similarity index 73% rename from core/lib/dal/.sqlx/query-8b608466767675e20fd6173ddbe6066b50f0c4ce9a0a8ad84b6af1cebcf7d8d4.json rename to core/lib/dal/.sqlx/query-0bdcf87f6910c7222b621f76f71bc6e326e15dca141050bc9d7dacae98a430e8.json index a326c314c9cf..e5ed48130726 100644 --- a/core/lib/dal/.sqlx/query-8b608466767675e20fd6173ddbe6066b50f0c4ce9a0a8ad84b6af1cebcf7d8d4.json +++ b/core/lib/dal/.sqlx/query-0bdcf87f6910c7222b621f76f71bc6e326e15dca141050bc9d7dacae98a430e8.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n hash\n FROM\n l1_batches\n WHERE\n is_sealed\n AND number = $1\n ", + "query": "\n SELECT\n hash\n FROM\n l1_batches\n WHERE\n number = $1\n ", "describe": { "columns": [ { @@ -18,5 +18,5 @@ true ] }, - "hash": "8b608466767675e20fd6173ddbe6066b50f0c4ce9a0a8ad84b6af1cebcf7d8d4" + "hash": "0bdcf87f6910c7222b621f76f71bc6e326e15dca141050bc9d7dacae98a430e8" } diff --git a/core/lib/dal/.sqlx/query-6ea2628a9d9e8f10daadc8cdf8bbde1d4ab2889c9dc43d918c403274b00d43d5.json b/core/lib/dal/.sqlx/query-148dd243ab476724a430e74406119a148b59a79b03dacf3b1c32223c5ebf8d4b.json similarity index 57% rename from core/lib/dal/.sqlx/query-6ea2628a9d9e8f10daadc8cdf8bbde1d4ab2889c9dc43d918c403274b00d43d5.json rename to core/lib/dal/.sqlx/query-148dd243ab476724a430e74406119a148b59a79b03dacf3b1c32223c5ebf8d4b.json index 36b8dfcd92aa..4f14d753fd6f 100644 --- a/core/lib/dal/.sqlx/query-6ea2628a9d9e8f10daadc8cdf8bbde1d4ab2889c9dc43d918c403274b00d43d5.json +++ b/core/lib/dal/.sqlx/query-148dd243ab476724a430e74406119a148b59a79b03dacf3b1c32223c5ebf8d4b.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n number\n FROM\n l1_batches\n WHERE\n is_sealed\n AND hash IS NOT NULL\n AND commitment IS NULL\n ORDER BY\n number\n LIMIT\n 1\n ", + "query": "\n SELECT\n number\n FROM\n l1_batches\n WHERE\n hash IS NOT NULL\n AND commitment IS NULL\n ORDER BY\n number DESC\n LIMIT\n 1\n ", "describe": { "columns": [ { @@ -16,5 +16,5 @@ false ] }, - "hash": "6ea2628a9d9e8f10daadc8cdf8bbde1d4ab2889c9dc43d918c403274b00d43d5" + "hash": "148dd243ab476724a430e74406119a148b59a79b03dacf3b1c32223c5ebf8d4b" } diff --git a/core/lib/dal/.sqlx/query-25df7ac382631c46d23956ba27d9c5ab362f2450aece13b382b36a0d235c25aa.json b/core/lib/dal/.sqlx/query-2486f8404e8cfcb9c178acd6dccae32e8812becbe5ce85e63694385f015f2cfe.json similarity index 93% rename from core/lib/dal/.sqlx/query-25df7ac382631c46d23956ba27d9c5ab362f2450aece13b382b36a0d235c25aa.json rename to core/lib/dal/.sqlx/query-2486f8404e8cfcb9c178acd6dccae32e8812becbe5ce85e63694385f015f2cfe.json index 287f80bd7c38..f28e3d044ccc 100644 --- a/core/lib/dal/.sqlx/query-25df7ac382631c46d23956ba27d9c5ab362f2450aece13b382b36a0d235c25aa.json +++ b/core/lib/dal/.sqlx/query-2486f8404e8cfcb9c178acd6dccae32e8812becbe5ce85e63694385f015f2cfe.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n number,\n timestamp,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n hash,\n commitment,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_merkle_root,\n rollup_last_leaf_index,\n zkporter_is_available,\n bootloader_code_hash,\n default_aa_code_hash,\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 pubdata_input\n FROM\n l1_batches\n LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number\n WHERE\n is_sealed\n AND number BETWEEN $1 AND $2\n ORDER BY\n number\n LIMIT\n $3\n ", + "query": "\n SELECT\n number,\n timestamp,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n hash,\n commitment,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_merkle_root,\n rollup_last_leaf_index,\n zkporter_is_available,\n bootloader_code_hash,\n default_aa_code_hash,\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 pubdata_input\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 ", "describe": { "columns": [ { @@ -170,5 +170,5 @@ true ] }, - "hash": "25df7ac382631c46d23956ba27d9c5ab362f2450aece13b382b36a0d235c25aa" + "hash": "2486f8404e8cfcb9c178acd6dccae32e8812becbe5ce85e63694385f015f2cfe" } diff --git a/core/lib/dal/.sqlx/query-241a1a4432e12e77a902e13dbe00599d342aac90c62b2be0df784b7a9166a434.json b/core/lib/dal/.sqlx/query-25646383ecacf72e3f63b5c93a57a66d1e38fb6ca706c2affd4607d77be38de9.json similarity index 73% rename from core/lib/dal/.sqlx/query-241a1a4432e12e77a902e13dbe00599d342aac90c62b2be0df784b7a9166a434.json rename to core/lib/dal/.sqlx/query-25646383ecacf72e3f63b5c93a57a66d1e38fb6ca706c2affd4607d77be38de9.json index 213014ebe504..8d35e81b216c 100644 --- a/core/lib/dal/.sqlx/query-241a1a4432e12e77a902e13dbe00599d342aac90c62b2be0df784b7a9166a434.json +++ b/core/lib/dal/.sqlx/query-25646383ecacf72e3f63b5c93a57a66d1e38fb6ca706c2affd4607d77be38de9.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n hash,\n rollup_last_leaf_index\n FROM\n l1_batches\n WHERE\n is_sealed\n AND number = $1\n ", + "query": "\n SELECT\n hash,\n rollup_last_leaf_index\n FROM\n l1_batches\n WHERE\n number = $1\n ", "describe": { "columns": [ { @@ -24,5 +24,5 @@ true ] }, - "hash": "241a1a4432e12e77a902e13dbe00599d342aac90c62b2be0df784b7a9166a434" + "hash": "25646383ecacf72e3f63b5c93a57a66d1e38fb6ca706c2affd4607d77be38de9" } diff --git a/core/lib/dal/.sqlx/query-00d2847d75afafffecf96542cfa89566ff0f991165cc8c46b3bf171d18544948.json b/core/lib/dal/.sqlx/query-2eb25bfcfc1114de825dc4eeb0605d7d1c9e649663f6e9444c4425821d0a5b71.json similarity index 72% rename from core/lib/dal/.sqlx/query-00d2847d75afafffecf96542cfa89566ff0f991165cc8c46b3bf171d18544948.json rename to core/lib/dal/.sqlx/query-2eb25bfcfc1114de825dc4eeb0605d7d1c9e649663f6e9444c4425821d0a5b71.json index 1cfcb9dbb01d..6b0ddef258fc 100644 --- a/core/lib/dal/.sqlx/query-00d2847d75afafffecf96542cfa89566ff0f991165cc8c46b3bf171d18544948.json +++ b/core/lib/dal/.sqlx/query-2eb25bfcfc1114de825dc4eeb0605d7d1c9e649663f6e9444c4425821d0a5b71.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n eth_commit_tx_id\n FROM\n l1_batches\n WHERE\n is_sealed\n AND number = $1\n ", + "query": "\n SELECT\n eth_commit_tx_id\n FROM\n l1_batches\n WHERE\n number = $1\n ", "describe": { "columns": [ { @@ -18,5 +18,5 @@ true ] }, - "hash": "00d2847d75afafffecf96542cfa89566ff0f991165cc8c46b3bf171d18544948" + "hash": "2eb25bfcfc1114de825dc4eeb0605d7d1c9e649663f6e9444c4425821d0a5b71" } diff --git a/core/lib/dal/.sqlx/query-2015ed86bc3d032e1ca34bd3604b4a4b0e84dd0dbc8115f265188ba286548a41.json b/core/lib/dal/.sqlx/query-63f95c6cdcfd933e2cf8f62c0d408f2dce89f7b700896fcc0f242e0e15ba058e.json similarity index 83% rename from core/lib/dal/.sqlx/query-2015ed86bc3d032e1ca34bd3604b4a4b0e84dd0dbc8115f265188ba286548a41.json rename to core/lib/dal/.sqlx/query-63f95c6cdcfd933e2cf8f62c0d408f2dce89f7b700896fcc0f242e0e15ba058e.json index f8dcb32bcbd8..cb68e7622524 100644 --- a/core/lib/dal/.sqlx/query-2015ed86bc3d032e1ca34bd3604b4a4b0e84dd0dbc8115f265188ba286548a41.json +++ b/core/lib/dal/.sqlx/query-63f95c6cdcfd933e2cf8f62c0d408f2dce89f7b700896fcc0f242e0e15ba058e.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n number,\n l1_batches.timestamp,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n hash,\n commitment,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_merkle_root,\n rollup_last_leaf_index,\n zkporter_is_available,\n l1_batches.bootloader_code_hash,\n l1_batches.default_aa_code_hash,\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 pubdata_input\n FROM\n l1_batches\n LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number\n LEFT JOIN data_availability ON data_availability.l1_batch_number = l1_batches.number\n JOIN protocol_versions ON protocol_versions.id = l1_batches.protocol_version\n WHERE\n is_sealed\n AND 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 AND (\n data_availability.inclusion_data IS NOT NULL\n OR $4 IS FALSE\n )\n ORDER BY\n number\n LIMIT\n $5\n ", + "query": "\n SELECT\n number,\n l1_batches.timestamp,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n hash,\n commitment,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_merkle_root,\n rollup_last_leaf_index,\n zkporter_is_available,\n l1_batches.bootloader_code_hash,\n l1_batches.default_aa_code_hash,\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 pubdata_input\n FROM\n l1_batches\n LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number\n LEFT JOIN data_availability ON data_availability.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 AND (\n data_availability.inclusion_data IS NOT NULL\n OR $4 IS FALSE\n )\n ORDER BY\n number\n LIMIT\n $5\n ", "describe": { "columns": [ { @@ -172,5 +172,5 @@ true ] }, - "hash": "2015ed86bc3d032e1ca34bd3604b4a4b0e84dd0dbc8115f265188ba286548a41" + "hash": "63f95c6cdcfd933e2cf8f62c0d408f2dce89f7b700896fcc0f242e0e15ba058e" } diff --git a/core/lib/dal/.sqlx/query-10c1e781d307512aad982cf582e12734a136e9b912856adfd15330e23919f4be.json b/core/lib/dal/.sqlx/query-65736a5b9b4ad364797dbedfc828f24785ae8bd2b4579203f05379e757a56f2b.json similarity index 63% rename from core/lib/dal/.sqlx/query-10c1e781d307512aad982cf582e12734a136e9b912856adfd15330e23919f4be.json rename to core/lib/dal/.sqlx/query-65736a5b9b4ad364797dbedfc828f24785ae8bd2b4579203f05379e757a56f2b.json index 0edf0f30778b..af7bff984be5 100644 --- a/core/lib/dal/.sqlx/query-10c1e781d307512aad982cf582e12734a136e9b912856adfd15330e23919f4be.json +++ b/core/lib/dal/.sqlx/query-65736a5b9b4ad364797dbedfc828f24785ae8bd2b4579203f05379e757a56f2b.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n COUNT(*) AS \"count!\"\n FROM\n l1_batches\n WHERE\n is_sealed\n AND number = $1\n AND commitment = $2\n ", + "query": "\n SELECT\n COUNT(*) AS \"count!\"\n FROM\n l1_batches\n WHERE\n number = $1\n AND commitment = $2\n ", "describe": { "columns": [ { @@ -19,5 +19,5 @@ null ] }, - "hash": "10c1e781d307512aad982cf582e12734a136e9b912856adfd15330e23919f4be" + "hash": "65736a5b9b4ad364797dbedfc828f24785ae8bd2b4579203f05379e757a56f2b" } diff --git a/core/lib/dal/.sqlx/query-353604cfbdd292fa6a71bae0bdf53f0d1bd420874dc0b894dc44ad97b262d007.json b/core/lib/dal/.sqlx/query-730095f41fd5e2ea376fd869887be82028e2865e646677ff67d0720ad17b1eac.json similarity index 72% rename from core/lib/dal/.sqlx/query-353604cfbdd292fa6a71bae0bdf53f0d1bd420874dc0b894dc44ad97b262d007.json rename to core/lib/dal/.sqlx/query-730095f41fd5e2ea376fd869887be82028e2865e646677ff67d0720ad17b1eac.json index 59105e74f687..e6d2f72575e3 100644 --- a/core/lib/dal/.sqlx/query-353604cfbdd292fa6a71bae0bdf53f0d1bd420874dc0b894dc44ad97b262d007.json +++ b/core/lib/dal/.sqlx/query-730095f41fd5e2ea376fd869887be82028e2865e646677ff67d0720ad17b1eac.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n tree_writes\n FROM\n l1_batches\n WHERE\n is_sealed\n AND number = $1\n ", + "query": "\n SELECT\n tree_writes\n FROM\n l1_batches\n WHERE\n number = $1\n ", "describe": { "columns": [ { @@ -18,5 +18,5 @@ true ] }, - "hash": "353604cfbdd292fa6a71bae0bdf53f0d1bd420874dc0b894dc44ad97b262d007" + "hash": "730095f41fd5e2ea376fd869887be82028e2865e646677ff67d0720ad17b1eac" } diff --git a/core/lib/dal/.sqlx/query-f3e9de395a5aeadc8ae8cb95cec8195f0dc434be64cd34ac84977d1a6731ba12.json b/core/lib/dal/.sqlx/query-77de28ce78e1e5827f03d7e7550aec881fb5d3cde2f3aad9a5db5629070d6b7c.json similarity index 67% rename from core/lib/dal/.sqlx/query-f3e9de395a5aeadc8ae8cb95cec8195f0dc434be64cd34ac84977d1a6731ba12.json rename to core/lib/dal/.sqlx/query-77de28ce78e1e5827f03d7e7550aec881fb5d3cde2f3aad9a5db5629070d6b7c.json index f46b4091935d..6fc747ea1237 100644 --- a/core/lib/dal/.sqlx/query-f3e9de395a5aeadc8ae8cb95cec8195f0dc434be64cd34ac84977d1a6731ba12.json +++ b/core/lib/dal/.sqlx/query-77de28ce78e1e5827f03d7e7550aec881fb5d3cde2f3aad9a5db5629070d6b7c.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n (tree_writes IS NOT NULL) AS \"tree_writes_are_present!\"\n FROM\n l1_batches\n WHERE\n is_sealed\n AND number = $1\n ", + "query": "\n SELECT\n (tree_writes IS NOT NULL) AS \"tree_writes_are_present!\"\n FROM\n l1_batches\n WHERE\n number = $1\n ", "describe": { "columns": [ { @@ -18,5 +18,5 @@ null ] }, - "hash": "f3e9de395a5aeadc8ae8cb95cec8195f0dc434be64cd34ac84977d1a6731ba12" + "hash": "77de28ce78e1e5827f03d7e7550aec881fb5d3cde2f3aad9a5db5629070d6b7c" } diff --git a/core/lib/dal/.sqlx/query-05208ed40e773359f6bd00bf0340e1ba189da720b743b2dad90590a9ca2cdfda.json b/core/lib/dal/.sqlx/query-87b3c0cb253a19ba181406bab5f30198c2651022c65eb9e04125356fcf52ddfc.json similarity index 57% rename from core/lib/dal/.sqlx/query-05208ed40e773359f6bd00bf0340e1ba189da720b743b2dad90590a9ca2cdfda.json rename to core/lib/dal/.sqlx/query-87b3c0cb253a19ba181406bab5f30198c2651022c65eb9e04125356fcf52ddfc.json index c05bf60c219e..669beb8aa25f 100644 --- a/core/lib/dal/.sqlx/query-05208ed40e773359f6bd00bf0340e1ba189da720b743b2dad90590a9ca2cdfda.json +++ b/core/lib/dal/.sqlx/query-87b3c0cb253a19ba181406bab5f30198c2651022c65eb9e04125356fcf52ddfc.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n number\n FROM\n l1_batches\n WHERE\n is_sealed\n AND hash IS NOT NULL\n AND commitment IS NULL\n ORDER BY\n number DESC\n LIMIT\n 1\n ", + "query": "\n SELECT\n number\n FROM\n l1_batches\n WHERE\n hash IS NOT NULL\n AND commitment IS NULL\n ORDER BY\n number\n LIMIT\n 1\n ", "describe": { "columns": [ { @@ -16,5 +16,5 @@ false ] }, - "hash": "05208ed40e773359f6bd00bf0340e1ba189da720b743b2dad90590a9ca2cdfda" + "hash": "87b3c0cb253a19ba181406bab5f30198c2651022c65eb9e04125356fcf52ddfc" } diff --git a/core/lib/dal/.sqlx/query-b43ebb5b15c6cb7c43005d3cba40e2f3aff3a8f6b69d1b8efa00e4339a3558c6.json b/core/lib/dal/.sqlx/query-928139bf23bd0d57b8dbdb3283b139300ad3b80ac9e70c00864c3d9f6521b028.json similarity index 62% rename from core/lib/dal/.sqlx/query-b43ebb5b15c6cb7c43005d3cba40e2f3aff3a8f6b69d1b8efa00e4339a3558c6.json rename to core/lib/dal/.sqlx/query-928139bf23bd0d57b8dbdb3283b139300ad3b80ac9e70c00864c3d9f6521b028.json index 23a893f38761..e192763b189b 100644 --- a/core/lib/dal/.sqlx/query-b43ebb5b15c6cb7c43005d3cba40e2f3aff3a8f6b69d1b8efa00e4339a3558c6.json +++ b/core/lib/dal/.sqlx/query-928139bf23bd0d57b8dbdb3283b139300ad3b80ac9e70c00864c3d9f6521b028.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n number,\n pubdata_input\n FROM\n l1_batches\n LEFT JOIN data_availability ON data_availability.l1_batch_number = l1_batches.number\n WHERE\n is_sealed\n AND eth_commit_tx_id IS NULL\n AND number != 0\n AND data_availability.blob_id IS NULL\n AND pubdata_input IS NOT NULL\n ORDER BY\n number\n LIMIT\n $1\n ", + "query": "\n SELECT\n number,\n pubdata_input\n FROM\n l1_batches\n LEFT JOIN data_availability ON data_availability.l1_batch_number = l1_batches.number\n WHERE\n eth_commit_tx_id IS NULL\n AND number != 0\n AND data_availability.blob_id IS NULL\n AND pubdata_input IS NOT NULL\n ORDER BY\n number\n LIMIT\n $1\n ", "describe": { "columns": [ { @@ -24,5 +24,5 @@ true ] }, - "hash": "b43ebb5b15c6cb7c43005d3cba40e2f3aff3a8f6b69d1b8efa00e4339a3558c6" + "hash": "928139bf23bd0d57b8dbdb3283b139300ad3b80ac9e70c00864c3d9f6521b028" } diff --git a/core/lib/dal/.sqlx/query-b5b4fc97d4ce204841b2c48d0893f5295127ea9a4f68aaa1c68131b88891d456.json b/core/lib/dal/.sqlx/query-b7cd7c40282c2ca2287eef93ee79c69a9e494bf1f873291b4ae7bf68b7e3c549.json similarity index 87% rename from core/lib/dal/.sqlx/query-b5b4fc97d4ce204841b2c48d0893f5295127ea9a4f68aaa1c68131b88891d456.json rename to core/lib/dal/.sqlx/query-b7cd7c40282c2ca2287eef93ee79c69a9e494bf1f873291b4ae7bf68b7e3c549.json index 330aec476824..ed4744206a48 100644 --- a/core/lib/dal/.sqlx/query-b5b4fc97d4ce204841b2c48d0893f5295127ea9a4f68aaa1c68131b88891d456.json +++ b/core/lib/dal/.sqlx/query-b7cd7c40282c2ca2287eef93ee79c69a9e494bf1f873291b4ae7bf68b7e3c549.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n number,\n l1_batches.timestamp,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n hash,\n commitment,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_merkle_root,\n rollup_last_leaf_index,\n zkporter_is_available,\n l1_batches.bootloader_code_hash,\n l1_batches.default_aa_code_hash,\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 pubdata_input\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 is_sealed\n AND 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 ", + "query": "\n SELECT\n number,\n l1_batches.timestamp,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n hash,\n commitment,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_merkle_root,\n rollup_last_leaf_index,\n zkporter_is_available,\n l1_batches.bootloader_code_hash,\n l1_batches.default_aa_code_hash,\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 pubdata_input\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 ", "describe": { "columns": [ { @@ -171,5 +171,5 @@ true ] }, - "hash": "b5b4fc97d4ce204841b2c48d0893f5295127ea9a4f68aaa1c68131b88891d456" + "hash": "b7cd7c40282c2ca2287eef93ee79c69a9e494bf1f873291b4ae7bf68b7e3c549" } diff --git a/core/lib/dal/.sqlx/query-f724566464e77fedc01169c20ff0551b2259488f58f23bec8e8a479ccd40374b.json b/core/lib/dal/.sqlx/query-cb98d84fc34af1e4a4c2f427c5bb4afd384063ae394a847b26304dd18d490ab4.json similarity index 74% rename from core/lib/dal/.sqlx/query-f724566464e77fedc01169c20ff0551b2259488f58f23bec8e8a479ccd40374b.json rename to core/lib/dal/.sqlx/query-cb98d84fc34af1e4a4c2f427c5bb4afd384063ae394a847b26304dd18d490ab4.json index 3c519a351622..732992595c73 100644 --- a/core/lib/dal/.sqlx/query-f724566464e77fedc01169c20ff0551b2259488f58f23bec8e8a479ccd40374b.json +++ b/core/lib/dal/.sqlx/query-cb98d84fc34af1e4a4c2f427c5bb4afd384063ae394a847b26304dd18d490ab4.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n timestamp,\n hash\n FROM\n l1_batches\n WHERE\n is_sealed\n AND number = $1\n ", + "query": "\n SELECT\n timestamp,\n hash\n FROM\n l1_batches\n WHERE\n number = $1\n ", "describe": { "columns": [ { @@ -24,5 +24,5 @@ true ] }, - "hash": "f724566464e77fedc01169c20ff0551b2259488f58f23bec8e8a479ccd40374b" + "hash": "cb98d84fc34af1e4a4c2f427c5bb4afd384063ae394a847b26304dd18d490ab4" } diff --git a/core/lib/dal/.sqlx/query-d1c7dcad34897fda05776667f1ce34fc2b97636f33696eaa2a7b1e81b783b650.json b/core/lib/dal/.sqlx/query-d1c7dcad34897fda05776667f1ce34fc2b97636f33696eaa2a7b1e81b783b650.json new file mode 100644 index 000000000000..101edb33b684 --- /dev/null +++ b/core/lib/dal/.sqlx/query-d1c7dcad34897fda05776667f1ce34fc2b97636f33696eaa2a7b1e81b783b650.json @@ -0,0 +1,18 @@ +{ + "db_name": "PostgreSQL", + "query": "\n INSERT INTO\n l1_batches (\n number,\n timestamp,\n l1_gas_price,\n l2_fair_gas_price,\n fair_pubdata_price,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n initial_bootloader_heap_content,\n used_contract_hashes,\n created_at,\n updated_at,\n is_sealed\n )\n VALUES\n (\n $1,\n $2,\n $3,\n $4,\n $5,\n 0,\n 0,\n ''::bytea,\n '{}'::bytea[],\n '{}'::jsonb,\n '{}'::jsonb,\n NOW(),\n NOW(),\n FALSE\n )\n ", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Int8", + "Int8", + "Int8", + "Int8", + "Int8" + ] + }, + "nullable": [] + }, + "hash": "d1c7dcad34897fda05776667f1ce34fc2b97636f33696eaa2a7b1e81b783b650" +} diff --git a/core/lib/dal/.sqlx/query-eb9bfcb97ab76409c0794ecdc7ae2e73723728d6e2061728c030045757016619.json b/core/lib/dal/.sqlx/query-dc481f59aae632ff6f5fa23f5c5c82627a936f7ea9f6c354eca4bea76fac6b10.json similarity index 68% rename from core/lib/dal/.sqlx/query-eb9bfcb97ab76409c0794ecdc7ae2e73723728d6e2061728c030045757016619.json rename to core/lib/dal/.sqlx/query-dc481f59aae632ff6f5fa23f5c5c82627a936f7ea9f6c354eca4bea76fac6b10.json index 09d730b2ac9e..77263c2a4dd7 100644 --- a/core/lib/dal/.sqlx/query-eb9bfcb97ab76409c0794ecdc7ae2e73723728d6e2061728c030045757016619.json +++ b/core/lib/dal/.sqlx/query-dc481f59aae632ff6f5fa23f5c5c82627a936f7ea9f6c354eca4bea76fac6b10.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n MAX(number) AS \"number\"\n FROM\n l1_batches\n WHERE\n is_sealed\n AND hash IS NOT NULL\n ", + "query": "\n SELECT\n MAX(number) AS \"number\"\n FROM\n l1_batches\n WHERE\n hash IS NOT NULL\n ", "describe": { "columns": [ { @@ -16,5 +16,5 @@ null ] }, - "hash": "eb9bfcb97ab76409c0794ecdc7ae2e73723728d6e2061728c030045757016619" + "hash": "dc481f59aae632ff6f5fa23f5c5c82627a936f7ea9f6c354eca4bea76fac6b10" } diff --git a/core/lib/dal/.sqlx/query-eeb101b29c28fd65a93ecbdb21176c368dae5fdd4b47664e00890bd47e21e0c2.json b/core/lib/dal/.sqlx/query-eeb101b29c28fd65a93ecbdb21176c368dae5fdd4b47664e00890bd47e21e0c2.json deleted file mode 100644 index e7b956a56c77..000000000000 --- a/core/lib/dal/.sqlx/query-eeb101b29c28fd65a93ecbdb21176c368dae5fdd4b47664e00890bd47e21e0c2.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "\n INSERT INTO\n l1_batches (\n number,\n timestamp,\n l1_gas_price,\n l2_fair_gas_price,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n initial_bootloader_heap_content,\n used_contract_hashes,\n created_at,\n updated_at,\n is_sealed\n )\n VALUES\n (\n $1,\n $2,\n $3,\n $4,\n 0,\n 0,\n ''::bytea,\n '{}'::bytea[],\n '{}'::jsonb,\n '{}'::jsonb,\n NOW(),\n NOW(),\n FALSE\n )\n ", - "describe": { - "columns": [], - "parameters": { - "Left": [ - "Int8", - "Int8", - "Int8", - "Int8" - ] - }, - "nullable": [] - }, - "hash": "eeb101b29c28fd65a93ecbdb21176c368dae5fdd4b47664e00890bd47e21e0c2" -} diff --git a/core/lib/dal/.sqlx/query-dd316dbcb309c3f9cd80ba9b3b22952a2099abd396bf36b9fd44b2daf400e3f3.json b/core/lib/dal/.sqlx/query-f6c0b212fad536f46863ce3a6105249bd77b263c4fcef81689f9dcd155064a36.json similarity index 71% rename from core/lib/dal/.sqlx/query-dd316dbcb309c3f9cd80ba9b3b22952a2099abd396bf36b9fd44b2daf400e3f3.json rename to core/lib/dal/.sqlx/query-f6c0b212fad536f46863ce3a6105249bd77b263c4fcef81689f9dcd155064a36.json index f937eea6a514..f916d0dddcef 100644 --- a/core/lib/dal/.sqlx/query-dd316dbcb309c3f9cd80ba9b3b22952a2099abd396bf36b9fd44b2daf400e3f3.json +++ b/core/lib/dal/.sqlx/query-f6c0b212fad536f46863ce3a6105249bd77b263c4fcef81689f9dcd155064a36.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n number,\n l1_tx_count,\n l2_tx_count,\n timestamp\n FROM\n l1_batches\n WHERE\n is_sealed\n AND (\n eth_commit_tx_id = $1\n OR eth_prove_tx_id = $1\n OR eth_execute_tx_id = $1\n )\n ", + "query": "\n SELECT\n number,\n l1_tx_count,\n l2_tx_count,\n timestamp\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 ", "describe": { "columns": [ { @@ -36,5 +36,5 @@ false ] }, - "hash": "dd316dbcb309c3f9cd80ba9b3b22952a2099abd396bf36b9fd44b2daf400e3f3" + "hash": "f6c0b212fad536f46863ce3a6105249bd77b263c4fcef81689f9dcd155064a36" } diff --git a/core/lib/dal/.sqlx/query-3900890900bbfbfc98cfb55f94e99857265d82d3c29ab37a9839a9e97573bfdc.json b/core/lib/dal/.sqlx/query-f91790ae5cc4b087bf942ba52dd63a1e89945f8d5e0f4da42ecf6313c4f5967e.json similarity index 68% rename from core/lib/dal/.sqlx/query-3900890900bbfbfc98cfb55f94e99857265d82d3c29ab37a9839a9e97573bfdc.json rename to core/lib/dal/.sqlx/query-f91790ae5cc4b087bf942ba52dd63a1e89945f8d5e0f4da42ecf6313c4f5967e.json index 965ab97b63f7..cdf4b166270d 100644 --- a/core/lib/dal/.sqlx/query-3900890900bbfbfc98cfb55f94e99857265d82d3c29ab37a9839a9e97573bfdc.json +++ b/core/lib/dal/.sqlx/query-f91790ae5cc4b087bf942ba52dd63a1e89945f8d5e0f4da42ecf6313c4f5967e.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n MIN(number) AS \"number\"\n FROM\n l1_batches\n WHERE\n is_sealed\n AND hash IS NOT NULL\n ", + "query": "\n SELECT\n MIN(number) AS \"number\"\n FROM\n l1_batches\n WHERE\n hash IS NOT NULL\n ", "describe": { "columns": [ { @@ -16,5 +16,5 @@ null ] }, - "hash": "3900890900bbfbfc98cfb55f94e99857265d82d3c29ab37a9839a9e97573bfdc" + "hash": "f91790ae5cc4b087bf942ba52dd63a1e89945f8d5e0f4da42ecf6313c4f5967e" } diff --git a/core/lib/dal/migrations/20240910112120_unsealed_batches_in_db.down.sql b/core/lib/dal/migrations/20240910112120_unsealed_batches_in_db.down.sql index 8b7a4c549e88..e6347963e102 100644 --- a/core/lib/dal/migrations/20240910112120_unsealed_batches_in_db.down.sql +++ b/core/lib/dal/migrations/20240910112120_unsealed_batches_in_db.down.sql @@ -1,2 +1,4 @@ ALTER TABLE l1_batches RENAME COLUMN is_sealed TO is_finished; +ALTER table l1_batches + DROP COLUMN fair_pubdata_price; diff --git a/core/lib/dal/migrations/20240910112120_unsealed_batches_in_db.up.sql b/core/lib/dal/migrations/20240910112120_unsealed_batches_in_db.up.sql index e6f351b68687..f08119caa49f 100644 --- a/core/lib/dal/migrations/20240910112120_unsealed_batches_in_db.up.sql +++ b/core/lib/dal/migrations/20240910112120_unsealed_batches_in_db.up.sql @@ -1,2 +1,4 @@ ALTER TABLE l1_batches RENAME COLUMN is_finished TO is_sealed; +ALTER table l1_batches + ADD COLUMN fair_pubdata_price bigint; diff --git a/core/lib/dal/src/blocks_dal.rs b/core/lib/dal/src/blocks_dal.rs index 24b2f40ebd75..7e425768a85b 100644 --- a/core/lib/dal/src/blocks_dal.rs +++ b/core/lib/dal/src/blocks_dal.rs @@ -183,8 +183,7 @@ impl BlocksDal<'_, '_> { FROM l1_batches WHERE - is_sealed - AND hash IS NOT NULL + hash IS NOT NULL "# ) .instrument("get_last_l1_batch_number_with_tree_data") @@ -207,8 +206,7 @@ impl BlocksDal<'_, '_> { FROM l1_batches WHERE - is_sealed - AND hash IS NOT NULL + hash IS NOT NULL AND commitment IS NULL ORDER BY number @@ -236,8 +234,7 @@ impl BlocksDal<'_, '_> { FROM l1_batches WHERE - is_sealed - AND hash IS NOT NULL + hash IS NOT NULL AND commitment IS NULL ORDER BY number DESC @@ -265,8 +262,7 @@ impl BlocksDal<'_, '_> { FROM l1_batches WHERE - is_sealed - AND hash IS NOT NULL + hash IS NOT NULL "# ) .instrument("get_earliest_l1_batch_number_with_metadata") @@ -291,12 +287,9 @@ impl BlocksDal<'_, '_> { FROM l1_batches WHERE - is_sealed - AND ( - eth_commit_tx_id = $1 - OR eth_prove_tx_id = $1 - OR eth_execute_tx_id = $1 - ) + eth_commit_tx_id = $1 + OR eth_prove_tx_id = $1 + OR eth_execute_tx_id = $1 "#, eth_tx_id as i32 ) @@ -592,6 +585,7 @@ impl BlocksDal<'_, '_> { timestamp, l1_gas_price, l2_fair_gas_price, + fair_pubdata_price, l1_tx_count, l2_tx_count, bloom, @@ -608,6 +602,7 @@ impl BlocksDal<'_, '_> { $2, $3, $4, + $5, 0, 0, ''::bytea, @@ -623,14 +618,13 @@ impl BlocksDal<'_, '_> { timestamp as i64, batch_fee_input.l1_gas_price() as i64, batch_fee_input.fair_l2_gas_price() as i64, - ); - - let mut transaction = self.storage.start_transaction().await?; - instrumentation - .with(query) - .execute(&mut transaction) - .await?; - transaction.commit().await + batch_fee_input.fair_pubdata_price() as i64, + ) + .instrument("insert_l1_batch") + .with_arg("number", &number) + .execute(self.storage) + .await?; + Ok(()) } /// Marks provided L1 batch as sealed and populates it with all the runtime information. @@ -718,12 +712,7 @@ impl BlocksDal<'_, '_> { pubdata_input, serde_json::to_value(predicted_circuits_by_type).unwrap(), ); - let mut transaction = self.storage.start_transaction().await?; - let update_result = instrumentation - .with(query) - .execute(&mut transaction) - .await?; - transaction.commit().await?; + let update_result = instrumentation.with(query).execute(self.storage).await?; if update_result.rows_affected() == 0 { anyhow::bail!( @@ -1021,8 +1010,7 @@ impl BlocksDal<'_, '_> { FROM l1_batches WHERE - is_sealed - AND number = $1 + number = $1 AND commitment = $2 "#, i64::from(number.0), @@ -1180,8 +1168,7 @@ impl BlocksDal<'_, '_> { FROM l1_batches WHERE - is_sealed - AND number = $1 + number = $1 "#, i64::from(l1_batch_number.0) ) @@ -1564,8 +1551,7 @@ impl BlocksDal<'_, '_> { l1_batches LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number WHERE - is_sealed - AND number BETWEEN $1 AND $2 + number BETWEEN $1 AND $2 ORDER BY number LIMIT @@ -1630,8 +1616,7 @@ impl BlocksDal<'_, '_> { LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number JOIN protocol_versions ON protocol_versions.id = l1_batches.protocol_version WHERE - is_sealed - AND eth_commit_tx_id IS NULL + eth_commit_tx_id IS NULL AND number != 0 AND protocol_versions.bootloader_code_hash = $1 AND protocol_versions.default_account_code_hash = $2 @@ -1710,8 +1695,7 @@ impl BlocksDal<'_, '_> { LEFT JOIN data_availability ON data_availability.l1_batch_number = l1_batches.number JOIN protocol_versions ON protocol_versions.id = l1_batches.protocol_version WHERE - is_sealed - AND eth_commit_tx_id IS NULL + eth_commit_tx_id IS NULL AND number != 0 AND protocol_versions.bootloader_code_hash = $1 AND protocol_versions.default_account_code_hash = $2 @@ -1762,8 +1746,7 @@ impl BlocksDal<'_, '_> { FROM l1_batches WHERE - is_sealed - AND number = $1 + number = $1 "#, i64::from(number.0) ) @@ -1787,8 +1770,7 @@ impl BlocksDal<'_, '_> { FROM l1_batches WHERE - is_sealed - AND number = $1 + number = $1 "#, i64::from(number.0) ) @@ -1848,8 +1830,7 @@ impl BlocksDal<'_, '_> { FROM l1_batches WHERE - is_sealed - AND number = $1 + number = $1 "#, i64::from(number.0) ) @@ -2348,8 +2329,7 @@ impl BlocksDal<'_, '_> { FROM l1_batches WHERE - is_sealed - AND number = $1 + number = $1 "#, i64::from(l1_batch_number.0), ) @@ -2376,8 +2356,7 @@ impl BlocksDal<'_, '_> { FROM l1_batches WHERE - is_sealed - AND number = $1 + number = $1 "#, i64::from(l1_batch_number.0), ) diff --git a/core/lib/dal/src/data_availability_dal.rs b/core/lib/dal/src/data_availability_dal.rs index 789803fdb825..24048ec4fa19 100644 --- a/core/lib/dal/src/data_availability_dal.rs +++ b/core/lib/dal/src/data_availability_dal.rs @@ -189,8 +189,7 @@ impl DataAvailabilityDal<'_, '_> { l1_batches LEFT JOIN data_availability ON data_availability.l1_batch_number = l1_batches.number WHERE - is_sealed - AND eth_commit_tx_id IS NULL + eth_commit_tx_id IS NULL AND number != 0 AND data_availability.blob_id IS NULL AND pubdata_input IS NOT NULL From fabfe300f147e88b936fb3070b8c47d6ee71cf4f Mon Sep 17 00:00:00 2001 From: Daniyar Itegulov Date: Fri, 13 Sep 2024 12:21:36 +1000 Subject: [PATCH 05/14] use `PubdataIndependent` batch fee variant --- core/lib/dal/src/blocks_dal.rs | 20 ++++++++++++++++---- core/node/genesis/src/lib.rs | 6 ++++-- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/core/lib/dal/src/blocks_dal.rs b/core/lib/dal/src/blocks_dal.rs index 7e425768a85b..faf5a224730b 100644 --- a/core/lib/dal/src/blocks_dal.rs +++ b/core/lib/dal/src/blocks_dal.rs @@ -2536,8 +2536,12 @@ impl BlocksDal<'_, '_> { } pub async fn insert_mock_l1_batch(&mut self, header: &L1BatchHeader) -> anyhow::Result<()> { - self.insert_l1_batch(header.number, header.timestamp, BatchFeeInput::default()) - .await?; + self.insert_l1_batch( + header.number, + header.timestamp, + BatchFeeInput::pubdata_independent(100, 100, 100), + ) + .await?; self.mark_l1_batch_as_sealed( header, &[], @@ -2815,7 +2819,11 @@ mod tests { execute: 10, }; conn.blocks_dal() - .insert_l1_batch(header.number, header.timestamp, BatchFeeInput::default()) + .insert_l1_batch( + header.number, + header.timestamp, + BatchFeeInput::pubdata_independent(100, 100, 100), + ) .await .unwrap(); conn.blocks_dal() @@ -2827,7 +2835,11 @@ mod tests { header.timestamp += 100; predicted_gas += predicted_gas; conn.blocks_dal() - .insert_l1_batch(header.number, header.timestamp, BatchFeeInput::default()) + .insert_l1_batch( + header.number, + header.timestamp, + BatchFeeInput::pubdata_independent(100, 100, 100), + ) .await .unwrap(); conn.blocks_dal() diff --git a/core/node/genesis/src/lib.rs b/core/node/genesis/src/lib.rs index 989da710a36c..3d90ee17005f 100644 --- a/core/node/genesis/src/lib.rs +++ b/core/node/genesis/src/lib.rs @@ -15,6 +15,7 @@ use zksync_eth_client::{CallFunctionArgs, EthInterface}; use zksync_merkle_tree::{domain::ZkSyncTree, TreeInstruction}; use zksync_multivm::utils::get_max_gas_per_pubdata_byte; use zksync_system_constants::PRIORITY_EXPIRATION; +use zksync_types::fee_model::PubdataIndependentBatchFeeModelInput; use zksync_types::{ block::{BlockGasCount, DeployedContract, L1BatchHeader, L2BlockHasher, L2BlockHeader}, commitment::{CommitmentInput, L1BatchCommitment}, @@ -386,6 +387,7 @@ pub async fn create_genesis_l1_batch( base_system_contracts.hashes(), protocol_version.minor, ); + let batch_fee_input = BatchFeeInput::pubdata_independent(0, 0, 0); let genesis_l2_block_header = L2BlockHeader { number: L2BlockNumber(0), @@ -396,7 +398,7 @@ pub async fn create_genesis_l1_batch( fee_account_address: Default::default(), base_fee_per_gas: 0, gas_per_pubdata_limit: get_max_gas_per_pubdata_byte(protocol_version.minor.into()), - batch_fee_input: BatchFeeInput::l1_pegged(0, 0), + batch_fee_input, base_system_contracts_hashes: base_system_contracts.hashes(), protocol_version: Some(protocol_version.minor), virtual_blocks: 0, @@ -415,7 +417,7 @@ pub async fn create_genesis_l1_batch( .insert_l1_batch( genesis_l1_batch_header.number, genesis_l1_batch_header.timestamp, - BatchFeeInput::default(), + batch_fee_input, ) .await?; transaction From bd275b9bb118d2eed9dd792ae9277e1007df2a30 Mon Sep 17 00:00:00 2001 From: Daniyar Itegulov Date: Fri, 13 Sep 2024 12:22:27 +1000 Subject: [PATCH 06/14] fmt --- core/node/genesis/src/lib.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/core/node/genesis/src/lib.rs b/core/node/genesis/src/lib.rs index 3d90ee17005f..8c5bece9d356 100644 --- a/core/node/genesis/src/lib.rs +++ b/core/node/genesis/src/lib.rs @@ -15,11 +15,10 @@ use zksync_eth_client::{CallFunctionArgs, EthInterface}; use zksync_merkle_tree::{domain::ZkSyncTree, TreeInstruction}; use zksync_multivm::utils::get_max_gas_per_pubdata_byte; use zksync_system_constants::PRIORITY_EXPIRATION; -use zksync_types::fee_model::PubdataIndependentBatchFeeModelInput; use zksync_types::{ block::{BlockGasCount, DeployedContract, L1BatchHeader, L2BlockHasher, L2BlockHeader}, commitment::{CommitmentInput, L1BatchCommitment}, - fee_model::BatchFeeInput, + fee_model::{BatchFeeInput, PubdataIndependentBatchFeeModelInput}, protocol_upgrade::decode_set_chain_id_event, protocol_version::{L1VerifierConfig, ProtocolSemanticVersion}, system_contracts::get_system_smart_contracts, From 8bfdeca71da3c37413f4e0f9473bb91ebd7773dc Mon Sep 17 00:00:00 2001 From: Daniyar Itegulov Date: Fri, 13 Sep 2024 15:06:28 +1000 Subject: [PATCH 07/14] lint --- core/lib/dal/src/blocks_dal.rs | 3 +-- core/node/genesis/src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/core/lib/dal/src/blocks_dal.rs b/core/lib/dal/src/blocks_dal.rs index faf5a224730b..299ca1dda5ae 100644 --- a/core/lib/dal/src/blocks_dal.rs +++ b/core/lib/dal/src/blocks_dal.rs @@ -576,8 +576,7 @@ impl BlocksDal<'_, '_> { timestamp: u64, batch_fee_input: BatchFeeInput, ) -> DalResult<()> { - let instrumentation = Instrumented::new("insert_l1_batch").with_arg("number", &number); - let query = sqlx::query!( + sqlx::query!( r#" INSERT INTO l1_batches ( diff --git a/core/node/genesis/src/lib.rs b/core/node/genesis/src/lib.rs index 8c5bece9d356..3cacd5a922ae 100644 --- a/core/node/genesis/src/lib.rs +++ b/core/node/genesis/src/lib.rs @@ -18,7 +18,7 @@ use zksync_system_constants::PRIORITY_EXPIRATION; use zksync_types::{ block::{BlockGasCount, DeployedContract, L1BatchHeader, L2BlockHasher, L2BlockHeader}, commitment::{CommitmentInput, L1BatchCommitment}, - fee_model::{BatchFeeInput, PubdataIndependentBatchFeeModelInput}, + fee_model::BatchFeeInput, protocol_upgrade::decode_set_chain_id_event, protocol_version::{L1VerifierConfig, ProtocolSemanticVersion}, system_contracts::get_system_smart_contracts, From f2cd67bfc0489373a5aa2691119a66f0a21dc256 Mon Sep 17 00:00:00 2001 From: Daniyar Itegulov Date: Fri, 13 Sep 2024 15:06:45 +1000 Subject: [PATCH 08/14] make `fair_pubdata_price` not null --- .../dal/migrations/20240910112120_unsealed_batches_in_db.up.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/lib/dal/migrations/20240910112120_unsealed_batches_in_db.up.sql b/core/lib/dal/migrations/20240910112120_unsealed_batches_in_db.up.sql index f08119caa49f..54bc3f81a592 100644 --- a/core/lib/dal/migrations/20240910112120_unsealed_batches_in_db.up.sql +++ b/core/lib/dal/migrations/20240910112120_unsealed_batches_in_db.up.sql @@ -1,4 +1,4 @@ ALTER TABLE l1_batches RENAME COLUMN is_finished TO is_sealed; ALTER table l1_batches - ADD COLUMN fair_pubdata_price bigint; + ADD COLUMN fair_pubdata_price bigint NOT NULL DEFAULT 0; From 2e843bddfa54aec5f316d5998d330e8d427edcb9 Mon Sep 17 00:00:00 2001 From: Daniyar Itegulov Date: Thu, 3 Oct 2024 14:30:22 +1000 Subject: [PATCH 09/14] insert protocol_version and fee_address in unsealed batches --- ...232fcf489829c9f0ed74e03e22cf9c6d9af1.json} | 12 ++++-- ...b81f1fd2c43cf460a3d2b268fc4757fb173a.json} | 12 ++++-- ...fecac25a826d5f7f729208fe23b9cd485c32.json} | 12 ++++-- ...512670180908eab56f49e70d42e1a933bd97.json} | 12 ++++-- ...5b46fec57bde627c9d6700c220fba60320bd.json} | 12 ++++-- ...7efdf3996bb3520c81c6b63b0ddc6f1b0d84.json} | 12 ++++-- ...d20df9afe9ba1e1a5b455205300b58fddd06.json} | 12 ++++-- ...1d3747c1ae3859292ff8caced9730b42acdf7.json | 20 +++++++++ ...a3def7e41216d0ca684784f71074dc1b5c5e.json} | 12 ++++-- ...5f335e8279fda50e8b78d559b2af828d9b0a.json} | 12 ++++-- ...e34fc2b97636f33696eaa2a7b1e81b783b650.json | 18 -------- ...240910112120_unsealed_batches_in_db.up.sql | 3 +- core/lib/dal/src/blocks_dal.rs | 41 +++++++++++++++---- core/lib/dal/src/models/storage_block.rs | 4 ++ core/lib/types/src/block.rs | 2 + core/node/block_reverter/src/tests.rs | 1 + core/node/genesis/src/lib.rs | 2 + core/node/node_sync/src/external_io.rs | 2 + core/node/state_keeper/src/io/mempool.rs | 8 +++- core/node/state_keeper/src/io/persistence.rs | 2 + .../state_keeper/src/io/seal_logic/mod.rs | 1 + core/node/state_keeper/src/updates/mod.rs | 2 +- 22 files changed, 157 insertions(+), 57 deletions(-) rename core/lib/dal/.sqlx/{query-932ec4483be7ebf34579f17694f6d14963cbfc84261824e47fbab1323895371d.json => query-0fe5562f14f2746f1c098636fcc3232fcf489829c9f0ed74e03e22cf9c6d9af1.json} (87%) rename core/lib/dal/.sqlx/{query-30268c71e4bd0d08015af6ae130d3ee5d5140714297401b4bde1e950ed6e971e.json => query-2e0e17395685244ef508fc50f3a7b81f1fd2c43cf460a3d2b268fc4757fb173a.json} (87%) rename core/lib/dal/.sqlx/{query-2dc550a35fb0f0ddb1aded83d54a2e93066a5cffbb3857dfd3c6fe00c307eada.json => query-5aa205491025edc3b367a0ea1a32fecac25a826d5f7f729208fe23b9cd485c32.json} (80%) rename core/lib/dal/.sqlx/{query-5250341acd42582e41570b6d7e380ae6c8a26f425429116a62892be84c2ff9fb.json => query-6d2a29adc9cceb8ef0d614dd3b9d512670180908eab56f49e70d42e1a933bd97.json} (87%) rename core/lib/dal/.sqlx/{query-ae30067056fe29febd68408c2ca2e604958488a41d3ee2bcbd05d269bcdfc7aa.json => query-7346e831cd774c8b3bdbcfb553a45b46fec57bde627c9d6700c220fba60320bd.json} (79%) rename core/lib/dal/.sqlx/{query-883a8ae0dccc2b46ec512625784ed0a2b72f141f36a682fb880ad76e19ea6914.json => query-7e11644708ac8b20a5793534ad8e7efdf3996bb3520c81c6b63b0ddc6f1b0d84.json} (84%) rename core/lib/dal/.sqlx/{query-d754369ae0d46e2cb336df5bffd1ea32ea002b66734a36a1dfec64fa6d7fb6c9.json => query-8194efed3c71aad25521b220ffd1d20df9afe9ba1e1a5b455205300b58fddd06.json} (89%) create mode 100644 core/lib/dal/.sqlx/query-820d1e33271bfd6aff55c8e31141d3747c1ae3859292ff8caced9730b42acdf7.json rename core/lib/dal/.sqlx/{query-ac4f1e7af7d866daf45b6997a8ce0a02a40c9f37be949bd4d088744f9c842ef3.json => query-87ac5fd7cd2f7077f07742ded252a3def7e41216d0ca684784f71074dc1b5c5e.json} (74%) rename core/lib/dal/.sqlx/{query-4ef330359df85ad6e0110a068ef3afa9cf50eafc7ac542975edea9bd592ce862.json => query-98950ef9f0085089044429b271dd5f335e8279fda50e8b78d559b2af828d9b0a.json} (86%) delete mode 100644 core/lib/dal/.sqlx/query-d1c7dcad34897fda05776667f1ce34fc2b97636f33696eaa2a7b1e81b783b650.json diff --git a/core/lib/dal/.sqlx/query-932ec4483be7ebf34579f17694f6d14963cbfc84261824e47fbab1323895371d.json b/core/lib/dal/.sqlx/query-0fe5562f14f2746f1c098636fcc3232fcf489829c9f0ed74e03e22cf9c6d9af1.json similarity index 87% rename from core/lib/dal/.sqlx/query-932ec4483be7ebf34579f17694f6d14963cbfc84261824e47fbab1323895371d.json rename to core/lib/dal/.sqlx/query-0fe5562f14f2746f1c098636fcc3232fcf489829c9f0ed74e03e22cf9c6d9af1.json index 0b1daaa10e5f..32dba61ab466 100644 --- a/core/lib/dal/.sqlx/query-932ec4483be7ebf34579f17694f6d14963cbfc84261824e47fbab1323895371d.json +++ b/core/lib/dal/.sqlx/query-0fe5562f14f2746f1c098636fcc3232fcf489829c9f0ed74e03e22cf9c6d9af1.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n number,\n timestamp,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n hash,\n commitment,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_merkle_root,\n rollup_last_leaf_index,\n zkporter_is_available,\n bootloader_code_hash,\n default_aa_code_hash,\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 pubdata_input\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 ", + "query": "\n SELECT\n number,\n timestamp,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n hash,\n commitment,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_merkle_root,\n rollup_last_leaf_index,\n zkporter_is_available,\n bootloader_code_hash,\n default_aa_code_hash,\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 pubdata_input,\n fee_address\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 ", "describe": { "columns": [ { @@ -132,6 +132,11 @@ "ordinal": 25, "name": "pubdata_input", "type_info": "Bytea" + }, + { + "ordinal": 26, + "name": "fee_address", + "type_info": "Bytea" } ], "parameters": { @@ -167,8 +172,9 @@ false, true, true, - true + true, + false ] }, - "hash": "932ec4483be7ebf34579f17694f6d14963cbfc84261824e47fbab1323895371d" + "hash": "0fe5562f14f2746f1c098636fcc3232fcf489829c9f0ed74e03e22cf9c6d9af1" } diff --git a/core/lib/dal/.sqlx/query-30268c71e4bd0d08015af6ae130d3ee5d5140714297401b4bde1e950ed6e971e.json b/core/lib/dal/.sqlx/query-2e0e17395685244ef508fc50f3a7b81f1fd2c43cf460a3d2b268fc4757fb173a.json similarity index 87% rename from core/lib/dal/.sqlx/query-30268c71e4bd0d08015af6ae130d3ee5d5140714297401b4bde1e950ed6e971e.json rename to core/lib/dal/.sqlx/query-2e0e17395685244ef508fc50f3a7b81f1fd2c43cf460a3d2b268fc4757fb173a.json index a96d94a5c55f..a9132125a06d 100644 --- a/core/lib/dal/.sqlx/query-30268c71e4bd0d08015af6ae130d3ee5d5140714297401b4bde1e950ed6e971e.json +++ b/core/lib/dal/.sqlx/query-2e0e17395685244ef508fc50f3a7b81f1fd2c43cf460a3d2b268fc4757fb173a.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n number,\n timestamp,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n hash,\n commitment,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_merkle_root,\n rollup_last_leaf_index,\n zkporter_is_available,\n bootloader_code_hash,\n default_aa_code_hash,\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 pubdata_input\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 ", + "query": "\n SELECT\n number,\n timestamp,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n hash,\n commitment,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_merkle_root,\n rollup_last_leaf_index,\n zkporter_is_available,\n bootloader_code_hash,\n default_aa_code_hash,\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 pubdata_input,\n fee_address\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 ", "describe": { "columns": [ { @@ -132,6 +132,11 @@ "ordinal": 25, "name": "pubdata_input", "type_info": "Bytea" + }, + { + "ordinal": 26, + "name": "fee_address", + "type_info": "Bytea" } ], "parameters": { @@ -163,8 +168,9 @@ false, true, true, - true + true, + false ] }, - "hash": "30268c71e4bd0d08015af6ae130d3ee5d5140714297401b4bde1e950ed6e971e" + "hash": "2e0e17395685244ef508fc50f3a7b81f1fd2c43cf460a3d2b268fc4757fb173a" } diff --git a/core/lib/dal/.sqlx/query-2dc550a35fb0f0ddb1aded83d54a2e93066a5cffbb3857dfd3c6fe00c307eada.json b/core/lib/dal/.sqlx/query-5aa205491025edc3b367a0ea1a32fecac25a826d5f7f729208fe23b9cd485c32.json similarity index 80% rename from core/lib/dal/.sqlx/query-2dc550a35fb0f0ddb1aded83d54a2e93066a5cffbb3857dfd3c6fe00c307eada.json rename to core/lib/dal/.sqlx/query-5aa205491025edc3b367a0ea1a32fecac25a826d5f7f729208fe23b9cd485c32.json index 8bf22e1b6fb7..2e4206ab303d 100644 --- a/core/lib/dal/.sqlx/query-2dc550a35fb0f0ddb1aded83d54a2e93066a5cffbb3857dfd3c6fe00c307eada.json +++ b/core/lib/dal/.sqlx/query-5aa205491025edc3b367a0ea1a32fecac25a826d5f7f729208fe23b9cd485c32.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n number,\n l1_batches.timestamp,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n hash,\n commitment,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_merkle_root,\n rollup_last_leaf_index,\n zkporter_is_available,\n l1_batches.bootloader_code_hash,\n l1_batches.default_aa_code_hash,\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 pubdata_input\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 ", + "query": "\n SELECT\n number,\n l1_batches.timestamp,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n hash,\n commitment,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_merkle_root,\n rollup_last_leaf_index,\n zkporter_is_available,\n l1_batches.bootloader_code_hash,\n l1_batches.default_aa_code_hash,\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 pubdata_input,\n fee_address\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 ", "describe": { "columns": [ { @@ -132,6 +132,11 @@ "ordinal": 25, "name": "pubdata_input", "type_info": "Bytea" + }, + { + "ordinal": 26, + "name": "fee_address", + "type_info": "Bytea" } ], "parameters": { @@ -168,8 +173,9 @@ false, true, true, - true + true, + false ] }, - "hash": "2dc550a35fb0f0ddb1aded83d54a2e93066a5cffbb3857dfd3c6fe00c307eada" + "hash": "5aa205491025edc3b367a0ea1a32fecac25a826d5f7f729208fe23b9cd485c32" } diff --git a/core/lib/dal/.sqlx/query-5250341acd42582e41570b6d7e380ae6c8a26f425429116a62892be84c2ff9fb.json b/core/lib/dal/.sqlx/query-6d2a29adc9cceb8ef0d614dd3b9d512670180908eab56f49e70d42e1a933bd97.json similarity index 87% rename from core/lib/dal/.sqlx/query-5250341acd42582e41570b6d7e380ae6c8a26f425429116a62892be84c2ff9fb.json rename to core/lib/dal/.sqlx/query-6d2a29adc9cceb8ef0d614dd3b9d512670180908eab56f49e70d42e1a933bd97.json index 93d522f5fb73..7f2babc32af1 100644 --- a/core/lib/dal/.sqlx/query-5250341acd42582e41570b6d7e380ae6c8a26f425429116a62892be84c2ff9fb.json +++ b/core/lib/dal/.sqlx/query-6d2a29adc9cceb8ef0d614dd3b9d512670180908eab56f49e70d42e1a933bd97.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n number,\n timestamp,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n hash,\n commitment,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_merkle_root,\n rollup_last_leaf_index,\n zkporter_is_available,\n bootloader_code_hash,\n default_aa_code_hash,\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 pubdata_input\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 ", + "query": "\n SELECT\n number,\n timestamp,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n hash,\n commitment,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_merkle_root,\n rollup_last_leaf_index,\n zkporter_is_available,\n bootloader_code_hash,\n default_aa_code_hash,\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 pubdata_input,\n fee_address\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 ", "describe": { "columns": [ { @@ -132,6 +132,11 @@ "ordinal": 25, "name": "pubdata_input", "type_info": "Bytea" + }, + { + "ordinal": 26, + "name": "fee_address", + "type_info": "Bytea" } ], "parameters": { @@ -165,8 +170,9 @@ false, true, true, - true + true, + false ] }, - "hash": "5250341acd42582e41570b6d7e380ae6c8a26f425429116a62892be84c2ff9fb" + "hash": "6d2a29adc9cceb8ef0d614dd3b9d512670180908eab56f49e70d42e1a933bd97" } diff --git a/core/lib/dal/.sqlx/query-ae30067056fe29febd68408c2ca2e604958488a41d3ee2bcbd05d269bcdfc7aa.json b/core/lib/dal/.sqlx/query-7346e831cd774c8b3bdbcfb553a45b46fec57bde627c9d6700c220fba60320bd.json similarity index 79% rename from core/lib/dal/.sqlx/query-ae30067056fe29febd68408c2ca2e604958488a41d3ee2bcbd05d269bcdfc7aa.json rename to core/lib/dal/.sqlx/query-7346e831cd774c8b3bdbcfb553a45b46fec57bde627c9d6700c220fba60320bd.json index 9e212249490c..42654f8e4207 100644 --- a/core/lib/dal/.sqlx/query-ae30067056fe29febd68408c2ca2e604958488a41d3ee2bcbd05d269bcdfc7aa.json +++ b/core/lib/dal/.sqlx/query-7346e831cd774c8b3bdbcfb553a45b46fec57bde627c9d6700c220fba60320bd.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n number,\n timestamp,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n hash,\n commitment,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_merkle_root,\n rollup_last_leaf_index,\n zkporter_is_available,\n bootloader_code_hash,\n default_aa_code_hash,\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 pubdata_input\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 ", + "query": "\n SELECT\n number,\n timestamp,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n hash,\n commitment,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_merkle_root,\n rollup_last_leaf_index,\n zkporter_is_available,\n bootloader_code_hash,\n default_aa_code_hash,\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 pubdata_input,\n fee_address\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 ", "describe": { "columns": [ { @@ -132,6 +132,11 @@ "ordinal": 25, "name": "pubdata_input", "type_info": "Bytea" + }, + { + "ordinal": 26, + "name": "fee_address", + "type_info": "Bytea" } ], "parameters": { @@ -166,8 +171,9 @@ true, true, true, - true + true, + false ] }, - "hash": "ae30067056fe29febd68408c2ca2e604958488a41d3ee2bcbd05d269bcdfc7aa" + "hash": "7346e831cd774c8b3bdbcfb553a45b46fec57bde627c9d6700c220fba60320bd" } diff --git a/core/lib/dal/.sqlx/query-883a8ae0dccc2b46ec512625784ed0a2b72f141f36a682fb880ad76e19ea6914.json b/core/lib/dal/.sqlx/query-7e11644708ac8b20a5793534ad8e7efdf3996bb3520c81c6b63b0ddc6f1b0d84.json similarity index 84% rename from core/lib/dal/.sqlx/query-883a8ae0dccc2b46ec512625784ed0a2b72f141f36a682fb880ad76e19ea6914.json rename to core/lib/dal/.sqlx/query-7e11644708ac8b20a5793534ad8e7efdf3996bb3520c81c6b63b0ddc6f1b0d84.json index 2f55e6d1a7d4..e6405b4f48e7 100644 --- a/core/lib/dal/.sqlx/query-883a8ae0dccc2b46ec512625784ed0a2b72f141f36a682fb880ad76e19ea6914.json +++ b/core/lib/dal/.sqlx/query-7e11644708ac8b20a5793534ad8e7efdf3996bb3520c81c6b63b0ddc6f1b0d84.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n number,\n l1_tx_count,\n l2_tx_count,\n timestamp,\n l2_to_l1_messages,\n bloom,\n priority_ops_onchain_data,\n used_contract_hashes,\n bootloader_code_hash,\n default_aa_code_hash,\n protocol_version,\n system_logs,\n pubdata_input\n FROM\n l1_batches\n WHERE\n is_sealed\n AND number = $1\n ", + "query": "\n SELECT\n number,\n l1_tx_count,\n l2_tx_count,\n timestamp,\n l2_to_l1_messages,\n bloom,\n priority_ops_onchain_data,\n used_contract_hashes,\n bootloader_code_hash,\n default_aa_code_hash,\n protocol_version,\n system_logs,\n pubdata_input,\n fee_address\n FROM\n l1_batches\n WHERE\n is_sealed\n AND number = $1\n ", "describe": { "columns": [ { @@ -67,6 +67,11 @@ "ordinal": 12, "name": "pubdata_input", "type_info": "Bytea" + }, + { + "ordinal": 13, + "name": "fee_address", + "type_info": "Bytea" } ], "parameters": { @@ -87,8 +92,9 @@ true, true, false, - true + true, + false ] }, - "hash": "883a8ae0dccc2b46ec512625784ed0a2b72f141f36a682fb880ad76e19ea6914" + "hash": "7e11644708ac8b20a5793534ad8e7efdf3996bb3520c81c6b63b0ddc6f1b0d84" } diff --git a/core/lib/dal/.sqlx/query-d754369ae0d46e2cb336df5bffd1ea32ea002b66734a36a1dfec64fa6d7fb6c9.json b/core/lib/dal/.sqlx/query-8194efed3c71aad25521b220ffd1d20df9afe9ba1e1a5b455205300b58fddd06.json similarity index 89% rename from core/lib/dal/.sqlx/query-d754369ae0d46e2cb336df5bffd1ea32ea002b66734a36a1dfec64fa6d7fb6c9.json rename to core/lib/dal/.sqlx/query-8194efed3c71aad25521b220ffd1d20df9afe9ba1e1a5b455205300b58fddd06.json index 024f8e8737e6..5b194e07fc84 100644 --- a/core/lib/dal/.sqlx/query-d754369ae0d46e2cb336df5bffd1ea32ea002b66734a36a1dfec64fa6d7fb6c9.json +++ b/core/lib/dal/.sqlx/query-8194efed3c71aad25521b220ffd1d20df9afe9ba1e1a5b455205300b58fddd06.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n number,\n timestamp,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n hash,\n commitment,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_merkle_root,\n rollup_last_leaf_index,\n zkporter_is_available,\n bootloader_code_hash,\n default_aa_code_hash,\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 pubdata_input\n FROM\n l1_batches\n LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number\n WHERE\n is_sealed\n AND number = $1\n ", + "query": "\n SELECT\n number,\n timestamp,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n hash,\n commitment,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_merkle_root,\n rollup_last_leaf_index,\n zkporter_is_available,\n bootloader_code_hash,\n default_aa_code_hash,\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 pubdata_input,\n fee_address\n FROM\n l1_batches\n LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number\n WHERE\n is_sealed\n AND number = $1\n ", "describe": { "columns": [ { @@ -132,6 +132,11 @@ "ordinal": 25, "name": "pubdata_input", "type_info": "Bytea" + }, + { + "ordinal": 26, + "name": "fee_address", + "type_info": "Bytea" } ], "parameters": { @@ -165,8 +170,9 @@ true, true, true, - true + true, + false ] }, - "hash": "d754369ae0d46e2cb336df5bffd1ea32ea002b66734a36a1dfec64fa6d7fb6c9" + "hash": "8194efed3c71aad25521b220ffd1d20df9afe9ba1e1a5b455205300b58fddd06" } diff --git a/core/lib/dal/.sqlx/query-820d1e33271bfd6aff55c8e31141d3747c1ae3859292ff8caced9730b42acdf7.json b/core/lib/dal/.sqlx/query-820d1e33271bfd6aff55c8e31141d3747c1ae3859292ff8caced9730b42acdf7.json new file mode 100644 index 000000000000..18d24009ba7d --- /dev/null +++ b/core/lib/dal/.sqlx/query-820d1e33271bfd6aff55c8e31141d3747c1ae3859292ff8caced9730b42acdf7.json @@ -0,0 +1,20 @@ +{ + "db_name": "PostgreSQL", + "query": "\n INSERT INTO\n l1_batches (\n number,\n timestamp,\n protocol_version,\n fee_address,\n l1_gas_price,\n l2_fair_gas_price,\n fair_pubdata_price,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n initial_bootloader_heap_content,\n used_contract_hashes,\n created_at,\n updated_at,\n is_sealed\n )\n VALUES\n (\n $1,\n $2,\n $3,\n $4,\n $5,\n $6,\n $7,\n 0,\n 0,\n ''::bytea,\n '{}'::bytea[],\n '{}'::jsonb,\n '{}'::jsonb,\n NOW(),\n NOW(),\n FALSE\n )\n ", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Int8", + "Int8", + "Int4", + "Bytea", + "Int8", + "Int8", + "Int8" + ] + }, + "nullable": [] + }, + "hash": "820d1e33271bfd6aff55c8e31141d3747c1ae3859292ff8caced9730b42acdf7" +} diff --git a/core/lib/dal/.sqlx/query-ac4f1e7af7d866daf45b6997a8ce0a02a40c9f37be949bd4d088744f9c842ef3.json b/core/lib/dal/.sqlx/query-87ac5fd7cd2f7077f07742ded252a3def7e41216d0ca684784f71074dc1b5c5e.json similarity index 74% rename from core/lib/dal/.sqlx/query-ac4f1e7af7d866daf45b6997a8ce0a02a40c9f37be949bd4d088744f9c842ef3.json rename to core/lib/dal/.sqlx/query-87ac5fd7cd2f7077f07742ded252a3def7e41216d0ca684784f71074dc1b5c5e.json index 671b56760d6b..9a523d3d5041 100644 --- a/core/lib/dal/.sqlx/query-ac4f1e7af7d866daf45b6997a8ce0a02a40c9f37be949bd4d088744f9c842ef3.json +++ b/core/lib/dal/.sqlx/query-87ac5fd7cd2f7077f07742ded252a3def7e41216d0ca684784f71074dc1b5c5e.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n number,\n l1_batches.timestamp,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n hash,\n commitment,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_merkle_root,\n rollup_last_leaf_index,\n zkporter_is_available,\n l1_batches.bootloader_code_hash,\n l1_batches.default_aa_code_hash,\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 pubdata_input\n FROM\n l1_batches\n LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number\n LEFT JOIN\n data_availability\n ON data_availability.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 AND (\n data_availability.inclusion_data IS NOT NULL\n OR $4 IS FALSE\n )\n ORDER BY\n number\n LIMIT\n $5\n ", + "query": "\n SELECT\n number,\n l1_batches.timestamp,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n hash,\n commitment,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_merkle_root,\n rollup_last_leaf_index,\n zkporter_is_available,\n l1_batches.bootloader_code_hash,\n l1_batches.default_aa_code_hash,\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 pubdata_input,\n fee_address\n FROM\n l1_batches\n LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number\n LEFT JOIN\n data_availability\n ON data_availability.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 AND (\n data_availability.inclusion_data IS NOT NULL\n OR $4 IS FALSE\n )\n ORDER BY\n number\n LIMIT\n $5\n ", "describe": { "columns": [ { @@ -132,6 +132,11 @@ "ordinal": 25, "name": "pubdata_input", "type_info": "Bytea" + }, + { + "ordinal": 26, + "name": "fee_address", + "type_info": "Bytea" } ], "parameters": { @@ -169,8 +174,9 @@ false, true, true, - true + true, + false ] }, - "hash": "ac4f1e7af7d866daf45b6997a8ce0a02a40c9f37be949bd4d088744f9c842ef3" + "hash": "87ac5fd7cd2f7077f07742ded252a3def7e41216d0ca684784f71074dc1b5c5e" } diff --git a/core/lib/dal/.sqlx/query-4ef330359df85ad6e0110a068ef3afa9cf50eafc7ac542975edea9bd592ce862.json b/core/lib/dal/.sqlx/query-98950ef9f0085089044429b271dd5f335e8279fda50e8b78d559b2af828d9b0a.json similarity index 86% rename from core/lib/dal/.sqlx/query-4ef330359df85ad6e0110a068ef3afa9cf50eafc7ac542975edea9bd592ce862.json rename to core/lib/dal/.sqlx/query-98950ef9f0085089044429b271dd5f335e8279fda50e8b78d559b2af828d9b0a.json index 10e2a76618f6..dc82ddf8696f 100644 --- a/core/lib/dal/.sqlx/query-4ef330359df85ad6e0110a068ef3afa9cf50eafc7ac542975edea9bd592ce862.json +++ b/core/lib/dal/.sqlx/query-98950ef9f0085089044429b271dd5f335e8279fda50e8b78d559b2af828d9b0a.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n number,\n timestamp,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n hash,\n commitment,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_merkle_root,\n rollup_last_leaf_index,\n zkporter_is_available,\n bootloader_code_hash,\n default_aa_code_hash,\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 pubdata_input\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 ", + "query": "\n SELECT\n number,\n timestamp,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n hash,\n commitment,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_merkle_root,\n rollup_last_leaf_index,\n zkporter_is_available,\n bootloader_code_hash,\n default_aa_code_hash,\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 pubdata_input,\n fee_address\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 ", "describe": { "columns": [ { @@ -132,6 +132,11 @@ "ordinal": 25, "name": "pubdata_input", "type_info": "Bytea" + }, + { + "ordinal": 26, + "name": "fee_address", + "type_info": "Bytea" } ], "parameters": { @@ -165,8 +170,9 @@ false, true, true, - true + true, + false ] }, - "hash": "4ef330359df85ad6e0110a068ef3afa9cf50eafc7ac542975edea9bd592ce862" + "hash": "98950ef9f0085089044429b271dd5f335e8279fda50e8b78d559b2af828d9b0a" } diff --git a/core/lib/dal/.sqlx/query-d1c7dcad34897fda05776667f1ce34fc2b97636f33696eaa2a7b1e81b783b650.json b/core/lib/dal/.sqlx/query-d1c7dcad34897fda05776667f1ce34fc2b97636f33696eaa2a7b1e81b783b650.json deleted file mode 100644 index 101edb33b684..000000000000 --- a/core/lib/dal/.sqlx/query-d1c7dcad34897fda05776667f1ce34fc2b97636f33696eaa2a7b1e81b783b650.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "\n INSERT INTO\n l1_batches (\n number,\n timestamp,\n l1_gas_price,\n l2_fair_gas_price,\n fair_pubdata_price,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n initial_bootloader_heap_content,\n used_contract_hashes,\n created_at,\n updated_at,\n is_sealed\n )\n VALUES\n (\n $1,\n $2,\n $3,\n $4,\n $5,\n 0,\n 0,\n ''::bytea,\n '{}'::bytea[],\n '{}'::jsonb,\n '{}'::jsonb,\n NOW(),\n NOW(),\n FALSE\n )\n ", - "describe": { - "columns": [], - "parameters": { - "Left": [ - "Int8", - "Int8", - "Int8", - "Int8", - "Int8" - ] - }, - "nullable": [] - }, - "hash": "d1c7dcad34897fda05776667f1ce34fc2b97636f33696eaa2a7b1e81b783b650" -} diff --git a/core/lib/dal/migrations/20240910112120_unsealed_batches_in_db.up.sql b/core/lib/dal/migrations/20240910112120_unsealed_batches_in_db.up.sql index 54bc3f81a592..6b08546ea1e5 100644 --- a/core/lib/dal/migrations/20240910112120_unsealed_batches_in_db.up.sql +++ b/core/lib/dal/migrations/20240910112120_unsealed_batches_in_db.up.sql @@ -1,4 +1,5 @@ ALTER TABLE l1_batches RENAME COLUMN is_finished TO is_sealed; ALTER table l1_batches - ADD COLUMN fair_pubdata_price bigint NOT NULL DEFAULT 0; + ADD COLUMN fair_pubdata_price bigint NOT NULL DEFAULT 0, + ADD COLUMN fee_address bytea NOT NULL DEFAULT '\x0000000000000000000000000000000000000000'::bytea; diff --git a/core/lib/dal/src/blocks_dal.rs b/core/lib/dal/src/blocks_dal.rs index 1906c43757f0..2dcc3c8bbedc 100644 --- a/core/lib/dal/src/blocks_dal.rs +++ b/core/lib/dal/src/blocks_dal.rs @@ -340,7 +340,8 @@ impl BlocksDal<'_, '_> { compressed_state_diffs, events_queue_commitment, bootloader_initial_content_commitment, - pubdata_input + pubdata_input, + fee_address FROM l1_batches LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number @@ -376,7 +377,8 @@ impl BlocksDal<'_, '_> { default_aa_code_hash, protocol_version, system_logs, - pubdata_input + pubdata_input, + fee_address FROM l1_batches WHERE @@ -574,6 +576,8 @@ impl BlocksDal<'_, '_> { &mut self, number: L1BatchNumber, timestamp: u64, + protocol_version: Option, + fee_address: Address, batch_fee_input: BatchFeeInput, ) -> DalResult<()> { sqlx::query!( @@ -582,6 +586,8 @@ impl BlocksDal<'_, '_> { l1_batches ( number, timestamp, + protocol_version, + fee_address, l1_gas_price, l2_fair_gas_price, fair_pubdata_price, @@ -602,6 +608,8 @@ impl BlocksDal<'_, '_> { $3, $4, $5, + $6, + $7, 0, 0, ''::bytea, @@ -615,6 +623,8 @@ impl BlocksDal<'_, '_> { "#, i64::from(number.0), timestamp as i64, + protocol_version.map(|v| v as i32), + fee_address.as_bytes(), batch_fee_input.l1_gas_price() as i64, batch_fee_input.fair_l2_gas_price() as i64, batch_fee_input.fair_pubdata_price() as i64, @@ -1094,7 +1104,8 @@ impl BlocksDal<'_, '_> { system_logs, events_queue_commitment, bootloader_initial_content_commitment, - pubdata_input + pubdata_input, + fee_address FROM l1_batches LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number @@ -1280,7 +1291,8 @@ impl BlocksDal<'_, '_> { system_logs, events_queue_commitment, bootloader_initial_content_commitment, - pubdata_input + pubdata_input, + fee_address FROM l1_batches LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number @@ -1360,7 +1372,8 @@ impl BlocksDal<'_, '_> { protocol_version, events_queue_commitment, bootloader_initial_content_commitment, - pubdata_input + pubdata_input, + fee_address FROM ( SELECT @@ -1433,7 +1446,8 @@ impl BlocksDal<'_, '_> { system_logs, events_queue_commitment, bootloader_initial_content_commitment, - pubdata_input + pubdata_input, + fee_address FROM l1_batches LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number @@ -1560,7 +1574,8 @@ impl BlocksDal<'_, '_> { system_logs, events_queue_commitment, bootloader_initial_content_commitment, - pubdata_input + pubdata_input, + fee_address FROM l1_batches LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number @@ -1624,7 +1639,8 @@ impl BlocksDal<'_, '_> { system_logs, events_queue_commitment, bootloader_initial_content_commitment, - pubdata_input + pubdata_input, + fee_address FROM l1_batches LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number @@ -1702,7 +1718,8 @@ impl BlocksDal<'_, '_> { system_logs, events_queue_commitment, bootloader_initial_content_commitment, - pubdata_input + pubdata_input, + fee_address FROM l1_batches LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number @@ -2555,6 +2572,8 @@ impl BlocksDal<'_, '_> { self.insert_l1_batch( header.number, header.timestamp, + header.protocol_version, + header.fee_address, BatchFeeInput::pubdata_independent(100, 100, 100), ) .await?; @@ -2838,6 +2857,8 @@ mod tests { .insert_l1_batch( header.number, header.timestamp, + header.protocol_version, + header.fee_address, BatchFeeInput::pubdata_independent(100, 100, 100), ) .await @@ -2854,6 +2875,8 @@ mod tests { .insert_l1_batch( header.number, header.timestamp, + header.protocol_version, + header.fee_address, BatchFeeInput::pubdata_independent(100, 100, 100), ) .await diff --git a/core/lib/dal/src/models/storage_block.rs b/core/lib/dal/src/models/storage_block.rs index 34e14387ca61..2b85692e9880 100644 --- a/core/lib/dal/src/models/storage_block.rs +++ b/core/lib/dal/src/models/storage_block.rs @@ -52,6 +52,7 @@ pub(crate) struct StorageL1BatchHeader { // will be exactly 7 (or 8 in the event of a protocol upgrade) system logs. pub system_logs: Vec>, pub pubdata_input: Option>, + pub fee_address: Vec, } impl StorageL1BatchHeader { @@ -88,6 +89,7 @@ impl StorageL1BatchHeader { .protocol_version .map(|v| (v as u16).try_into().unwrap()), pubdata_input: self.pubdata_input, + fee_address: Address::from_slice(&self.fee_address), } } } @@ -147,6 +149,7 @@ pub(crate) struct StorageL1Batch { pub events_queue_commitment: Option>, pub bootloader_initial_content_commitment: Option>, pub pubdata_input: Option>, + pub fee_address: Vec, } impl StorageL1Batch { @@ -183,6 +186,7 @@ impl StorageL1Batch { .protocol_version .map(|v| (v as u16).try_into().unwrap()), pubdata_input: self.pubdata_input, + fee_address: Address::from_slice(&self.fee_address), } } } diff --git a/core/lib/types/src/block.rs b/core/lib/types/src/block.rs index 9c1609bf1756..8c0a123f6e4f 100644 --- a/core/lib/types/src/block.rs +++ b/core/lib/types/src/block.rs @@ -65,6 +65,7 @@ pub struct L1BatchHeader { /// Version of protocol used for the L1 batch. pub protocol_version: Option, pub pubdata_input: Option>, + pub fee_address: Address, } /// Holder for the L2 block metadata that is not available from transactions themselves. @@ -132,6 +133,7 @@ impl L1BatchHeader { system_logs: vec![], protocol_version: Some(protocol_version), pubdata_input: Some(vec![]), + fee_address: Default::default(), } } diff --git a/core/node/block_reverter/src/tests.rs b/core/node/block_reverter/src/tests.rs index b29d01af39a4..85d894b7fd57 100644 --- a/core/node/block_reverter/src/tests.rs +++ b/core/node/block_reverter/src/tests.rs @@ -87,6 +87,7 @@ async fn setup_storage(storage: &mut Connection<'_, Core>, storage_logs: &[Stora system_logs: vec![], protocol_version: Some(ProtocolVersionId::latest()), pubdata_input: None, + fee_address: Default::default(), }; storage .blocks_dal() diff --git a/core/node/genesis/src/lib.rs b/core/node/genesis/src/lib.rs index 3cacd5a922ae..bc6cd1ee5a20 100644 --- a/core/node/genesis/src/lib.rs +++ b/core/node/genesis/src/lib.rs @@ -416,6 +416,8 @@ pub async fn create_genesis_l1_batch( .insert_l1_batch( genesis_l1_batch_header.number, genesis_l1_batch_header.timestamp, + genesis_l1_batch_header.protocol_version, + genesis_l1_batch_header.fee_address, batch_fee_input, ) .await?; diff --git a/core/node/node_sync/src/external_io.rs b/core/node/node_sync/src/external_io.rs index 5f6d75be8a0b..53bde9449420 100644 --- a/core/node/node_sync/src/external_io.rs +++ b/core/node/node_sync/src/external_io.rs @@ -244,6 +244,8 @@ impl StateKeeperIO for ExternalIO { .insert_l1_batch( cursor.l1_batch, params.first_l2_block.timestamp, + None, + params.operator_address, params.fee_input, ) .await?; diff --git a/core/node/state_keeper/src/io/mempool.rs b/core/node/state_keeper/src/io/mempool.rs index 6f61563e88dd..605271bede09 100644 --- a/core/node/state_keeper/src/io/mempool.rs +++ b/core/node/state_keeper/src/io/mempool.rs @@ -195,7 +195,13 @@ impl StateKeeperIO for MempoolIO { .connection() .await? .blocks_dal() - .insert_l1_batch(cursor.l1_batch, timestamp, self.filter.fee_input) + .insert_l1_batch( + cursor.l1_batch, + timestamp, + Some(protocol_version), + self.fee_account, + self.filter.fee_input, + ) .await?; return Ok(Some(L1BatchParams { diff --git a/core/node/state_keeper/src/io/persistence.rs b/core/node/state_keeper/src/io/persistence.rs index c1dd7593510c..d43828f386db 100644 --- a/core/node/state_keeper/src/io/persistence.rs +++ b/core/node/state_keeper/src/io/persistence.rs @@ -459,6 +459,8 @@ mod tests { .insert_l1_batch( l1_batch_env.number, l1_batch_env.timestamp, + None, + l1_batch_env.fee_account, l1_batch_env.fee_input, ) .await diff --git a/core/node/state_keeper/src/io/seal_logic/mod.rs b/core/node/state_keeper/src/io/seal_logic/mod.rs index e8b45af033c3..5859d27786d9 100644 --- a/core/node/state_keeper/src/io/seal_logic/mod.rs +++ b/core/node/state_keeper/src/io/seal_logic/mod.rs @@ -132,6 +132,7 @@ impl UpdatesManager { protocol_version: Some(self.protocol_version()), system_logs: finished_batch.final_execution_state.system_logs.clone(), pubdata_input: finished_batch.pubdata_input.clone(), + fee_address: self.fee_account_address, }; let final_bootloader_memory = finished_batch diff --git a/core/node/state_keeper/src/updates/mod.rs b/core/node/state_keeper/src/updates/mod.rs index 2fad56a99299..7264f52d12aa 100644 --- a/core/node/state_keeper/src/updates/mod.rs +++ b/core/node/state_keeper/src/updates/mod.rs @@ -30,7 +30,7 @@ pub mod l2_block_updates; #[derive(Debug)] pub struct UpdatesManager { batch_timestamp: u64, - fee_account_address: Address, + pub fee_account_address: Address, batch_fee_input: BatchFeeInput, base_fee_per_gas: u64, base_system_contract_hashes: BaseSystemContractsHashes, From aa71262f66ed06e13f7e454be48c9b7c6300d35a Mon Sep 17 00:00:00 2001 From: Daniyar Itegulov Date: Thu, 3 Oct 2024 16:06:19 +1000 Subject: [PATCH 10/14] recover unsealed batch on restart --- ...4ba52c9a0e64d1badc39cc2fef29b1468621a.json | 56 +++++++++++++++++++ ...0910112120_unsealed_batches_in_db.down.sql | 3 +- core/lib/dal/src/blocks_dal.rs | 27 +++++++++ core/lib/dal/src/models/storage_block.rs | 33 +++++++++++ core/lib/types/src/block.rs | 9 +++ core/node/state_keeper/src/io/mempool.rs | 24 ++++++++ 6 files changed, 151 insertions(+), 1 deletion(-) create mode 100644 core/lib/dal/.sqlx/query-8435ed4ee2a9b962116ecfa522f4ba52c9a0e64d1badc39cc2fef29b1468621a.json diff --git a/core/lib/dal/.sqlx/query-8435ed4ee2a9b962116ecfa522f4ba52c9a0e64d1badc39cc2fef29b1468621a.json b/core/lib/dal/.sqlx/query-8435ed4ee2a9b962116ecfa522f4ba52c9a0e64d1badc39cc2fef29b1468621a.json new file mode 100644 index 000000000000..df856b977026 --- /dev/null +++ b/core/lib/dal/.sqlx/query-8435ed4ee2a9b962116ecfa522f4ba52c9a0e64d1badc39cc2fef29b1468621a.json @@ -0,0 +1,56 @@ +{ + "db_name": "PostgreSQL", + "query": "\n SELECT\n number,\n timestamp,\n protocol_version,\n fee_address,\n l1_gas_price,\n l2_fair_gas_price,\n fair_pubdata_price\n FROM\n l1_batches\n WHERE\n NOT is_sealed\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "number", + "type_info": "Int8" + }, + { + "ordinal": 1, + "name": "timestamp", + "type_info": "Int8" + }, + { + "ordinal": 2, + "name": "protocol_version", + "type_info": "Int4" + }, + { + "ordinal": 3, + "name": "fee_address", + "type_info": "Bytea" + }, + { + "ordinal": 4, + "name": "l1_gas_price", + "type_info": "Int8" + }, + { + "ordinal": 5, + "name": "l2_fair_gas_price", + "type_info": "Int8" + }, + { + "ordinal": 6, + "name": "fair_pubdata_price", + "type_info": "Int8" + } + ], + "parameters": { + "Left": [] + }, + "nullable": [ + false, + false, + true, + false, + false, + false, + false + ] + }, + "hash": "8435ed4ee2a9b962116ecfa522f4ba52c9a0e64d1badc39cc2fef29b1468621a" +} diff --git a/core/lib/dal/migrations/20240910112120_unsealed_batches_in_db.down.sql b/core/lib/dal/migrations/20240910112120_unsealed_batches_in_db.down.sql index e6347963e102..3706fc6630bd 100644 --- a/core/lib/dal/migrations/20240910112120_unsealed_batches_in_db.down.sql +++ b/core/lib/dal/migrations/20240910112120_unsealed_batches_in_db.down.sql @@ -1,4 +1,5 @@ ALTER TABLE l1_batches RENAME COLUMN is_sealed TO is_finished; ALTER table l1_batches - DROP COLUMN fair_pubdata_price; + DROP COLUMN fair_pubdata_price, + DROP COLUMN fee_address; diff --git a/core/lib/dal/src/blocks_dal.rs b/core/lib/dal/src/blocks_dal.rs index 2dcc3c8bbedc..c6d077ab314e 100644 --- a/core/lib/dal/src/blocks_dal.rs +++ b/core/lib/dal/src/blocks_dal.rs @@ -13,6 +13,7 @@ use zksync_db_connection::{ instrument::{InstrumentExt, Instrumented}, interpolate_query, match_query_as, }; +use zksync_types::block::UnsealedL1BatchHeader; use zksync_types::{ aggregated_operations::AggregatedActionType, block::{ @@ -27,6 +28,7 @@ use zksync_types::{ }; use zksync_vm_interface::CircuitStatistic; +use crate::models::storage_block::UnsealedStorageL1Batch; pub use crate::models::storage_block::{L1BatchMetadataError, L1BatchWithOptionalMetadata}; use crate::{ models::{ @@ -733,6 +735,31 @@ impl BlocksDal<'_, '_> { Ok(()) } + pub async fn get_unsealed_l1_batch(&mut self) -> DalResult> { + let batch = sqlx::query_as!( + UnsealedStorageL1Batch, + r#" + SELECT + number, + timestamp, + protocol_version, + fee_address, + l1_gas_price, + l2_fair_gas_price, + fair_pubdata_price + FROM + l1_batches + WHERE + NOT is_sealed + "#, + ) + .instrument("get_last_committed_to_eth_l1_batch") + .fetch_optional(self.storage) + .await?; + + Ok(batch.map(|b| b.into())) + } + pub async fn insert_l2_block(&mut self, l2_block_header: &L2BlockHeader) -> DalResult<()> { let instrumentation = Instrumented::new("insert_l2_block").with_arg("number", &l2_block_header.number); diff --git a/core/lib/dal/src/models/storage_block.rs b/core/lib/dal/src/models/storage_block.rs index 2b85692e9880..c00070fc8b16 100644 --- a/core/lib/dal/src/models/storage_block.rs +++ b/core/lib/dal/src/models/storage_block.rs @@ -4,6 +4,7 @@ use bigdecimal::{BigDecimal, ToPrimitive}; use sqlx::types::chrono::{DateTime, NaiveDateTime, Utc}; use thiserror::Error; use zksync_contracts::BaseSystemContractsHashes; +use zksync_types::block::UnsealedL1BatchHeader; use zksync_types::{ api, block::{L1BatchHeader, L2BlockHeader}, @@ -257,6 +258,38 @@ impl TryFrom for L1BatchMetadata { } } +/// Partial projection of the columns corresponding to an unsealed [`L1BatchHeader`]. +#[derive(Debug, Clone)] +pub(crate) struct UnsealedStorageL1Batch { + pub number: i64, + pub timestamp: i64, + pub protocol_version: Option, + pub fee_address: Vec, + pub l1_gas_price: i64, + pub l2_fair_gas_price: i64, + pub fair_pubdata_price: Option, +} + +impl From for UnsealedL1BatchHeader { + fn from(batch: UnsealedStorageL1Batch) -> Self { + let protocol_version: Option = batch + .protocol_version + .map(|v| (v as u16).try_into().unwrap()); + Self { + number: L1BatchNumber(batch.number as u32), + timestamp: batch.timestamp as u64, + protocol_version, + fee_address: Address::from_slice(&batch.fee_address), + fee_input: BatchFeeInput::for_protocol_version( + protocol_version.unwrap_or_else(ProtocolVersionId::last_potentially_undefined), + batch.l2_fair_gas_price as u64, + batch.fair_pubdata_price.map(|p| p as u64), + batch.l1_gas_price as u64, + ), + } + } +} + #[derive(Debug, Clone, sqlx::FromRow)] pub(crate) struct StorageBlockDetails { pub number: i64, diff --git a/core/lib/types/src/block.rs b/core/lib/types/src/block.rs index 8c0a123f6e4f..361e9ea56d28 100644 --- a/core/lib/types/src/block.rs +++ b/core/lib/types/src/block.rs @@ -68,6 +68,15 @@ pub struct L1BatchHeader { pub fee_address: Address, } +#[derive(Debug, Clone, PartialEq)] +pub struct UnsealedL1BatchHeader { + pub number: L1BatchNumber, + pub timestamp: u64, + pub protocol_version: Option, + pub fee_address: Address, + pub fee_input: BatchFeeInput, +} + /// Holder for the L2 block metadata that is not available from transactions themselves. #[derive(Debug, Clone, PartialEq)] pub struct L2BlockHeader { diff --git a/core/node/state_keeper/src/io/mempool.rs b/core/node/state_keeper/src/io/mempool.rs index 605271bede09..f771a2dda4ce 100644 --- a/core/node/state_keeper/src/io/mempool.rs +++ b/core/node/state_keeper/src/io/mempool.rs @@ -148,6 +148,30 @@ impl StateKeeperIO for MempoolIO { cursor: &IoCursor, max_wait: Duration, ) -> anyhow::Result> { + // Check if there is an existing unsealed batch + if let Some(unsealed_storage_batch) = self + .pool + .connection_tagged("state_keeper") + .await? + .blocks_dal() + .get_unsealed_l1_batch() + .await? + { + return Ok(Some(L1BatchParams { + protocol_version: unsealed_storage_batch + .protocol_version + .expect("unsealed batch is missing protocol version"), + validation_computational_gas_limit: self.validation_computational_gas_limit, + operator_address: unsealed_storage_batch.fee_address, + fee_input: unsealed_storage_batch.fee_input, + first_l2_block: L2BlockParams { + timestamp: unsealed_storage_batch.timestamp, + // This value is effectively ignored by the protocol. + virtual_blocks: 1, + }, + })); + } + let deadline = Instant::now() + max_wait; // Block until at least one transaction in the mempool can match the filter (or timeout happens). From faa8b6b7d24475a8ab9c3c0bb572cf49c0d12acd Mon Sep 17 00:00:00 2001 From: Daniyar Itegulov Date: Thu, 3 Oct 2024 16:07:34 +1000 Subject: [PATCH 11/14] fmt --- ...3010bea7cee09a9538a4e275ea89f67704966.json | 23 ++++++ ...f7cae7565e28f72f5ab3d0eb653fa0fbdff0a.json | 23 ++++++ ...1d3747c1ae3859292ff8caced9730b42acdf7.json | 20 ----- ...a029d6851124a5fb6bc25660089bc49cf57b6.json | 23 ------ ...0a5b8081edf28fa1b67f71101d2e3621be798.json | 20 +++++ ...de30ccb6ab4e3b80f606026f7ec6243c9e443.json | 23 ------ core/lib/dal/src/blocks_dal.rs | 80 +++++++++---------- core/lib/dal/src/models/storage_block.rs | 3 +- core/lib/dal/src/vm_runner_dal.rs | 68 ++++++++-------- 9 files changed, 143 insertions(+), 140 deletions(-) create mode 100644 core/lib/dal/.sqlx/query-55c0349569786bac0204272961f3010bea7cee09a9538a4e275ea89f67704966.json create mode 100644 core/lib/dal/.sqlx/query-5ddf39d930c11e13311c8a88b72f7cae7565e28f72f5ab3d0eb653fa0fbdff0a.json delete mode 100644 core/lib/dal/.sqlx/query-820d1e33271bfd6aff55c8e31141d3747c1ae3859292ff8caced9730b42acdf7.json delete mode 100644 core/lib/dal/.sqlx/query-92b303156b0e1bbfbd62763e322a029d6851124a5fb6bc25660089bc49cf57b6.json create mode 100644 core/lib/dal/.sqlx/query-b282359f07eb8372e973a51a27e0a5b8081edf28fa1b67f71101d2e3621be798.json delete mode 100644 core/lib/dal/.sqlx/query-c2ef38b3ba99cbc8d77e39ecf6ede30ccb6ab4e3b80f606026f7ec6243c9e443.json diff --git a/core/lib/dal/.sqlx/query-55c0349569786bac0204272961f3010bea7cee09a9538a4e275ea89f67704966.json b/core/lib/dal/.sqlx/query-55c0349569786bac0204272961f3010bea7cee09a9538a4e275ea89f67704966.json new file mode 100644 index 000000000000..2cd528a9f537 --- /dev/null +++ b/core/lib/dal/.sqlx/query-55c0349569786bac0204272961f3010bea7cee09a9538a4e275ea89f67704966.json @@ -0,0 +1,23 @@ +{ + "db_name": "PostgreSQL", + "query": "\n WITH\n available_batches AS (\n SELECT\n MAX(number) AS \"last_batch\"\n FROM\n l1_batches\n WHERE\n is_sealed\n ),\n \n processed_batches AS (\n SELECT\n COALESCE(MAX(l1_batch_number), $1) + $2 AS \"last_ready_batch\"\n FROM\n vm_runner_bwip\n WHERE\n time_taken IS NOT NULL\n )\n \n SELECT\n LEAST(last_batch, last_ready_batch) AS \"last_ready_batch!\"\n FROM\n available_batches\n FULL JOIN processed_batches ON TRUE\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "last_ready_batch!", + "type_info": "Int8" + } + ], + "parameters": { + "Left": [ + "Int8", + "Int8" + ] + }, + "nullable": [ + true + ] + }, + "hash": "55c0349569786bac0204272961f3010bea7cee09a9538a4e275ea89f67704966" +} diff --git a/core/lib/dal/.sqlx/query-5ddf39d930c11e13311c8a88b72f7cae7565e28f72f5ab3d0eb653fa0fbdff0a.json b/core/lib/dal/.sqlx/query-5ddf39d930c11e13311c8a88b72f7cae7565e28f72f5ab3d0eb653fa0fbdff0a.json new file mode 100644 index 000000000000..c95a5bc6bd4a --- /dev/null +++ b/core/lib/dal/.sqlx/query-5ddf39d930c11e13311c8a88b72f7cae7565e28f72f5ab3d0eb653fa0fbdff0a.json @@ -0,0 +1,23 @@ +{ + "db_name": "PostgreSQL", + "query": "\n WITH\n available_batches AS (\n SELECT\n MAX(number) AS \"last_batch\"\n FROM\n l1_batches\n WHERE\n is_sealed\n ),\n \n processed_batches AS (\n SELECT\n COALESCE(MAX(l1_batch_number), $1) + $2 AS \"last_ready_batch\"\n FROM\n vm_runner_protective_reads\n WHERE\n time_taken IS NOT NULL\n )\n \n SELECT\n LEAST(last_batch, last_ready_batch) AS \"last_ready_batch!\"\n FROM\n available_batches\n FULL JOIN processed_batches ON TRUE\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "last_ready_batch!", + "type_info": "Int8" + } + ], + "parameters": { + "Left": [ + "Int8", + "Int8" + ] + }, + "nullable": [ + true + ] + }, + "hash": "5ddf39d930c11e13311c8a88b72f7cae7565e28f72f5ab3d0eb653fa0fbdff0a" +} diff --git a/core/lib/dal/.sqlx/query-820d1e33271bfd6aff55c8e31141d3747c1ae3859292ff8caced9730b42acdf7.json b/core/lib/dal/.sqlx/query-820d1e33271bfd6aff55c8e31141d3747c1ae3859292ff8caced9730b42acdf7.json deleted file mode 100644 index 18d24009ba7d..000000000000 --- a/core/lib/dal/.sqlx/query-820d1e33271bfd6aff55c8e31141d3747c1ae3859292ff8caced9730b42acdf7.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "\n INSERT INTO\n l1_batches (\n number,\n timestamp,\n protocol_version,\n fee_address,\n l1_gas_price,\n l2_fair_gas_price,\n fair_pubdata_price,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n initial_bootloader_heap_content,\n used_contract_hashes,\n created_at,\n updated_at,\n is_sealed\n )\n VALUES\n (\n $1,\n $2,\n $3,\n $4,\n $5,\n $6,\n $7,\n 0,\n 0,\n ''::bytea,\n '{}'::bytea[],\n '{}'::jsonb,\n '{}'::jsonb,\n NOW(),\n NOW(),\n FALSE\n )\n ", - "describe": { - "columns": [], - "parameters": { - "Left": [ - "Int8", - "Int8", - "Int4", - "Bytea", - "Int8", - "Int8", - "Int8" - ] - }, - "nullable": [] - }, - "hash": "820d1e33271bfd6aff55c8e31141d3747c1ae3859292ff8caced9730b42acdf7" -} diff --git a/core/lib/dal/.sqlx/query-92b303156b0e1bbfbd62763e322a029d6851124a5fb6bc25660089bc49cf57b6.json b/core/lib/dal/.sqlx/query-92b303156b0e1bbfbd62763e322a029d6851124a5fb6bc25660089bc49cf57b6.json deleted file mode 100644 index ab5048e306c3..000000000000 --- a/core/lib/dal/.sqlx/query-92b303156b0e1bbfbd62763e322a029d6851124a5fb6bc25660089bc49cf57b6.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "\n WITH\n available_batches AS (\n SELECT\n MAX(number) AS \"last_batch\"\n FROM\n l1_batches\n WHERE\n is_sealed\n ),\n processed_batches AS (\n SELECT\n COALESCE(MAX(l1_batch_number), $1) + $2 AS \"last_ready_batch\"\n FROM\n vm_runner_protective_reads\n WHERE\n time_taken IS NOT NULL\n )\n SELECT\n LEAST(last_batch, last_ready_batch) AS \"last_ready_batch!\"\n FROM\n available_batches\n FULL JOIN processed_batches ON TRUE\n ", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "last_ready_batch!", - "type_info": "Int8" - } - ], - "parameters": { - "Left": [ - "Int8", - "Int8" - ] - }, - "nullable": [ - true - ] - }, - "hash": "92b303156b0e1bbfbd62763e322a029d6851124a5fb6bc25660089bc49cf57b6" -} diff --git a/core/lib/dal/.sqlx/query-b282359f07eb8372e973a51a27e0a5b8081edf28fa1b67f71101d2e3621be798.json b/core/lib/dal/.sqlx/query-b282359f07eb8372e973a51a27e0a5b8081edf28fa1b67f71101d2e3621be798.json new file mode 100644 index 000000000000..78b913fcc36a --- /dev/null +++ b/core/lib/dal/.sqlx/query-b282359f07eb8372e973a51a27e0a5b8081edf28fa1b67f71101d2e3621be798.json @@ -0,0 +1,20 @@ +{ + "db_name": "PostgreSQL", + "query": "\n INSERT INTO\n l1_batches (\n number,\n timestamp,\n protocol_version,\n fee_address,\n l1_gas_price,\n l2_fair_gas_price,\n fair_pubdata_price,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n initial_bootloader_heap_content,\n used_contract_hashes,\n created_at,\n updated_at,\n is_sealed\n )\n VALUES\n (\n $1,\n $2,\n $3,\n $4,\n $5,\n $6,\n $7,\n 0,\n 0,\n ''::bytea,\n '{}'::bytea [],\n '{}'::jsonb,\n '{}'::jsonb,\n NOW(),\n NOW(),\n FALSE\n )\n ", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Int8", + "Int8", + "Int4", + "Bytea", + "Int8", + "Int8", + "Int8" + ] + }, + "nullable": [] + }, + "hash": "b282359f07eb8372e973a51a27e0a5b8081edf28fa1b67f71101d2e3621be798" +} diff --git a/core/lib/dal/.sqlx/query-c2ef38b3ba99cbc8d77e39ecf6ede30ccb6ab4e3b80f606026f7ec6243c9e443.json b/core/lib/dal/.sqlx/query-c2ef38b3ba99cbc8d77e39ecf6ede30ccb6ab4e3b80f606026f7ec6243c9e443.json deleted file mode 100644 index 455f5a285cc8..000000000000 --- a/core/lib/dal/.sqlx/query-c2ef38b3ba99cbc8d77e39ecf6ede30ccb6ab4e3b80f606026f7ec6243c9e443.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "\n WITH\n available_batches AS (\n SELECT\n MAX(number) AS \"last_batch\"\n FROM\n l1_batches\n WHERE\n is_sealed\n ),\n processed_batches AS (\n SELECT\n COALESCE(MAX(l1_batch_number), $1) + $2 AS \"last_ready_batch\"\n FROM\n vm_runner_bwip\n WHERE\n time_taken IS NOT NULL\n )\n SELECT\n LEAST(last_batch, last_ready_batch) AS \"last_ready_batch!\"\n FROM\n available_batches\n FULL JOIN processed_batches ON TRUE\n ", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "last_ready_batch!", - "type_info": "Int8" - } - ], - "parameters": { - "Left": [ - "Int8", - "Int8" - ] - }, - "nullable": [ - true - ] - }, - "hash": "c2ef38b3ba99cbc8d77e39ecf6ede30ccb6ab4e3b80f606026f7ec6243c9e443" -} diff --git a/core/lib/dal/src/blocks_dal.rs b/core/lib/dal/src/blocks_dal.rs index c6d077ab314e..11ebca0a8a6d 100644 --- a/core/lib/dal/src/blocks_dal.rs +++ b/core/lib/dal/src/blocks_dal.rs @@ -13,12 +13,11 @@ use zksync_db_connection::{ instrument::{InstrumentExt, Instrumented}, interpolate_query, match_query_as, }; -use zksync_types::block::UnsealedL1BatchHeader; use zksync_types::{ aggregated_operations::AggregatedActionType, block::{ BlockGasCount, L1BatchHeader, L1BatchStatistics, L1BatchTreeData, L2BlockHeader, - StorageOracleInfo, + StorageOracleInfo, UnsealedL1BatchHeader, }, commitment::{L1BatchCommitmentArtifacts, L1BatchWithMetadata}, fee_model::BatchFeeInput, @@ -28,12 +27,13 @@ use zksync_types::{ }; use zksync_vm_interface::CircuitStatistic; -use crate::models::storage_block::UnsealedStorageL1Batch; pub use crate::models::storage_block::{L1BatchMetadataError, L1BatchWithOptionalMetadata}; use crate::{ models::{ parse_protocol_version, - storage_block::{StorageL1Batch, StorageL1BatchHeader, StorageL2BlockHeader}, + storage_block::{ + StorageL1Batch, StorageL1BatchHeader, StorageL2BlockHeader, UnsealedStorageL1Batch, + }, storage_event::StorageL2ToL1Log, storage_oracle_info::DbStorageOracleInfo, }, @@ -585,43 +585,43 @@ impl BlocksDal<'_, '_> { sqlx::query!( r#" INSERT INTO - l1_batches ( - number, - timestamp, - protocol_version, - fee_address, - l1_gas_price, - l2_fair_gas_price, - fair_pubdata_price, - l1_tx_count, - l2_tx_count, - bloom, - priority_ops_onchain_data, - initial_bootloader_heap_content, - used_contract_hashes, - created_at, - updated_at, - is_sealed - ) + l1_batches ( + number, + timestamp, + protocol_version, + fee_address, + l1_gas_price, + l2_fair_gas_price, + fair_pubdata_price, + l1_tx_count, + l2_tx_count, + bloom, + priority_ops_onchain_data, + initial_bootloader_heap_content, + used_contract_hashes, + created_at, + updated_at, + is_sealed + ) VALUES - ( - $1, - $2, - $3, - $4, - $5, - $6, - $7, - 0, - 0, - ''::bytea, - '{}'::bytea[], - '{}'::jsonb, - '{}'::jsonb, - NOW(), - NOW(), - FALSE - ) + ( + $1, + $2, + $3, + $4, + $5, + $6, + $7, + 0, + 0, + ''::bytea, + '{}'::bytea [], + '{}'::jsonb, + '{}'::jsonb, + NOW(), + NOW(), + FALSE + ) "#, i64::from(number.0), timestamp as i64, diff --git a/core/lib/dal/src/models/storage_block.rs b/core/lib/dal/src/models/storage_block.rs index c00070fc8b16..815b8f37bcf3 100644 --- a/core/lib/dal/src/models/storage_block.rs +++ b/core/lib/dal/src/models/storage_block.rs @@ -4,10 +4,9 @@ use bigdecimal::{BigDecimal, ToPrimitive}; use sqlx::types::chrono::{DateTime, NaiveDateTime, Utc}; use thiserror::Error; use zksync_contracts::BaseSystemContractsHashes; -use zksync_types::block::UnsealedL1BatchHeader; use zksync_types::{ api, - block::{L1BatchHeader, L2BlockHeader}, + block::{L1BatchHeader, L2BlockHeader, UnsealedL1BatchHeader}, commitment::{L1BatchMetaParameters, L1BatchMetadata}, fee_model::{BatchFeeInput, L1PeggedBatchFeeModelInput, PubdataIndependentBatchFeeModelInput}, l2_to_l1_log::{L2ToL1Log, SystemL2ToL1Log, UserL2ToL1Log}, diff --git a/core/lib/dal/src/vm_runner_dal.rs b/core/lib/dal/src/vm_runner_dal.rs index 9ab359cc34aa..df0d3e86b889 100644 --- a/core/lib/dal/src/vm_runner_dal.rs +++ b/core/lib/dal/src/vm_runner_dal.rs @@ -37,22 +37,24 @@ impl VmRunnerDal<'_, '_> { let row = sqlx::query!( r#" WITH - available_batches AS ( - SELECT - MAX(number) AS "last_batch" - FROM - l1_batches - WHERE - is_sealed - ), - processed_batches AS ( - SELECT - COALESCE(MAX(l1_batch_number), $1) + $2 AS "last_ready_batch" - FROM - vm_runner_protective_reads - WHERE - time_taken IS NOT NULL - ) + available_batches AS ( + SELECT + MAX(number) AS "last_batch" + FROM + l1_batches + WHERE + is_sealed + ), + + processed_batches AS ( + SELECT + COALESCE(MAX(l1_batch_number), $1) + $2 AS "last_ready_batch" + FROM + vm_runner_protective_reads + WHERE + time_taken IS NOT NULL + ) + SELECT LEAST(last_batch, last_ready_batch) AS "last_ready_batch!" FROM @@ -200,22 +202,24 @@ impl VmRunnerDal<'_, '_> { let row = sqlx::query!( r#" WITH - available_batches AS ( - SELECT - MAX(number) AS "last_batch" - FROM - l1_batches - WHERE - is_sealed - ), - processed_batches AS ( - SELECT - COALESCE(MAX(l1_batch_number), $1) + $2 AS "last_ready_batch" - FROM - vm_runner_bwip - WHERE - time_taken IS NOT NULL - ) + available_batches AS ( + SELECT + MAX(number) AS "last_batch" + FROM + l1_batches + WHERE + is_sealed + ), + + processed_batches AS ( + SELECT + COALESCE(MAX(l1_batch_number), $1) + $2 AS "last_ready_batch" + FROM + vm_runner_bwip + WHERE + time_taken IS NOT NULL + ) + SELECT LEAST(last_batch, last_ready_batch) AS "last_ready_batch!" FROM From 0e38efb77eec5f4cd206ebc61e2c8cf92eeaa61c Mon Sep 17 00:00:00 2001 From: Daniyar Itegulov Date: Wed, 9 Oct 2024 16:50:53 +1100 Subject: [PATCH 12/14] update dal files --- ...0fa76a03907957b7a0d87ea55a7873f3312e.json} | 14 +- ...00a91254ec6c8a68a359d22b02df5a40911f.json} | 12 +- ...5598f5d22a3aebd893afddded0e3c6b94a3b.json} | 14 +- ...fbde6eb6634d7a63005081ffc1eb6c28e9ec.json} | 14 +- ...bf3ffb03b3791c0e9a9f39fb85cfffc65db2.json} | 14 +- ...97f64d0c9620506bb41890548181bccca9ee5.json | 144 ------------------ ...0294e53eb37c1a2dbcc3044b8311200d549a.json} | 5 +- ...0371bdc118b25d64fcf526bd6575e4d675c8.json} | 14 +- ...56e43137ac0cf45312d70dec0c407cadc1bf.json} | 14 +- ...6b563ff2f0f3a818e8c8a02c2ef632d0b960.json} | 14 +- ...3926df634ebf0d8286181fa04884fb747cee8.json | 136 +++++++++++++++++ ...2baec4b2531ecaa8da234863e2eb810761c7.json} | 14 +- ...8c8132d0958e4e25f4954e93d2095b4f11e8.json} | 14 +- ...914f15fd7a5fa3d7f7bc56906817c70b04950.json | 34 ----- 14 files changed, 168 insertions(+), 289 deletions(-) rename core/lib/dal/.sqlx/{query-860de4af5c11c3a7c9eb660ec7049749bd5fc78b09578589c26d3017cc6bd192.json => query-0784f2cc13f85763cc7da29902850fa76a03907957b7a0d87ea55a7873f3312e.json} (64%) rename core/lib/dal/.sqlx/{query-51d5b6fd147fa06ddadb5f8c9c0e12784694d2f8fe9a67159ad4c7abc2279ca6.json => query-2049362aad5e32981e48e5c5ef7a00a91254ec6c8a68a359d22b02df5a40911f.json} (54%) rename core/lib/dal/.sqlx/{query-16d4658899c5b604fb794d44a8b3bef013ad12b66bdca7251be2af21e98fe870.json => query-2def67eb8372245ed59e76e07d615598f5d22a3aebd893afddded0e3c6b94a3b.json} (58%) rename core/lib/dal/.sqlx/{query-7cceb18485c0fdeed57b7f279debfe9b944b2dd80eb56965a5874ce3168e8c5e.json => query-4e994d519b9c75e64a74423f8c19fbde6eb6634d7a63005081ffc1eb6c28e9ec.json} (61%) rename core/lib/dal/.sqlx/{query-da1ea91f3a1189f881020a6cec17fc5d8943e65a30508898d90a098432050bc7.json => query-5aa487a98dff53a5d32a5916a26cbf3ffb03b3791c0e9a9f39fb85cfffc65db2.json} (62%) delete mode 100644 core/lib/dal/.sqlx/query-7240ff1240a2cdae14ab1bbfaad97f64d0c9620506bb41890548181bccca9ee5.json rename core/lib/dal/.sqlx/{query-66aa91ae9f9c54346d9966ea5e0bc61568110e9bbe688c55862f93fa62a71405.json => query-746d8b62d576b4b9596458aa865e0294e53eb37c1a2dbcc3044b8311200d549a.json} (66%) rename core/lib/dal/.sqlx/{query-9ece18b3a36cbaeaa99ca3db466b9fabba23fa52a17a54146931476681edbd24.json => query-7aebc0d8eb43bd835c4f175edc4c0371bdc118b25d64fcf526bd6575e4d675c8.json} (64%) rename core/lib/dal/.sqlx/{query-9f2e976278266ae5845c5188c95876eb8a6a508aea04d93342df50dd9745c361.json => query-942d6d948770c374ba4d3566c50e56e43137ac0cf45312d70dec0c407cadc1bf.json} (53%) rename core/lib/dal/.sqlx/{query-4f5f59bc6fd27bb73c6020b6f0be7ca0e4b83f50724a0b18256aafab69909a98.json => query-b456147560b107640abdc10f7ac76b563ff2f0f3a818e8c8a02c2ef632d0b960.json} (67%) create mode 100644 core/lib/dal/.sqlx/query-d3760406b7bf5d14a3fe6cbc9fb3926df634ebf0d8286181fa04884fb747cee8.json rename core/lib/dal/.sqlx/{query-b037613a81f7b3cb106cf62205feb2d1aa6b398c6981c8d4f35e499f42b01731.json => query-e2d0bd978f76e0ce09b36b0e4b0a2baec4b2531ecaa8da234863e2eb810761c7.json} (65%) rename core/lib/dal/.sqlx/{query-05726523bb494b40011c28acd3f52dba1d37493d4c1db4b957cfec476a791b32.json => query-f30748bef5f8d08b60739cdfd9508c8132d0958e4e25f4954e93d2095b4f11e8.json} (57%) delete mode 100644 core/lib/dal/.sqlx/query-f81c5b92cac0466af8a2721b44d914f15fd7a5fa3d7f7bc56906817c70b04950.json diff --git a/core/lib/dal/.sqlx/query-860de4af5c11c3a7c9eb660ec7049749bd5fc78b09578589c26d3017cc6bd192.json b/core/lib/dal/.sqlx/query-0784f2cc13f85763cc7da29902850fa76a03907957b7a0d87ea55a7873f3312e.json similarity index 64% rename from core/lib/dal/.sqlx/query-860de4af5c11c3a7c9eb660ec7049749bd5fc78b09578589c26d3017cc6bd192.json rename to core/lib/dal/.sqlx/query-0784f2cc13f85763cc7da29902850fa76a03907957b7a0d87ea55a7873f3312e.json index f019e84b9f4f..84f677a36c86 100644 --- a/core/lib/dal/.sqlx/query-860de4af5c11c3a7c9eb660ec7049749bd5fc78b09578589c26d3017cc6bd192.json +++ b/core/lib/dal/.sqlx/query-0784f2cc13f85763cc7da29902850fa76a03907957b7a0d87ea55a7873f3312e.json @@ -1,10 +1,6 @@ { "db_name": "PostgreSQL", -<<<<<<<< HEAD:core/lib/dal/.sqlx/query-6d2a29adc9cceb8ef0d614dd3b9d512670180908eab56f49e70d42e1a933bd97.json - "query": "\n SELECT\n number,\n timestamp,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n hash,\n commitment,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_merkle_root,\n rollup_last_leaf_index,\n zkporter_is_available,\n bootloader_code_hash,\n default_aa_code_hash,\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 pubdata_input,\n fee_address\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 ", -======== - "query": "\n SELECT\n number,\n timestamp,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n hash,\n commitment,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_merkle_root,\n rollup_last_leaf_index,\n zkporter_is_available,\n bootloader_code_hash,\n default_aa_code_hash,\n evm_emulator_code_hash,\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 pubdata_input\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 ", ->>>>>>>> origin/main:core/lib/dal/.sqlx/query-860de4af5c11c3a7c9eb660ec7049749bd5fc78b09578589c26d3017cc6bd192.json + "query": "\n SELECT\n number,\n timestamp,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n hash,\n commitment,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_merkle_root,\n rollup_last_leaf_index,\n zkporter_is_available,\n bootloader_code_hash,\n default_aa_code_hash,\n evm_emulator_code_hash,\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 pubdata_input,\n fee_address\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 ", "describe": { "columns": [ { @@ -143,7 +139,7 @@ "type_info": "Bytea" }, { - "ordinal": 26, + "ordinal": 27, "name": "fee_address", "type_info": "Bytea" } @@ -184,9 +180,5 @@ false ] }, -<<<<<<<< HEAD:core/lib/dal/.sqlx/query-6d2a29adc9cceb8ef0d614dd3b9d512670180908eab56f49e70d42e1a933bd97.json - "hash": "6d2a29adc9cceb8ef0d614dd3b9d512670180908eab56f49e70d42e1a933bd97" -======== - "hash": "860de4af5c11c3a7c9eb660ec7049749bd5fc78b09578589c26d3017cc6bd192" ->>>>>>>> origin/main:core/lib/dal/.sqlx/query-860de4af5c11c3a7c9eb660ec7049749bd5fc78b09578589c26d3017cc6bd192.json + "hash": "0784f2cc13f85763cc7da29902850fa76a03907957b7a0d87ea55a7873f3312e" } diff --git a/core/lib/dal/.sqlx/query-51d5b6fd147fa06ddadb5f8c9c0e12784694d2f8fe9a67159ad4c7abc2279ca6.json b/core/lib/dal/.sqlx/query-2049362aad5e32981e48e5c5ef7a00a91254ec6c8a68a359d22b02df5a40911f.json similarity index 54% rename from core/lib/dal/.sqlx/query-51d5b6fd147fa06ddadb5f8c9c0e12784694d2f8fe9a67159ad4c7abc2279ca6.json rename to core/lib/dal/.sqlx/query-2049362aad5e32981e48e5c5ef7a00a91254ec6c8a68a359d22b02df5a40911f.json index dd8d17bb477f..b8f8db874b63 100644 --- a/core/lib/dal/.sqlx/query-51d5b6fd147fa06ddadb5f8c9c0e12784694d2f8fe9a67159ad4c7abc2279ca6.json +++ b/core/lib/dal/.sqlx/query-2049362aad5e32981e48e5c5ef7a00a91254ec6c8a68a359d22b02df5a40911f.json @@ -1,10 +1,6 @@ { "db_name": "PostgreSQL", -<<<<<<<< HEAD:core/lib/dal/.sqlx/query-ce9dff39b1b01d6d6c700755a82fe9e81bca99d9d52147c67a817ee2fdbadea1.json - "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 WHERE\n is_sealed\n ),\n (\n SELECT\n MAX(l1_batch_number) + 1\n FROM\n snapshot_recovery\n )\n ) AS \"l1_batch_number!\",\n (miniblocks.l1_tx_count + miniblocks.l2_tx_count) AS \"tx_count!\",\n miniblocks.timestamp,\n miniblocks.l1_gas_price,\n miniblocks.l2_fair_gas_price,\n miniblocks.fair_pubdata_price,\n miniblocks.bootloader_code_hash,\n miniblocks.default_aa_code_hash,\n miniblocks.virtual_blocks,\n miniblocks.hash,\n miniblocks.protocol_version AS \"protocol_version!\",\n miniblocks.fee_account_address AS \"fee_account_address!\"\n FROM\n miniblocks\n WHERE\n miniblocks.number BETWEEN $1 AND $2\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 (\n SELECT\n MAX(l1_batch_number) + 1\n FROM\n snapshot_recovery\n )\n ) AS \"l1_batch_number!\",\n (miniblocks.l1_tx_count + miniblocks.l2_tx_count) AS \"tx_count!\",\n miniblocks.timestamp,\n miniblocks.l1_gas_price,\n miniblocks.l2_fair_gas_price,\n miniblocks.fair_pubdata_price,\n miniblocks.bootloader_code_hash,\n miniblocks.default_aa_code_hash,\n miniblocks.evm_emulator_code_hash,\n miniblocks.virtual_blocks,\n miniblocks.hash,\n miniblocks.protocol_version AS \"protocol_version!\",\n miniblocks.fee_account_address AS \"fee_account_address!\"\n FROM\n miniblocks\n WHERE\n miniblocks.number BETWEEN $1 AND $2\n ", ->>>>>>>> origin/main:core/lib/dal/.sqlx/query-51d5b6fd147fa06ddadb5f8c9c0e12784694d2f8fe9a67159ad4c7abc2279ca6.json + "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 WHERE\n is_sealed\n ),\n (\n SELECT\n MAX(l1_batch_number) + 1\n FROM\n snapshot_recovery\n )\n ) AS \"l1_batch_number!\",\n (miniblocks.l1_tx_count + miniblocks.l2_tx_count) AS \"tx_count!\",\n miniblocks.timestamp,\n miniblocks.l1_gas_price,\n miniblocks.l2_fair_gas_price,\n miniblocks.fair_pubdata_price,\n miniblocks.bootloader_code_hash,\n miniblocks.default_aa_code_hash,\n miniblocks.evm_emulator_code_hash,\n miniblocks.virtual_blocks,\n miniblocks.hash,\n miniblocks.protocol_version AS \"protocol_version!\",\n miniblocks.fee_account_address AS \"fee_account_address!\"\n FROM\n miniblocks\n WHERE\n miniblocks.number BETWEEN $1 AND $2\n ", "describe": { "columns": [ { @@ -101,9 +97,5 @@ false ] }, -<<<<<<<< HEAD:core/lib/dal/.sqlx/query-ce9dff39b1b01d6d6c700755a82fe9e81bca99d9d52147c67a817ee2fdbadea1.json - "hash": "ce9dff39b1b01d6d6c700755a82fe9e81bca99d9d52147c67a817ee2fdbadea1" -======== - "hash": "51d5b6fd147fa06ddadb5f8c9c0e12784694d2f8fe9a67159ad4c7abc2279ca6" ->>>>>>>> origin/main:core/lib/dal/.sqlx/query-51d5b6fd147fa06ddadb5f8c9c0e12784694d2f8fe9a67159ad4c7abc2279ca6.json + "hash": "2049362aad5e32981e48e5c5ef7a00a91254ec6c8a68a359d22b02df5a40911f" } diff --git a/core/lib/dal/.sqlx/query-16d4658899c5b604fb794d44a8b3bef013ad12b66bdca7251be2af21e98fe870.json b/core/lib/dal/.sqlx/query-2def67eb8372245ed59e76e07d615598f5d22a3aebd893afddded0e3c6b94a3b.json similarity index 58% rename from core/lib/dal/.sqlx/query-16d4658899c5b604fb794d44a8b3bef013ad12b66bdca7251be2af21e98fe870.json rename to core/lib/dal/.sqlx/query-2def67eb8372245ed59e76e07d615598f5d22a3aebd893afddded0e3c6b94a3b.json index 62bf662f8746..afac14e6d5cd 100644 --- a/core/lib/dal/.sqlx/query-16d4658899c5b604fb794d44a8b3bef013ad12b66bdca7251be2af21e98fe870.json +++ b/core/lib/dal/.sqlx/query-2def67eb8372245ed59e76e07d615598f5d22a3aebd893afddded0e3c6b94a3b.json @@ -1,10 +1,6 @@ { "db_name": "PostgreSQL", -<<<<<<<< HEAD:core/lib/dal/.sqlx/query-5aa205491025edc3b367a0ea1a32fecac25a826d5f7f729208fe23b9cd485c32.json - "query": "\n SELECT\n number,\n l1_batches.timestamp,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n hash,\n commitment,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_merkle_root,\n rollup_last_leaf_index,\n zkporter_is_available,\n l1_batches.bootloader_code_hash,\n l1_batches.default_aa_code_hash,\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 pubdata_input,\n fee_address\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 ", -======== - "query": "\n SELECT\n number,\n l1_batches.timestamp,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n hash,\n commitment,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_merkle_root,\n rollup_last_leaf_index,\n zkporter_is_available,\n l1_batches.bootloader_code_hash,\n l1_batches.default_aa_code_hash,\n l1_batches.evm_emulator_code_hash,\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 pubdata_input\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 ", ->>>>>>>> origin/main:core/lib/dal/.sqlx/query-16d4658899c5b604fb794d44a8b3bef013ad12b66bdca7251be2af21e98fe870.json + "query": "\n SELECT\n number,\n l1_batches.timestamp,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n hash,\n commitment,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_merkle_root,\n rollup_last_leaf_index,\n zkporter_is_available,\n l1_batches.bootloader_code_hash,\n l1_batches.default_aa_code_hash,\n l1_batches.evm_emulator_code_hash,\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 pubdata_input,\n fee_address\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 ", "describe": { "columns": [ { @@ -143,7 +139,7 @@ "type_info": "Bytea" }, { - "ordinal": 26, + "ordinal": 27, "name": "fee_address", "type_info": "Bytea" } @@ -187,9 +183,5 @@ false ] }, -<<<<<<<< HEAD:core/lib/dal/.sqlx/query-5aa205491025edc3b367a0ea1a32fecac25a826d5f7f729208fe23b9cd485c32.json - "hash": "5aa205491025edc3b367a0ea1a32fecac25a826d5f7f729208fe23b9cd485c32" -======== - "hash": "16d4658899c5b604fb794d44a8b3bef013ad12b66bdca7251be2af21e98fe870" ->>>>>>>> origin/main:core/lib/dal/.sqlx/query-16d4658899c5b604fb794d44a8b3bef013ad12b66bdca7251be2af21e98fe870.json + "hash": "2def67eb8372245ed59e76e07d615598f5d22a3aebd893afddded0e3c6b94a3b" } diff --git a/core/lib/dal/.sqlx/query-7cceb18485c0fdeed57b7f279debfe9b944b2dd80eb56965a5874ce3168e8c5e.json b/core/lib/dal/.sqlx/query-4e994d519b9c75e64a74423f8c19fbde6eb6634d7a63005081ffc1eb6c28e9ec.json similarity index 61% rename from core/lib/dal/.sqlx/query-7cceb18485c0fdeed57b7f279debfe9b944b2dd80eb56965a5874ce3168e8c5e.json rename to core/lib/dal/.sqlx/query-4e994d519b9c75e64a74423f8c19fbde6eb6634d7a63005081ffc1eb6c28e9ec.json index 4a636c4efb00..804318120fcc 100644 --- a/core/lib/dal/.sqlx/query-7cceb18485c0fdeed57b7f279debfe9b944b2dd80eb56965a5874ce3168e8c5e.json +++ b/core/lib/dal/.sqlx/query-4e994d519b9c75e64a74423f8c19fbde6eb6634d7a63005081ffc1eb6c28e9ec.json @@ -1,10 +1,6 @@ { "db_name": "PostgreSQL", -<<<<<<<< HEAD:core/lib/dal/.sqlx/query-7e11644708ac8b20a5793534ad8e7efdf3996bb3520c81c6b63b0ddc6f1b0d84.json - "query": "\n SELECT\n number,\n l1_tx_count,\n l2_tx_count,\n timestamp,\n l2_to_l1_messages,\n bloom,\n priority_ops_onchain_data,\n used_contract_hashes,\n bootloader_code_hash,\n default_aa_code_hash,\n protocol_version,\n system_logs,\n pubdata_input,\n fee_address\n FROM\n l1_batches\n WHERE\n is_sealed\n AND number = $1\n ", -======== - "query": "\n SELECT\n number,\n l1_tx_count,\n l2_tx_count,\n timestamp,\n l2_to_l1_messages,\n bloom,\n priority_ops_onchain_data,\n used_contract_hashes,\n bootloader_code_hash,\n default_aa_code_hash,\n evm_emulator_code_hash,\n protocol_version,\n system_logs,\n pubdata_input\n FROM\n l1_batches\n WHERE\n number = $1\n ", ->>>>>>>> origin/main:core/lib/dal/.sqlx/query-7cceb18485c0fdeed57b7f279debfe9b944b2dd80eb56965a5874ce3168e8c5e.json + "query": "\n SELECT\n number,\n l1_tx_count,\n l2_tx_count,\n timestamp,\n l2_to_l1_messages,\n bloom,\n priority_ops_onchain_data,\n used_contract_hashes,\n bootloader_code_hash,\n default_aa_code_hash,\n evm_emulator_code_hash,\n protocol_version,\n system_logs,\n pubdata_input,\n fee_address\n FROM\n l1_batches\n WHERE\n is_sealed\n AND number = $1\n ", "describe": { "columns": [ { @@ -78,7 +74,7 @@ "type_info": "Bytea" }, { - "ordinal": 13, + "ordinal": 14, "name": "fee_address", "type_info": "Bytea" } @@ -106,9 +102,5 @@ false ] }, -<<<<<<<< HEAD:core/lib/dal/.sqlx/query-7e11644708ac8b20a5793534ad8e7efdf3996bb3520c81c6b63b0ddc6f1b0d84.json - "hash": "7e11644708ac8b20a5793534ad8e7efdf3996bb3520c81c6b63b0ddc6f1b0d84" -======== - "hash": "7cceb18485c0fdeed57b7f279debfe9b944b2dd80eb56965a5874ce3168e8c5e" ->>>>>>>> origin/main:core/lib/dal/.sqlx/query-7cceb18485c0fdeed57b7f279debfe9b944b2dd80eb56965a5874ce3168e8c5e.json + "hash": "4e994d519b9c75e64a74423f8c19fbde6eb6634d7a63005081ffc1eb6c28e9ec" } diff --git a/core/lib/dal/.sqlx/query-da1ea91f3a1189f881020a6cec17fc5d8943e65a30508898d90a098432050bc7.json b/core/lib/dal/.sqlx/query-5aa487a98dff53a5d32a5916a26cbf3ffb03b3791c0e9a9f39fb85cfffc65db2.json similarity index 62% rename from core/lib/dal/.sqlx/query-da1ea91f3a1189f881020a6cec17fc5d8943e65a30508898d90a098432050bc7.json rename to core/lib/dal/.sqlx/query-5aa487a98dff53a5d32a5916a26cbf3ffb03b3791c0e9a9f39fb85cfffc65db2.json index 6e20e635f79d..4eae4f778cee 100644 --- a/core/lib/dal/.sqlx/query-da1ea91f3a1189f881020a6cec17fc5d8943e65a30508898d90a098432050bc7.json +++ b/core/lib/dal/.sqlx/query-5aa487a98dff53a5d32a5916a26cbf3ffb03b3791c0e9a9f39fb85cfffc65db2.json @@ -1,10 +1,6 @@ { "db_name": "PostgreSQL", -<<<<<<<< HEAD:core/lib/dal/.sqlx/query-98950ef9f0085089044429b271dd5f335e8279fda50e8b78d559b2af828d9b0a.json - "query": "\n SELECT\n number,\n timestamp,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n hash,\n commitment,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_merkle_root,\n rollup_last_leaf_index,\n zkporter_is_available,\n bootloader_code_hash,\n default_aa_code_hash,\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 pubdata_input,\n fee_address\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 ", -======== - "query": "\n SELECT\n number,\n timestamp,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n hash,\n commitment,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_merkle_root,\n rollup_last_leaf_index,\n zkporter_is_available,\n bootloader_code_hash,\n default_aa_code_hash,\n evm_emulator_code_hash,\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 pubdata_input\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 ", ->>>>>>>> origin/main:core/lib/dal/.sqlx/query-da1ea91f3a1189f881020a6cec17fc5d8943e65a30508898d90a098432050bc7.json + "query": "\n SELECT\n number,\n timestamp,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n hash,\n commitment,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_merkle_root,\n rollup_last_leaf_index,\n zkporter_is_available,\n bootloader_code_hash,\n default_aa_code_hash,\n evm_emulator_code_hash,\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 pubdata_input,\n fee_address\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 ", "describe": { "columns": [ { @@ -143,7 +139,7 @@ "type_info": "Bytea" }, { - "ordinal": 26, + "ordinal": 27, "name": "fee_address", "type_info": "Bytea" } @@ -184,9 +180,5 @@ false ] }, -<<<<<<<< HEAD:core/lib/dal/.sqlx/query-98950ef9f0085089044429b271dd5f335e8279fda50e8b78d559b2af828d9b0a.json - "hash": "98950ef9f0085089044429b271dd5f335e8279fda50e8b78d559b2af828d9b0a" -======== - "hash": "da1ea91f3a1189f881020a6cec17fc5d8943e65a30508898d90a098432050bc7" ->>>>>>>> origin/main:core/lib/dal/.sqlx/query-da1ea91f3a1189f881020a6cec17fc5d8943e65a30508898d90a098432050bc7.json + "hash": "5aa487a98dff53a5d32a5916a26cbf3ffb03b3791c0e9a9f39fb85cfffc65db2" } diff --git a/core/lib/dal/.sqlx/query-7240ff1240a2cdae14ab1bbfaad97f64d0c9620506bb41890548181bccca9ee5.json b/core/lib/dal/.sqlx/query-7240ff1240a2cdae14ab1bbfaad97f64d0c9620506bb41890548181bccca9ee5.json deleted file mode 100644 index 9af5eb059252..000000000000 --- a/core/lib/dal/.sqlx/query-7240ff1240a2cdae14ab1bbfaad97f64d0c9620506bb41890548181bccca9ee5.json +++ /dev/null @@ -1,144 +0,0 @@ -{ - "db_name": "PostgreSQL", -<<<<<<<< HEAD:core/lib/dal/.sqlx/query-17cfbae7761d3f93ca4ab7aefef185d804460cf388ba06515e965341b32b2856.json - "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 WHERE\n is_sealed\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.fair_pubdata_price,\n miniblocks.bootloader_code_hash,\n miniblocks.default_aa_code_hash,\n miniblocks.protocol_version,\n miniblocks.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\n 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\n 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\n 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 ", -======== - "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.fair_pubdata_price,\n miniblocks.bootloader_code_hash,\n miniblocks.default_aa_code_hash,\n l1_batches.evm_emulator_code_hash,\n miniblocks.protocol_version,\n miniblocks.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\n 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\n 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\n 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 ", ->>>>>>>> origin/main:core/lib/dal/.sqlx/query-7240ff1240a2cdae14ab1bbfaad97f64d0c9620506bb41890548181bccca9ee5.json - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "number", - "type_info": "Int8" - }, - { - "ordinal": 1, - "name": "l1_batch_number!", - "type_info": "Int8" - }, - { - "ordinal": 2, - "name": "timestamp", - "type_info": "Int8" - }, - { - "ordinal": 3, - "name": "l1_tx_count", - "type_info": "Int4" - }, - { - "ordinal": 4, - "name": "l2_tx_count", - "type_info": "Int4" - }, - { - "ordinal": 5, - "name": "root_hash?", - "type_info": "Bytea" - }, - { - "ordinal": 6, - "name": "commit_tx_hash?", - "type_info": "Text" - }, - { - "ordinal": 7, - "name": "committed_at?", - "type_info": "Timestamp" - }, - { - "ordinal": 8, - "name": "prove_tx_hash?", - "type_info": "Text" - }, - { - "ordinal": 9, - "name": "proven_at?", - "type_info": "Timestamp" - }, - { - "ordinal": 10, - "name": "execute_tx_hash?", - "type_info": "Text" - }, - { - "ordinal": 11, - "name": "executed_at?", - "type_info": "Timestamp" - }, - { - "ordinal": 12, - "name": "l1_gas_price", - "type_info": "Int8" - }, - { - "ordinal": 13, - "name": "l2_fair_gas_price", - "type_info": "Int8" - }, - { - "ordinal": 14, - "name": "fair_pubdata_price", - "type_info": "Int8" - }, - { - "ordinal": 15, - "name": "bootloader_code_hash", - "type_info": "Bytea" - }, - { - "ordinal": 16, - "name": "default_aa_code_hash", - "type_info": "Bytea" - }, - { - "ordinal": 17, - "name": "evm_emulator_code_hash", - "type_info": "Bytea" - }, - { - "ordinal": 18, - "name": "protocol_version", - "type_info": "Int4" - }, - { - "ordinal": 19, - "name": "fee_account_address", - "type_info": "Bytea" - } - ], - "parameters": { - "Left": [ - "Int8" - ] - }, - "nullable": [ - false, - null, - false, - false, - false, - false, - false, - true, - false, - true, - false, - true, - false, - false, - true, - true, - true, - true, - true, - false - ] - }, -<<<<<<<< HEAD:core/lib/dal/.sqlx/query-17cfbae7761d3f93ca4ab7aefef185d804460cf388ba06515e965341b32b2856.json - "hash": "17cfbae7761d3f93ca4ab7aefef185d804460cf388ba06515e965341b32b2856" -======== - "hash": "7240ff1240a2cdae14ab1bbfaad97f64d0c9620506bb41890548181bccca9ee5" ->>>>>>>> origin/main:core/lib/dal/.sqlx/query-7240ff1240a2cdae14ab1bbfaad97f64d0c9620506bb41890548181bccca9ee5.json -} diff --git a/core/lib/dal/.sqlx/query-66aa91ae9f9c54346d9966ea5e0bc61568110e9bbe688c55862f93fa62a71405.json b/core/lib/dal/.sqlx/query-746d8b62d576b4b9596458aa865e0294e53eb37c1a2dbcc3044b8311200d549a.json similarity index 66% rename from core/lib/dal/.sqlx/query-66aa91ae9f9c54346d9966ea5e0bc61568110e9bbe688c55862f93fa62a71405.json rename to core/lib/dal/.sqlx/query-746d8b62d576b4b9596458aa865e0294e53eb37c1a2dbcc3044b8311200d549a.json index b9c984920993..306f193861f1 100644 --- a/core/lib/dal/.sqlx/query-66aa91ae9f9c54346d9966ea5e0bc61568110e9bbe688c55862f93fa62a71405.json +++ b/core/lib/dal/.sqlx/query-746d8b62d576b4b9596458aa865e0294e53eb37c1a2dbcc3044b8311200d549a.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n UPDATE l1_batches\n SET\n l1_tx_count = $2,\n l2_tx_count = $3,\n l2_to_l1_messages = $4,\n bloom = $5,\n priority_ops_onchain_data = $6,\n predicted_commit_gas_cost = $7,\n predicted_prove_gas_cost = $8,\n predicted_execute_gas_cost = $9,\n initial_bootloader_heap_content = $10,\n used_contract_hashes = $11,\n bootloader_code_hash = $12,\n default_aa_code_hash = $13,\n protocol_version = $14,\n system_logs = $15,\n storage_refunds = $16,\n pubdata_costs = $17,\n pubdata_input = $18,\n predicted_circuits_by_type = $19,\n updated_at = NOW(),\n is_sealed = TRUE\n WHERE\n number = $1\n ", + "query": "\n UPDATE l1_batches\n SET\n l1_tx_count = $2,\n l2_tx_count = $3,\n l2_to_l1_messages = $4,\n bloom = $5,\n priority_ops_onchain_data = $6,\n predicted_commit_gas_cost = $7,\n predicted_prove_gas_cost = $8,\n predicted_execute_gas_cost = $9,\n initial_bootloader_heap_content = $10,\n used_contract_hashes = $11,\n bootloader_code_hash = $12,\n default_aa_code_hash = $13,\n evm_emulator_code_hash = $14,\n protocol_version = $15,\n system_logs = $16,\n storage_refunds = $17,\n pubdata_costs = $18,\n pubdata_input = $19,\n predicted_circuits_by_type = $20,\n updated_at = NOW(),\n is_sealed = TRUE\n WHERE\n number = $1\n ", "describe": { "columns": [], "parameters": { @@ -18,6 +18,7 @@ "Jsonb", "Bytea", "Bytea", + "Bytea", "Int4", "ByteaArray", "Int8Array", @@ -28,5 +29,5 @@ }, "nullable": [] }, - "hash": "66aa91ae9f9c54346d9966ea5e0bc61568110e9bbe688c55862f93fa62a71405" + "hash": "746d8b62d576b4b9596458aa865e0294e53eb37c1a2dbcc3044b8311200d549a" } diff --git a/core/lib/dal/.sqlx/query-9ece18b3a36cbaeaa99ca3db466b9fabba23fa52a17a54146931476681edbd24.json b/core/lib/dal/.sqlx/query-7aebc0d8eb43bd835c4f175edc4c0371bdc118b25d64fcf526bd6575e4d675c8.json similarity index 64% rename from core/lib/dal/.sqlx/query-9ece18b3a36cbaeaa99ca3db466b9fabba23fa52a17a54146931476681edbd24.json rename to core/lib/dal/.sqlx/query-7aebc0d8eb43bd835c4f175edc4c0371bdc118b25d64fcf526bd6575e4d675c8.json index 15fd37a72d28..dffd3ed8f9d2 100644 --- a/core/lib/dal/.sqlx/query-9ece18b3a36cbaeaa99ca3db466b9fabba23fa52a17a54146931476681edbd24.json +++ b/core/lib/dal/.sqlx/query-7aebc0d8eb43bd835c4f175edc4c0371bdc118b25d64fcf526bd6575e4d675c8.json @@ -1,10 +1,6 @@ { "db_name": "PostgreSQL", -<<<<<<<< HEAD:core/lib/dal/.sqlx/query-2e0e17395685244ef508fc50f3a7b81f1fd2c43cf460a3d2b268fc4757fb173a.json - "query": "\n SELECT\n number,\n timestamp,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n hash,\n commitment,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_merkle_root,\n rollup_last_leaf_index,\n zkporter_is_available,\n bootloader_code_hash,\n default_aa_code_hash,\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 pubdata_input,\n fee_address\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 ", -======== - "query": "\n SELECT\n number,\n timestamp,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n hash,\n commitment,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_merkle_root,\n rollup_last_leaf_index,\n zkporter_is_available,\n bootloader_code_hash,\n default_aa_code_hash,\n evm_emulator_code_hash,\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 pubdata_input\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 ", ->>>>>>>> origin/main:core/lib/dal/.sqlx/query-9ece18b3a36cbaeaa99ca3db466b9fabba23fa52a17a54146931476681edbd24.json + "query": "\n SELECT\n number,\n timestamp,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n hash,\n commitment,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_merkle_root,\n rollup_last_leaf_index,\n zkporter_is_available,\n bootloader_code_hash,\n default_aa_code_hash,\n evm_emulator_code_hash,\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 pubdata_input,\n fee_address\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 ", "describe": { "columns": [ { @@ -143,7 +139,7 @@ "type_info": "Bytea" }, { - "ordinal": 26, + "ordinal": 27, "name": "fee_address", "type_info": "Bytea" } @@ -182,9 +178,5 @@ false ] }, -<<<<<<<< HEAD:core/lib/dal/.sqlx/query-2e0e17395685244ef508fc50f3a7b81f1fd2c43cf460a3d2b268fc4757fb173a.json - "hash": "2e0e17395685244ef508fc50f3a7b81f1fd2c43cf460a3d2b268fc4757fb173a" -======== - "hash": "9ece18b3a36cbaeaa99ca3db466b9fabba23fa52a17a54146931476681edbd24" ->>>>>>>> origin/main:core/lib/dal/.sqlx/query-9ece18b3a36cbaeaa99ca3db466b9fabba23fa52a17a54146931476681edbd24.json + "hash": "7aebc0d8eb43bd835c4f175edc4c0371bdc118b25d64fcf526bd6575e4d675c8" } diff --git a/core/lib/dal/.sqlx/query-9f2e976278266ae5845c5188c95876eb8a6a508aea04d93342df50dd9745c361.json b/core/lib/dal/.sqlx/query-942d6d948770c374ba4d3566c50e56e43137ac0cf45312d70dec0c407cadc1bf.json similarity index 53% rename from core/lib/dal/.sqlx/query-9f2e976278266ae5845c5188c95876eb8a6a508aea04d93342df50dd9745c361.json rename to core/lib/dal/.sqlx/query-942d6d948770c374ba4d3566c50e56e43137ac0cf45312d70dec0c407cadc1bf.json index 0ce426ae248f..8c22b4f92c4e 100644 --- a/core/lib/dal/.sqlx/query-9f2e976278266ae5845c5188c95876eb8a6a508aea04d93342df50dd9745c361.json +++ b/core/lib/dal/.sqlx/query-942d6d948770c374ba4d3566c50e56e43137ac0cf45312d70dec0c407cadc1bf.json @@ -1,10 +1,6 @@ { "db_name": "PostgreSQL", -<<<<<<<< HEAD:core/lib/dal/.sqlx/query-87ac5fd7cd2f7077f07742ded252a3def7e41216d0ca684784f71074dc1b5c5e.json - "query": "\n SELECT\n number,\n l1_batches.timestamp,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n hash,\n commitment,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_merkle_root,\n rollup_last_leaf_index,\n zkporter_is_available,\n l1_batches.bootloader_code_hash,\n l1_batches.default_aa_code_hash,\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 pubdata_input,\n fee_address\n FROM\n l1_batches\n LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number\n LEFT JOIN\n data_availability\n ON data_availability.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 AND (\n data_availability.inclusion_data IS NOT NULL\n OR $4 IS FALSE\n )\n ORDER BY\n number\n LIMIT\n $5\n ", -======== - "query": "\n SELECT\n number,\n l1_batches.timestamp,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n hash,\n commitment,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_merkle_root,\n rollup_last_leaf_index,\n zkporter_is_available,\n l1_batches.bootloader_code_hash,\n l1_batches.default_aa_code_hash,\n l1_batches.evm_emulator_code_hash,\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 pubdata_input\n FROM\n l1_batches\n LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number\n LEFT JOIN\n data_availability\n ON data_availability.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 AND (\n data_availability.inclusion_data IS NOT NULL\n OR $4 IS FALSE\n )\n ORDER BY\n number\n LIMIT\n $5\n ", ->>>>>>>> origin/main:core/lib/dal/.sqlx/query-9f2e976278266ae5845c5188c95876eb8a6a508aea04d93342df50dd9745c361.json + "query": "\n SELECT\n number,\n l1_batches.timestamp,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n hash,\n commitment,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_merkle_root,\n rollup_last_leaf_index,\n zkporter_is_available,\n l1_batches.bootloader_code_hash,\n l1_batches.default_aa_code_hash,\n l1_batches.evm_emulator_code_hash,\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 pubdata_input,\n fee_address\n FROM\n l1_batches\n LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number\n LEFT JOIN\n data_availability\n ON data_availability.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 AND (\n data_availability.inclusion_data IS NOT NULL\n OR $4 IS FALSE\n )\n ORDER BY\n number\n LIMIT\n $5\n ", "describe": { "columns": [ { @@ -143,7 +139,7 @@ "type_info": "Bytea" }, { - "ordinal": 26, + "ordinal": 27, "name": "fee_address", "type_info": "Bytea" } @@ -188,9 +184,5 @@ false ] }, -<<<<<<<< HEAD:core/lib/dal/.sqlx/query-87ac5fd7cd2f7077f07742ded252a3def7e41216d0ca684784f71074dc1b5c5e.json - "hash": "87ac5fd7cd2f7077f07742ded252a3def7e41216d0ca684784f71074dc1b5c5e" -======== - "hash": "9f2e976278266ae5845c5188c95876eb8a6a508aea04d93342df50dd9745c361" ->>>>>>>> origin/main:core/lib/dal/.sqlx/query-9f2e976278266ae5845c5188c95876eb8a6a508aea04d93342df50dd9745c361.json + "hash": "942d6d948770c374ba4d3566c50e56e43137ac0cf45312d70dec0c407cadc1bf" } diff --git a/core/lib/dal/.sqlx/query-4f5f59bc6fd27bb73c6020b6f0be7ca0e4b83f50724a0b18256aafab69909a98.json b/core/lib/dal/.sqlx/query-b456147560b107640abdc10f7ac76b563ff2f0f3a818e8c8a02c2ef632d0b960.json similarity index 67% rename from core/lib/dal/.sqlx/query-4f5f59bc6fd27bb73c6020b6f0be7ca0e4b83f50724a0b18256aafab69909a98.json rename to core/lib/dal/.sqlx/query-b456147560b107640abdc10f7ac76b563ff2f0f3a818e8c8a02c2ef632d0b960.json index 4c03966b370a..80a6946026b0 100644 --- a/core/lib/dal/.sqlx/query-4f5f59bc6fd27bb73c6020b6f0be7ca0e4b83f50724a0b18256aafab69909a98.json +++ b/core/lib/dal/.sqlx/query-b456147560b107640abdc10f7ac76b563ff2f0f3a818e8c8a02c2ef632d0b960.json @@ -1,10 +1,6 @@ { "db_name": "PostgreSQL", -<<<<<<<< HEAD:core/lib/dal/.sqlx/query-8194efed3c71aad25521b220ffd1d20df9afe9ba1e1a5b455205300b58fddd06.json - "query": "\n SELECT\n number,\n timestamp,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n hash,\n commitment,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_merkle_root,\n rollup_last_leaf_index,\n zkporter_is_available,\n bootloader_code_hash,\n default_aa_code_hash,\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 pubdata_input,\n fee_address\n FROM\n l1_batches\n LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number\n WHERE\n is_sealed\n AND number = $1\n ", -======== - "query": "\n SELECT\n number,\n timestamp,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n hash,\n commitment,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_merkle_root,\n rollup_last_leaf_index,\n zkporter_is_available,\n bootloader_code_hash,\n default_aa_code_hash,\n evm_emulator_code_hash,\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 pubdata_input\n FROM\n l1_batches\n LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number\n WHERE\n number = $1\n ", ->>>>>>>> origin/main:core/lib/dal/.sqlx/query-4f5f59bc6fd27bb73c6020b6f0be7ca0e4b83f50724a0b18256aafab69909a98.json + "query": "\n SELECT\n number,\n timestamp,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n hash,\n commitment,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_merkle_root,\n rollup_last_leaf_index,\n zkporter_is_available,\n bootloader_code_hash,\n default_aa_code_hash,\n evm_emulator_code_hash,\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 pubdata_input,\n fee_address\n FROM\n l1_batches\n LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number\n WHERE\n is_sealed\n AND number = $1\n ", "describe": { "columns": [ { @@ -143,7 +139,7 @@ "type_info": "Bytea" }, { - "ordinal": 26, + "ordinal": 27, "name": "fee_address", "type_info": "Bytea" } @@ -184,9 +180,5 @@ false ] }, -<<<<<<<< HEAD:core/lib/dal/.sqlx/query-8194efed3c71aad25521b220ffd1d20df9afe9ba1e1a5b455205300b58fddd06.json - "hash": "8194efed3c71aad25521b220ffd1d20df9afe9ba1e1a5b455205300b58fddd06" -======== - "hash": "4f5f59bc6fd27bb73c6020b6f0be7ca0e4b83f50724a0b18256aafab69909a98" ->>>>>>>> origin/main:core/lib/dal/.sqlx/query-4f5f59bc6fd27bb73c6020b6f0be7ca0e4b83f50724a0b18256aafab69909a98.json + "hash": "b456147560b107640abdc10f7ac76b563ff2f0f3a818e8c8a02c2ef632d0b960" } diff --git a/core/lib/dal/.sqlx/query-d3760406b7bf5d14a3fe6cbc9fb3926df634ebf0d8286181fa04884fb747cee8.json b/core/lib/dal/.sqlx/query-d3760406b7bf5d14a3fe6cbc9fb3926df634ebf0d8286181fa04884fb747cee8.json new file mode 100644 index 000000000000..ed3270de573e --- /dev/null +++ b/core/lib/dal/.sqlx/query-d3760406b7bf5d14a3fe6cbc9fb3926df634ebf0d8286181fa04884fb747cee8.json @@ -0,0 +1,136 @@ +{ + "db_name": "PostgreSQL", + "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 WHERE\n is_sealed\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.fair_pubdata_price,\n miniblocks.bootloader_code_hash,\n miniblocks.default_aa_code_hash,\n l1_batches.evm_emulator_code_hash,\n miniblocks.protocol_version,\n miniblocks.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\n 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\n 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\n 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 ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "number", + "type_info": "Int8" + }, + { + "ordinal": 1, + "name": "l1_batch_number!", + "type_info": "Int8" + }, + { + "ordinal": 2, + "name": "timestamp", + "type_info": "Int8" + }, + { + "ordinal": 3, + "name": "l1_tx_count", + "type_info": "Int4" + }, + { + "ordinal": 4, + "name": "l2_tx_count", + "type_info": "Int4" + }, + { + "ordinal": 5, + "name": "root_hash?", + "type_info": "Bytea" + }, + { + "ordinal": 6, + "name": "commit_tx_hash?", + "type_info": "Text" + }, + { + "ordinal": 7, + "name": "committed_at?", + "type_info": "Timestamp" + }, + { + "ordinal": 8, + "name": "prove_tx_hash?", + "type_info": "Text" + }, + { + "ordinal": 9, + "name": "proven_at?", + "type_info": "Timestamp" + }, + { + "ordinal": 10, + "name": "execute_tx_hash?", + "type_info": "Text" + }, + { + "ordinal": 11, + "name": "executed_at?", + "type_info": "Timestamp" + }, + { + "ordinal": 12, + "name": "l1_gas_price", + "type_info": "Int8" + }, + { + "ordinal": 13, + "name": "l2_fair_gas_price", + "type_info": "Int8" + }, + { + "ordinal": 14, + "name": "fair_pubdata_price", + "type_info": "Int8" + }, + { + "ordinal": 15, + "name": "bootloader_code_hash", + "type_info": "Bytea" + }, + { + "ordinal": 16, + "name": "default_aa_code_hash", + "type_info": "Bytea" + }, + { + "ordinal": 17, + "name": "evm_emulator_code_hash", + "type_info": "Bytea" + }, + { + "ordinal": 18, + "name": "protocol_version", + "type_info": "Int4" + }, + { + "ordinal": 19, + "name": "fee_account_address", + "type_info": "Bytea" + } + ], + "parameters": { + "Left": [ + "Int8" + ] + }, + "nullable": [ + false, + null, + false, + false, + false, + false, + false, + true, + false, + true, + false, + true, + false, + false, + true, + true, + true, + true, + true, + false + ] + }, + "hash": "d3760406b7bf5d14a3fe6cbc9fb3926df634ebf0d8286181fa04884fb747cee8" +} diff --git a/core/lib/dal/.sqlx/query-b037613a81f7b3cb106cf62205feb2d1aa6b398c6981c8d4f35e499f42b01731.json b/core/lib/dal/.sqlx/query-e2d0bd978f76e0ce09b36b0e4b0a2baec4b2531ecaa8da234863e2eb810761c7.json similarity index 65% rename from core/lib/dal/.sqlx/query-b037613a81f7b3cb106cf62205feb2d1aa6b398c6981c8d4f35e499f42b01731.json rename to core/lib/dal/.sqlx/query-e2d0bd978f76e0ce09b36b0e4b0a2baec4b2531ecaa8da234863e2eb810761c7.json index 3aebfc314b79..e55d10d6f9a8 100644 --- a/core/lib/dal/.sqlx/query-b037613a81f7b3cb106cf62205feb2d1aa6b398c6981c8d4f35e499f42b01731.json +++ b/core/lib/dal/.sqlx/query-e2d0bd978f76e0ce09b36b0e4b0a2baec4b2531ecaa8da234863e2eb810761c7.json @@ -1,10 +1,6 @@ { "db_name": "PostgreSQL", -<<<<<<<< HEAD:core/lib/dal/.sqlx/query-0fe5562f14f2746f1c098636fcc3232fcf489829c9f0ed74e03e22cf9c6d9af1.json - "query": "\n SELECT\n number,\n timestamp,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n hash,\n commitment,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_merkle_root,\n rollup_last_leaf_index,\n zkporter_is_available,\n bootloader_code_hash,\n default_aa_code_hash,\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 pubdata_input,\n fee_address\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 ", -======== - "query": "\n SELECT\n number,\n timestamp,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n hash,\n commitment,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_merkle_root,\n rollup_last_leaf_index,\n zkporter_is_available,\n bootloader_code_hash,\n default_aa_code_hash,\n evm_emulator_code_hash,\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 pubdata_input\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 ", ->>>>>>>> origin/main:core/lib/dal/.sqlx/query-b037613a81f7b3cb106cf62205feb2d1aa6b398c6981c8d4f35e499f42b01731.json + "query": "\n SELECT\n number,\n timestamp,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n hash,\n commitment,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_merkle_root,\n rollup_last_leaf_index,\n zkporter_is_available,\n bootloader_code_hash,\n default_aa_code_hash,\n evm_emulator_code_hash,\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 pubdata_input,\n fee_address\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 ", "describe": { "columns": [ { @@ -143,7 +139,7 @@ "type_info": "Bytea" }, { - "ordinal": 26, + "ordinal": 27, "name": "fee_address", "type_info": "Bytea" } @@ -186,9 +182,5 @@ false ] }, -<<<<<<<< HEAD:core/lib/dal/.sqlx/query-0fe5562f14f2746f1c098636fcc3232fcf489829c9f0ed74e03e22cf9c6d9af1.json - "hash": "0fe5562f14f2746f1c098636fcc3232fcf489829c9f0ed74e03e22cf9c6d9af1" -======== - "hash": "b037613a81f7b3cb106cf62205feb2d1aa6b398c6981c8d4f35e499f42b01731" ->>>>>>>> origin/main:core/lib/dal/.sqlx/query-b037613a81f7b3cb106cf62205feb2d1aa6b398c6981c8d4f35e499f42b01731.json + "hash": "e2d0bd978f76e0ce09b36b0e4b0a2baec4b2531ecaa8da234863e2eb810761c7" } diff --git a/core/lib/dal/.sqlx/query-05726523bb494b40011c28acd3f52dba1d37493d4c1db4b957cfec476a791b32.json b/core/lib/dal/.sqlx/query-f30748bef5f8d08b60739cdfd9508c8132d0958e4e25f4954e93d2095b4f11e8.json similarity index 57% rename from core/lib/dal/.sqlx/query-05726523bb494b40011c28acd3f52dba1d37493d4c1db4b957cfec476a791b32.json rename to core/lib/dal/.sqlx/query-f30748bef5f8d08b60739cdfd9508c8132d0958e4e25f4954e93d2095b4f11e8.json index 89fe9e668e7b..4f138822ad1b 100644 --- a/core/lib/dal/.sqlx/query-05726523bb494b40011c28acd3f52dba1d37493d4c1db4b957cfec476a791b32.json +++ b/core/lib/dal/.sqlx/query-f30748bef5f8d08b60739cdfd9508c8132d0958e4e25f4954e93d2095b4f11e8.json @@ -1,10 +1,6 @@ { "db_name": "PostgreSQL", -<<<<<<<< HEAD:core/lib/dal/.sqlx/query-7346e831cd774c8b3bdbcfb553a45b46fec57bde627c9d6700c220fba60320bd.json - "query": "\n SELECT\n number,\n timestamp,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n hash,\n commitment,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_merkle_root,\n rollup_last_leaf_index,\n zkporter_is_available,\n bootloader_code_hash,\n default_aa_code_hash,\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 pubdata_input,\n fee_address\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 ", -======== - "query": "\n SELECT\n number,\n timestamp,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n hash,\n commitment,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_merkle_root,\n rollup_last_leaf_index,\n zkporter_is_available,\n bootloader_code_hash,\n default_aa_code_hash,\n evm_emulator_code_hash,\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 pubdata_input\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 ", ->>>>>>>> origin/main:core/lib/dal/.sqlx/query-05726523bb494b40011c28acd3f52dba1d37493d4c1db4b957cfec476a791b32.json + "query": "\n SELECT\n number,\n timestamp,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n hash,\n commitment,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_merkle_root,\n rollup_last_leaf_index,\n zkporter_is_available,\n bootloader_code_hash,\n default_aa_code_hash,\n evm_emulator_code_hash,\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 pubdata_input,\n fee_address\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 ", "describe": { "columns": [ { @@ -143,7 +139,7 @@ "type_info": "Bytea" }, { - "ordinal": 26, + "ordinal": 27, "name": "fee_address", "type_info": "Bytea" } @@ -185,9 +181,5 @@ false ] }, -<<<<<<<< HEAD:core/lib/dal/.sqlx/query-7346e831cd774c8b3bdbcfb553a45b46fec57bde627c9d6700c220fba60320bd.json - "hash": "7346e831cd774c8b3bdbcfb553a45b46fec57bde627c9d6700c220fba60320bd" -======== - "hash": "05726523bb494b40011c28acd3f52dba1d37493d4c1db4b957cfec476a791b32" ->>>>>>>> origin/main:core/lib/dal/.sqlx/query-05726523bb494b40011c28acd3f52dba1d37493d4c1db4b957cfec476a791b32.json + "hash": "f30748bef5f8d08b60739cdfd9508c8132d0958e4e25f4954e93d2095b4f11e8" } diff --git a/core/lib/dal/.sqlx/query-f81c5b92cac0466af8a2721b44d914f15fd7a5fa3d7f7bc56906817c70b04950.json b/core/lib/dal/.sqlx/query-f81c5b92cac0466af8a2721b44d914f15fd7a5fa3d7f7bc56906817c70b04950.json deleted file mode 100644 index 4fe32531a3f1..000000000000 --- a/core/lib/dal/.sqlx/query-f81c5b92cac0466af8a2721b44d914f15fd7a5fa3d7f7bc56906817c70b04950.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "\n INSERT INTO\n l1_batches (\n number,\n l1_tx_count,\n l2_tx_count,\n timestamp,\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 bootloader_code_hash,\n default_aa_code_hash,\n evm_emulator_code_hash,\n protocol_version,\n system_logs,\n storage_refunds,\n pubdata_costs,\n pubdata_input,\n predicted_circuits_by_type,\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 NOW(),\n NOW()\n )\n ", - "describe": { - "columns": [], - "parameters": { - "Left": [ - "Int8", - "Int4", - "Int4", - "Int8", - "ByteaArray", - "Bytea", - "ByteaArray", - "Int8", - "Int8", - "Int8", - "Jsonb", - "Jsonb", - "Bytea", - "Bytea", - "Bytea", - "Int4", - "ByteaArray", - "Int8Array", - "Int8Array", - "Bytea", - "Jsonb" - ] - }, - "nullable": [] - }, - "hash": "f81c5b92cac0466af8a2721b44d914f15fd7a5fa3d7f7bc56906817c70b04950" -} From 84aafa7c39b12a82740493cd257051c600f46fd9 Mon Sep 17 00:00:00 2001 From: Daniyar Itegulov Date: Wed, 9 Oct 2024 18:59:29 +1100 Subject: [PATCH 13/14] add a test that continues from unsealed batch --- core/node/state_keeper/src/io/mod.rs | 4 +- core/node/state_keeper/src/io/tests/mod.rs | 50 +++++++++++++++++++ core/node/state_keeper/src/io/tests/tester.rs | 20 ++++++-- 3 files changed, 67 insertions(+), 7 deletions(-) diff --git a/core/node/state_keeper/src/io/mod.rs b/core/node/state_keeper/src/io/mod.rs index f8106fd2423b..0fc5ebb6c082 100644 --- a/core/node/state_keeper/src/io/mod.rs +++ b/core/node/state_keeper/src/io/mod.rs @@ -42,7 +42,7 @@ pub struct PendingBatchData { pub(crate) pending_l2_blocks: Vec, } -#[derive(Debug, Copy, Clone, Default)] +#[derive(Debug, Copy, Clone, Default, PartialEq)] pub struct L2BlockParams { /// The timestamp of the L2 block. pub timestamp: u64, @@ -58,7 +58,7 @@ pub struct L2BlockParams { } /// Parameters for a new L1 batch returned by [`StateKeeperIO::wait_for_new_batch_params()`]. -#[derive(Debug, Clone)] +#[derive(Debug, Clone, PartialEq)] pub struct L1BatchParams { /// Protocol version for the new L1 batch. pub protocol_version: ProtocolVersionId, diff --git a/core/node/state_keeper/src/io/tests/mod.rs b/core/node/state_keeper/src/io/tests/mod.rs index e2a90f30691b..cd60bc68b36a 100644 --- a/core/node/state_keeper/src/io/tests/mod.rs +++ b/core/node/state_keeper/src/io/tests/mod.rs @@ -556,3 +556,53 @@ async fn different_timestamp_for_l2_blocks_in_same_batch(commitment_mode: L1Batc .expect("no new L2 block params"); assert!(l2_block_params.timestamp > current_timestamp); } + +#[test_casing(2, COMMITMENT_MODES)] +#[tokio::test] +async fn continue_unsealed_batch_on_restart(commitment_mode: L1BatchCommitmentMode) { + let connection_pool = ConnectionPool::::test_pool().await; + let tester = Tester::new(commitment_mode); + tester.genesis(&connection_pool).await; + let mut storage = connection_pool.connection().await.unwrap(); + + let (mut mempool, mut mempool_guard) = + tester.create_test_mempool_io(connection_pool.clone()).await; + let (cursor, _) = mempool.initialize().await.unwrap(); + + // Insert a transaction into the mempool in order to open a new batch. + let tx_filter = l2_tx_filter( + &tester.create_batch_fee_input_provider().await, + ProtocolVersionId::latest().into(), + ) + .await + .unwrap(); + let tx = tester.insert_tx( + &mut mempool_guard, + tx_filter.fee_per_gas, + tx_filter.gas_per_pubdata, + ); + storage + .transactions_dal() + .insert_transaction_l2(&tx, TransactionExecutionMetrics::default()) + .await + .unwrap(); + + let old_l1_batch_params = mempool + .wait_for_new_batch_params(&cursor, Duration::from_secs(10)) + .await + .unwrap() + .expect("no batch params generated"); + + // Restart + drop((mempool, mempool_guard, cursor)); + let (mut mempool, _) = tester.create_test_mempool_io(connection_pool.clone()).await; + let (cursor, _) = mempool.initialize().await.unwrap(); + + let new_l1_batch_params = mempool + .wait_for_new_batch_params(&cursor, Duration::from_secs(10)) + .await + .unwrap() + .expect("no batch params generated"); + + assert_eq!(old_l1_batch_params, new_l1_batch_params); +} diff --git a/core/node/state_keeper/src/io/tests/tester.rs b/core/node/state_keeper/src/io/tests/tester.rs index 02170283e94b..1c12b8921b69 100644 --- a/core/node/state_keeper/src/io/tests/tester.rs +++ b/core/node/state_keeper/src/io/tests/tester.rs @@ -2,6 +2,7 @@ use std::{slice, sync::Arc, time::Duration}; +use crate::{MempoolGuard, MempoolIO}; use zksync_base_token_adjuster::NoOpRatioProvider; use zksync_config::{ configs::{chain::StateKeeperConfig, eth_sender::PubdataSendingMode, wallets::Wallets}, @@ -22,18 +23,17 @@ use zksync_node_genesis::create_genesis_l1_batch; use zksync_node_test_utils::{ create_l1_batch, create_l2_block, create_l2_transaction, execute_l2_transaction, }; +use zksync_types::fee_model::FeeModelConfigV2; use zksync_types::{ block::L2BlockHeader, commitment::L1BatchCommitmentMode, - fee_model::{BatchFeeInput, FeeModelConfig, FeeModelConfigV1}, + fee_model::{BatchFeeInput, FeeModelConfig}, l2::L2Tx, protocol_version::{L1VerifierConfig, ProtocolSemanticVersion}, system_contracts::get_system_smart_contracts, L2BlockNumber, L2ChainId, PriorityOpId, ProtocolVersionId, H256, }; -use crate::{MempoolGuard, MempoolIO}; - #[derive(Debug)] pub struct Tester { base_system_contracts: BaseSystemContracts, @@ -97,8 +97,13 @@ impl Tester { MainNodeFeeInputProvider::new( gas_adjuster, Arc::new(NoOpRatioProvider::default()), - FeeModelConfig::V1(FeeModelConfigV1 { + FeeModelConfig::V2(FeeModelConfigV2 { minimal_l2_gas_price: self.minimal_l2_gas_price(), + compute_overhead_part: 1.0, + pubdata_overhead_part: 1.0, + batch_overhead_l1_gas: 10, + max_gas_per_batch: 500_000_000_000, + max_pubdata_per_batch: 100_000_000_000, }), ) } @@ -116,8 +121,13 @@ impl Tester { let batch_fee_input_provider = MainNodeFeeInputProvider::new( gas_adjuster, Arc::new(NoOpRatioProvider::default()), - FeeModelConfig::V1(FeeModelConfigV1 { + FeeModelConfig::V2(FeeModelConfigV2 { minimal_l2_gas_price: self.minimal_l2_gas_price(), + compute_overhead_part: 1.0, + pubdata_overhead_part: 1.0, + batch_overhead_l1_gas: 10, + max_gas_per_batch: 500_000_000_000, + max_pubdata_per_batch: 100_000_000_000, }), ); From 9701c331939c5280da04f6f953902af52d28409c Mon Sep 17 00:00:00 2001 From: Daniyar Itegulov Date: Wed, 9 Oct 2024 19:33:36 +1100 Subject: [PATCH 14/14] fmt --- core/node/state_keeper/src/io/tests/tester.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/node/state_keeper/src/io/tests/tester.rs b/core/node/state_keeper/src/io/tests/tester.rs index 1c12b8921b69..062fc426e8cc 100644 --- a/core/node/state_keeper/src/io/tests/tester.rs +++ b/core/node/state_keeper/src/io/tests/tester.rs @@ -2,7 +2,6 @@ use std::{slice, sync::Arc, time::Duration}; -use crate::{MempoolGuard, MempoolIO}; use zksync_base_token_adjuster::NoOpRatioProvider; use zksync_config::{ configs::{chain::StateKeeperConfig, eth_sender::PubdataSendingMode, wallets::Wallets}, @@ -23,17 +22,18 @@ use zksync_node_genesis::create_genesis_l1_batch; use zksync_node_test_utils::{ create_l1_batch, create_l2_block, create_l2_transaction, execute_l2_transaction, }; -use zksync_types::fee_model::FeeModelConfigV2; use zksync_types::{ block::L2BlockHeader, commitment::L1BatchCommitmentMode, - fee_model::{BatchFeeInput, FeeModelConfig}, + fee_model::{BatchFeeInput, FeeModelConfig, FeeModelConfigV2}, l2::L2Tx, protocol_version::{L1VerifierConfig, ProtocolSemanticVersion}, system_contracts::get_system_smart_contracts, L2BlockNumber, L2ChainId, PriorityOpId, ProtocolVersionId, H256, }; +use crate::{MempoolGuard, MempoolIO}; + #[derive(Debug)] pub struct Tester { base_system_contracts: BaseSystemContracts,