diff --git a/core/lib/dal/.sqlx/query-860de4af5c11c3a7c9eb660ec7049749bd5fc78b09578589c26d3017cc6bd192.json b/core/lib/dal/.sqlx/query-0784f2cc13f85763cc7da29902850fa76a03907957b7a0d87ea55a7873f3312e.json similarity index 87% rename from core/lib/dal/.sqlx/query-860de4af5c11c3a7c9eb660ec7049749bd5fc78b09578589c26d3017cc6bd192.json rename to core/lib/dal/.sqlx/query-0784f2cc13f85763cc7da29902850fa76a03907957b7a0d87ea55a7873f3312e.json index 8f41bf3b4916..84f677a36c86 100644 --- a/core/lib/dal/.sqlx/query-860de4af5c11c3a7c9eb660ec7049749bd5fc78b09578589c26d3017cc6bd192.json +++ b/core/lib/dal/.sqlx/query-0784f2cc13f85763cc7da29902850fa76a03907957b7a0d87ea55a7873f3312e.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 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 ", + "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": [ { @@ -137,6 +137,11 @@ "ordinal": 26, "name": "pubdata_input", "type_info": "Bytea" + }, + { + "ordinal": 27, + "name": "fee_address", + "type_info": "Bytea" } ], "parameters": { @@ -171,8 +176,9 @@ false, true, true, - true + true, + false ] }, - "hash": "860de4af5c11c3a7c9eb660ec7049749bd5fc78b09578589c26d3017cc6bd192" + "hash": "0784f2cc13f85763cc7da29902850fa76a03907957b7a0d87ea55a7873f3312e" } 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-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-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-51d5b6fd147fa06ddadb5f8c9c0e12784694d2f8fe9a67159ad4c7abc2279ca6.json b/core/lib/dal/.sqlx/query-2049362aad5e32981e48e5c5ef7a00a91254ec6c8a68a359d22b02df5a40911f.json similarity index 63% rename from core/lib/dal/.sqlx/query-51d5b6fd147fa06ddadb5f8c9c0e12784694d2f8fe9a67159ad4c7abc2279ca6.json rename to core/lib/dal/.sqlx/query-2049362aad5e32981e48e5c5ef7a00a91254ec6c8a68a359d22b02df5a40911f.json index 6f77a656072b..b8f8db874b63 100644 --- a/core/lib/dal/.sqlx/query-51d5b6fd147fa06ddadb5f8c9c0e12784694d2f8fe9a67159ad4c7abc2279ca6.json +++ b/core/lib/dal/.sqlx/query-2049362aad5e32981e48e5c5ef7a00a91254ec6c8a68a359d22b02df5a40911f.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.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 ", + "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": [ { @@ -97,5 +97,5 @@ false ] }, - "hash": "51d5b6fd147fa06ddadb5f8c9c0e12784694d2f8fe9a67159ad4c7abc2279ca6" + "hash": "2049362aad5e32981e48e5c5ef7a00a91254ec6c8a68a359d22b02df5a40911f" } diff --git a/core/lib/dal/.sqlx/query-16d4658899c5b604fb794d44a8b3bef013ad12b66bdca7251be2af21e98fe870.json b/core/lib/dal/.sqlx/query-2def67eb8372245ed59e76e07d615598f5d22a3aebd893afddded0e3c6b94a3b.json similarity index 81% rename from core/lib/dal/.sqlx/query-16d4658899c5b604fb794d44a8b3bef013ad12b66bdca7251be2af21e98fe870.json rename to core/lib/dal/.sqlx/query-2def67eb8372245ed59e76e07d615598f5d22a3aebd893afddded0e3c6b94a3b.json index a3d356f4bea9..afac14e6d5cd 100644 --- a/core/lib/dal/.sqlx/query-16d4658899c5b604fb794d44a8b3bef013ad12b66bdca7251be2af21e98fe870.json +++ b/core/lib/dal/.sqlx/query-2def67eb8372245ed59e76e07d615598f5d22a3aebd893afddded0e3c6b94a3b.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 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 ", + "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": [ { @@ -137,6 +137,11 @@ "ordinal": 26, "name": "pubdata_input", "type_info": "Bytea" + }, + { + "ordinal": 27, + "name": "fee_address", + "type_info": "Bytea" } ], "parameters": { @@ -174,8 +179,9 @@ false, true, true, - true + true, + false ] }, - "hash": "16d4658899c5b604fb794d44a8b3bef013ad12b66bdca7251be2af21e98fe870" + "hash": "2def67eb8372245ed59e76e07d615598f5d22a3aebd893afddded0e3c6b94a3b" } diff --git a/core/lib/dal/.sqlx/query-7cceb18485c0fdeed57b7f279debfe9b944b2dd80eb56965a5874ce3168e8c5e.json b/core/lib/dal/.sqlx/query-4e994d519b9c75e64a74423f8c19fbde6eb6634d7a63005081ffc1eb6c28e9ec.json similarity index 83% rename from core/lib/dal/.sqlx/query-7cceb18485c0fdeed57b7f279debfe9b944b2dd80eb56965a5874ce3168e8c5e.json rename to core/lib/dal/.sqlx/query-4e994d519b9c75e64a74423f8c19fbde6eb6634d7a63005081ffc1eb6c28e9ec.json index 28fbea09998c..804318120fcc 100644 --- a/core/lib/dal/.sqlx/query-7cceb18485c0fdeed57b7f279debfe9b944b2dd80eb56965a5874ce3168e8c5e.json +++ b/core/lib/dal/.sqlx/query-4e994d519b9c75e64a74423f8c19fbde6eb6634d7a63005081ffc1eb6c28e9ec.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 evm_emulator_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 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": [ { @@ -72,6 +72,11 @@ "ordinal": 13, "name": "pubdata_input", "type_info": "Bytea" + }, + { + "ordinal": 14, + "name": "fee_address", + "type_info": "Bytea" } ], "parameters": { @@ -93,8 +98,9 @@ true, true, false, - true + true, + false ] }, - "hash": "7cceb18485c0fdeed57b7f279debfe9b944b2dd80eb56965a5874ce3168e8c5e" + "hash": "4e994d519b9c75e64a74423f8c19fbde6eb6634d7a63005081ffc1eb6c28e9ec" } 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-da1ea91f3a1189f881020a6cec17fc5d8943e65a30508898d90a098432050bc7.json b/core/lib/dal/.sqlx/query-5aa487a98dff53a5d32a5916a26cbf3ffb03b3791c0e9a9f39fb85cfffc65db2.json similarity index 86% rename from core/lib/dal/.sqlx/query-da1ea91f3a1189f881020a6cec17fc5d8943e65a30508898d90a098432050bc7.json rename to core/lib/dal/.sqlx/query-5aa487a98dff53a5d32a5916a26cbf3ffb03b3791c0e9a9f39fb85cfffc65db2.json index 032cf987fc0b..4eae4f778cee 100644 --- a/core/lib/dal/.sqlx/query-da1ea91f3a1189f881020a6cec17fc5d8943e65a30508898d90a098432050bc7.json +++ b/core/lib/dal/.sqlx/query-5aa487a98dff53a5d32a5916a26cbf3ffb03b3791c0e9a9f39fb85cfffc65db2.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 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 ", + "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": [ { @@ -137,6 +137,11 @@ "ordinal": 26, "name": "pubdata_input", "type_info": "Bytea" + }, + { + "ordinal": 27, + "name": "fee_address", + "type_info": "Bytea" } ], "parameters": { @@ -171,8 +176,9 @@ false, true, true, - true + true, + false ] }, - "hash": "da1ea91f3a1189f881020a6cec17fc5d8943e65a30508898d90a098432050bc7" + "hash": "5aa487a98dff53a5d32a5916a26cbf3ffb03b3791c0e9a9f39fb85cfffc65db2" } diff --git a/core/lib/dal/.sqlx/query-5dba5f8b178decfd77db0ca4f415e94ad6bdd84c31e4b2e0c629e51857533974.json b/core/lib/dal/.sqlx/query-5dba5f8b178decfd77db0ca4f415e94ad6bdd84c31e4b2e0c629e51857533974.json deleted file mode 100644 index c2d9fe2e1ac5..000000000000 --- a/core/lib/dal/.sqlx/query-5dba5f8b178decfd77db0ca4f415e94ad6bdd84c31e4b2e0c629e51857533974.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 \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": "5dba5f8b178decfd77db0ca4f415e94ad6bdd84c31e4b2e0c629e51857533974" -} 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-877d20634068170326ab5801b69c70aff49e60b7def3d93b9206e650c259168b.json b/core/lib/dal/.sqlx/query-5e8fc8ee5b143a7e0053f7c6f8c93ba84478b6e56c95dfae6d8cc84e938e80c6.json similarity index 57% rename from core/lib/dal/.sqlx/query-877d20634068170326ab5801b69c70aff49e60b7def3d93b9206e650c259168b.json rename to core/lib/dal/.sqlx/query-5e8fc8ee5b143a7e0053f7c6f8c93ba84478b6e56c95dfae6d8cc84e938e80c6.json index 3052b3a04d1a..959571601249 100644 --- a/core/lib/dal/.sqlx/query-877d20634068170326ab5801b69c70aff49e60b7def3d93b9206e650c259168b.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_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_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": "877d20634068170326ab5801b69c70aff49e60b7def3d93b9206e650c259168b" + "hash": "5e8fc8ee5b143a7e0053f7c6f8c93ba84478b6e56c95dfae6d8cc84e938e80c6" } diff --git a/core/lib/dal/.sqlx/query-746d8b62d576b4b9596458aa865e0294e53eb37c1a2dbcc3044b8311200d549a.json b/core/lib/dal/.sqlx/query-746d8b62d576b4b9596458aa865e0294e53eb37c1a2dbcc3044b8311200d549a.json new file mode 100644 index 000000000000..306f193861f1 --- /dev/null +++ b/core/lib/dal/.sqlx/query-746d8b62d576b4b9596458aa865e0294e53eb37c1a2dbcc3044b8311200d549a.json @@ -0,0 +1,33 @@ +{ + "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 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": { + "Left": [ + "Int8", + "Int4", + "Int4", + "ByteaArray", + "Bytea", + "ByteaArray", + "Int8", + "Int8", + "Int8", + "Jsonb", + "Jsonb", + "Bytea", + "Bytea", + "Bytea", + "Int4", + "ByteaArray", + "Int8Array", + "Int8Array", + "Bytea", + "Jsonb" + ] + }, + "nullable": [] + }, + "hash": "746d8b62d576b4b9596458aa865e0294e53eb37c1a2dbcc3044b8311200d549a" +} diff --git a/core/lib/dal/.sqlx/query-9ece18b3a36cbaeaa99ca3db466b9fabba23fa52a17a54146931476681edbd24.json b/core/lib/dal/.sqlx/query-7aebc0d8eb43bd835c4f175edc4c0371bdc118b25d64fcf526bd6575e4d675c8.json similarity index 86% rename from core/lib/dal/.sqlx/query-9ece18b3a36cbaeaa99ca3db466b9fabba23fa52a17a54146931476681edbd24.json rename to core/lib/dal/.sqlx/query-7aebc0d8eb43bd835c4f175edc4c0371bdc118b25d64fcf526bd6575e4d675c8.json index 9eb67bb8299a..dffd3ed8f9d2 100644 --- a/core/lib/dal/.sqlx/query-9ece18b3a36cbaeaa99ca3db466b9fabba23fa52a17a54146931476681edbd24.json +++ b/core/lib/dal/.sqlx/query-7aebc0d8eb43bd835c4f175edc4c0371bdc118b25d64fcf526bd6575e4d675c8.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 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 ", + "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": [ { @@ -137,6 +137,11 @@ "ordinal": 26, "name": "pubdata_input", "type_info": "Bytea" + }, + { + "ordinal": 27, + "name": "fee_address", + "type_info": "Bytea" } ], "parameters": { @@ -169,8 +174,9 @@ false, true, true, - true + true, + false ] }, - "hash": "9ece18b3a36cbaeaa99ca3db466b9fabba23fa52a17a54146931476681edbd24" + "hash": "7aebc0d8eb43bd835c4f175edc4c0371bdc118b25d64fcf526bd6575e4d675c8" } 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/.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-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-9f2e976278266ae5845c5188c95876eb8a6a508aea04d93342df50dd9745c361.json b/core/lib/dal/.sqlx/query-942d6d948770c374ba4d3566c50e56e43137ac0cf45312d70dec0c407cadc1bf.json similarity index 75% rename from core/lib/dal/.sqlx/query-9f2e976278266ae5845c5188c95876eb8a6a508aea04d93342df50dd9745c361.json rename to core/lib/dal/.sqlx/query-942d6d948770c374ba4d3566c50e56e43137ac0cf45312d70dec0c407cadc1bf.json index 55d56cc4ab00..8c22b4f92c4e 100644 --- a/core/lib/dal/.sqlx/query-9f2e976278266ae5845c5188c95876eb8a6a508aea04d93342df50dd9745c361.json +++ b/core/lib/dal/.sqlx/query-942d6d948770c374ba4d3566c50e56e43137ac0cf45312d70dec0c407cadc1bf.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 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 ", + "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": [ { @@ -137,6 +137,11 @@ "ordinal": 26, "name": "pubdata_input", "type_info": "Bytea" + }, + { + "ordinal": 27, + "name": "fee_address", + "type_info": "Bytea" } ], "parameters": { @@ -175,8 +180,9 @@ false, true, true, - true + true, + false ] }, - "hash": "9f2e976278266ae5845c5188c95876eb8a6a508aea04d93342df50dd9745c361" + "hash": "942d6d948770c374ba4d3566c50e56e43137ac0cf45312d70dec0c407cadc1bf" } 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-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-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-4f5f59bc6fd27bb73c6020b6f0be7ca0e4b83f50724a0b18256aafab69909a98.json b/core/lib/dal/.sqlx/query-b456147560b107640abdc10f7ac76b563ff2f0f3a818e8c8a02c2ef632d0b960.json similarity index 89% rename from core/lib/dal/.sqlx/query-4f5f59bc6fd27bb73c6020b6f0be7ca0e4b83f50724a0b18256aafab69909a98.json rename to core/lib/dal/.sqlx/query-b456147560b107640abdc10f7ac76b563ff2f0f3a818e8c8a02c2ef632d0b960.json index 752e171f58cb..80a6946026b0 100644 --- a/core/lib/dal/.sqlx/query-4f5f59bc6fd27bb73c6020b6f0be7ca0e4b83f50724a0b18256aafab69909a98.json +++ b/core/lib/dal/.sqlx/query-b456147560b107640abdc10f7ac76b563ff2f0f3a818e8c8a02c2ef632d0b960.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 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 ", + "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": [ { @@ -137,6 +137,11 @@ "ordinal": 26, "name": "pubdata_input", "type_info": "Bytea" + }, + { + "ordinal": 27, + "name": "fee_address", + "type_info": "Bytea" } ], "parameters": { @@ -171,8 +176,9 @@ true, true, true, - true + true, + false ] }, - "hash": "4f5f59bc6fd27bb73c6020b6f0be7ca0e4b83f50724a0b18256aafab69909a98" + "hash": "b456147560b107640abdc10f7ac76b563ff2f0f3a818e8c8a02c2ef632d0b960" } diff --git a/core/lib/dal/.sqlx/query-b6bfb2d998857f165ee04e282e299bf19b587a16ad70a671b0de48fd608bf31c.json b/core/lib/dal/.sqlx/query-b6bfb2d998857f165ee04e282e299bf19b587a16ad70a671b0de48fd608bf31c.json deleted file mode 100644 index 120fac1021f5..000000000000 --- a/core/lib/dal/.sqlx/query-b6bfb2d998857f165ee04e282e299bf19b587a16ad70a671b0de48fd608bf31c.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 \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": "b6bfb2d998857f165ee04e282e299bf19b587a16ad70a671b0de48fd608bf31c" -} 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-7240ff1240a2cdae14ab1bbfaad97f64d0c9620506bb41890548181bccca9ee5.json b/core/lib/dal/.sqlx/query-d3760406b7bf5d14a3fe6cbc9fb3926df634ebf0d8286181fa04884fb747cee8.json similarity index 58% rename from core/lib/dal/.sqlx/query-7240ff1240a2cdae14ab1bbfaad97f64d0c9620506bb41890548181bccca9ee5.json rename to core/lib/dal/.sqlx/query-d3760406b7bf5d14a3fe6cbc9fb3926df634ebf0d8286181fa04884fb747cee8.json index b2f195c4e5c1..ed3270de573e 100644 --- a/core/lib/dal/.sqlx/query-7240ff1240a2cdae14ab1bbfaad97f64d0c9620506bb41890548181bccca9ee5.json +++ b/core/lib/dal/.sqlx/query-d3760406b7bf5d14a3fe6cbc9fb3926df634ebf0d8286181fa04884fb747cee8.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 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 ", + "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": [ { @@ -132,5 +132,5 @@ false ] }, - "hash": "7240ff1240a2cdae14ab1bbfaad97f64d0c9620506bb41890548181bccca9ee5" + "hash": "d3760406b7bf5d14a3fe6cbc9fb3926df634ebf0d8286181fa04884fb747cee8" } diff --git a/core/lib/dal/.sqlx/query-d14b52df2cd9f9e484c60ba00383b438f14b68535111cf2cedd363fc646aac99.json b/core/lib/dal/.sqlx/query-d38116f1664a3ab88d285297e8caebfcd3b9c287fecde4376afa84c0566a55ef.json similarity index 57% rename from core/lib/dal/.sqlx/query-d14b52df2cd9f9e484c60ba00383b438f14b68535111cf2cedd363fc646aac99.json rename to core/lib/dal/.sqlx/query-d38116f1664a3ab88d285297e8caebfcd3b9c287fecde4376afa84c0566a55ef.json index 0370a63d65e3..15d6096420fb 100644 --- a/core/lib/dal/.sqlx/query-d14b52df2cd9f9e484c60ba00383b438f14b68535111cf2cedd363fc646aac99.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_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_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": "d14b52df2cd9f9e484c60ba00383b438f14b68535111cf2cedd363fc646aac99" + "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-b037613a81f7b3cb106cf62205feb2d1aa6b398c6981c8d4f35e499f42b01731.json b/core/lib/dal/.sqlx/query-e2d0bd978f76e0ce09b36b0e4b0a2baec4b2531ecaa8da234863e2eb810761c7.json similarity index 88% rename from core/lib/dal/.sqlx/query-b037613a81f7b3cb106cf62205feb2d1aa6b398c6981c8d4f35e499f42b01731.json rename to core/lib/dal/.sqlx/query-e2d0bd978f76e0ce09b36b0e4b0a2baec4b2531ecaa8da234863e2eb810761c7.json index 6588ee2f11ef..e55d10d6f9a8 100644 --- a/core/lib/dal/.sqlx/query-b037613a81f7b3cb106cf62205feb2d1aa6b398c6981c8d4f35e499f42b01731.json +++ b/core/lib/dal/.sqlx/query-e2d0bd978f76e0ce09b36b0e4b0a2baec4b2531ecaa8da234863e2eb810761c7.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 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 ", + "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": [ { @@ -137,6 +137,11 @@ "ordinal": 26, "name": "pubdata_input", "type_info": "Bytea" + }, + { + "ordinal": 27, + "name": "fee_address", + "type_info": "Bytea" } ], "parameters": { @@ -173,8 +178,9 @@ false, true, true, - true + true, + false ] }, - "hash": "b037613a81f7b3cb106cf62205feb2d1aa6b398c6981c8d4f35e499f42b01731" + "hash": "e2d0bd978f76e0ce09b36b0e4b0a2baec4b2531ecaa8da234863e2eb810761c7" } 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-05726523bb494b40011c28acd3f52dba1d37493d4c1db4b957cfec476a791b32.json b/core/lib/dal/.sqlx/query-f30748bef5f8d08b60739cdfd9508c8132d0958e4e25f4954e93d2095b4f11e8.json similarity index 79% rename from core/lib/dal/.sqlx/query-05726523bb494b40011c28acd3f52dba1d37493d4c1db4b957cfec476a791b32.json rename to core/lib/dal/.sqlx/query-f30748bef5f8d08b60739cdfd9508c8132d0958e4e25f4954e93d2095b4f11e8.json index c93e6aef3e7c..4f138822ad1b 100644 --- a/core/lib/dal/.sqlx/query-05726523bb494b40011c28acd3f52dba1d37493d4c1db4b957cfec476a791b32.json +++ b/core/lib/dal/.sqlx/query-f30748bef5f8d08b60739cdfd9508c8132d0958e4e25f4954e93d2095b4f11e8.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 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 ", + "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": [ { @@ -137,6 +137,11 @@ "ordinal": 26, "name": "pubdata_input", "type_info": "Bytea" + }, + { + "ordinal": 27, + "name": "fee_address", + "type_info": "Bytea" } ], "parameters": { @@ -172,8 +177,9 @@ true, true, true, - true + true, + false ] }, - "hash": "05726523bb494b40011c28acd3f52dba1d37493d4c1db4b957cfec476a791b32" + "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" -} 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..3706fc6630bd --- /dev/null +++ b/core/lib/dal/migrations/20240910112120_unsealed_batches_in_db.down.sql @@ -0,0 +1,5 @@ +ALTER TABLE l1_batches + RENAME COLUMN is_sealed TO is_finished; +ALTER table l1_batches + DROP COLUMN fair_pubdata_price, + DROP COLUMN fee_address; 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..6b08546ea1e5 --- /dev/null +++ b/core/lib/dal/migrations/20240910112120_unsealed_batches_in_db.up.sql @@ -0,0 +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 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 59cc557f36ec..347152e3c38d 100644 --- a/core/lib/dal/src/blocks_dal.rs +++ b/core/lib/dal/src/blocks_dal.rs @@ -17,9 +17,10 @@ use zksync_types::{ aggregated_operations::AggregatedActionType, block::{ BlockGasCount, L1BatchHeader, L1BatchStatistics, L1BatchTreeData, L2BlockHeader, - StorageOracleInfo, + StorageOracleInfo, UnsealedL1BatchHeader, }, commitment::{L1BatchCommitmentArtifacts, L1BatchWithMetadata}, + fee_model::BatchFeeInput, l2_to_l1_log::UserL2ToL1Log, writes::TreeWrite, Address, Bloom, L1BatchNumber, L2BlockNumber, ProtocolVersionId, H256, U256, @@ -30,7 +31,9 @@ pub use crate::models::storage_block::{L1BatchMetadataError, L1BatchWithOptional use crate::{ models::{ parse_protocol_version, - storage_block::{StorageL1Batch, StorageL1BatchHeader, StorageL2BlockHeader}, + storage_block::{ + StorageL1Batch, StorageL1BatchHeader, StorageL2BlockHeader, UnsealedStorageL1Batch, + }, storage_event::StorageL2ToL1Log, storage_oracle_info::DbStorageOracleInfo, }, @@ -89,6 +92,8 @@ impl BlocksDal<'_, '_> { COUNT(*) AS "count!" FROM l1_batches + WHERE + is_sealed "# ) .instrument("is_genesis_needed") @@ -105,6 +110,8 @@ impl BlocksDal<'_, '_> { MAX(number) AS "number" FROM l1_batches + WHERE + is_sealed "# ) .instrument("get_sealed_l1_batch_number") @@ -140,6 +147,8 @@ impl BlocksDal<'_, '_> { MIN(number) AS "number" FROM l1_batches + WHERE + is_sealed "# ) .instrument("get_earliest_l1_batch_number") @@ -334,12 +343,14 @@ 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 WHERE - number = $1 + is_sealed + AND number = $1 "#, i64::from(number.0) ) @@ -370,11 +381,13 @@ impl BlocksDal<'_, '_> { evm_emulator_code_hash, protocol_version, system_logs, - pubdata_input + pubdata_input, + fee_address FROM l1_batches WHERE - number = $1 + is_sealed + AND number = $1 "#, i64::from(number.0) ) @@ -407,7 +420,8 @@ impl BlocksDal<'_, '_> { FROM l1_batches WHERE - number = $1 + is_sealed + AND number = $1 "#, i64::from(number.0) ) @@ -438,7 +452,8 @@ impl BlocksDal<'_, '_> { FROM l1_batches WHERE - number = $1 + is_sealed + AND number = $1 "#, i64::from(number.0) ) @@ -559,7 +574,76 @@ 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, + protocol_version: Option, + fee_address: Address, + batch_fee_input: BatchFeeInput, + ) -> DalResult<()> { + 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 + ) + VALUES + ( + $1, + $2, + $3, + $4, + $5, + $6, + $7, + 0, + 0, + ''::bytea, + '{}'::bytea [], + '{}'::jsonb, + '{}'::jsonb, + NOW(), + NOW(), + FALSE + ) + "#, + 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, + ) + .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. + /// + /// Errors if the batch does not exist. + pub async fn mark_l1_batch_as_sealed( &mut self, header: &L1BatchHeader, initial_bootloader_contents: &[(usize, U256)], @@ -567,9 +651,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", @@ -596,63 +680,35 @@ 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, - evm_emulator_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, - $21, - 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, + evm_emulator_code_hash = $14, + protocol_version = $15, + system_logs = $16, + storage_refunds = $17, + pubdata_costs = $18, + pubdata_input = $19, + predicted_circuits_by_type = $20, + 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, @@ -675,13 +731,41 @@ impl BlocksDal<'_, '_> { pubdata_input, serde_json::to_value(predicted_circuits_by_type).unwrap(), ); + let update_result = instrumentation.with(query).execute(self.storage).await?; - let mut transaction = self.storage.start_transaction().await?; - instrumentation - .with(query) - .execute(&mut transaction) - .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 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<()> { @@ -1065,7 +1149,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 @@ -1252,7 +1337,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 @@ -1333,7 +1419,8 @@ impl BlocksDal<'_, '_> { protocol_version, events_queue_commitment, bootloader_initial_content_commitment, - pubdata_input + pubdata_input, + fee_address FROM ( SELECT @@ -1407,7 +1494,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 @@ -1535,7 +1623,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 @@ -1600,7 +1689,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 @@ -1679,7 +1769,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 @@ -2078,7 +2169,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 @@ -2100,7 +2192,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 @@ -2122,7 +2215,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 @@ -2147,7 +2241,8 @@ impl BlocksDal<'_, '_> { FROM l1_batches WHERE - number = $1 + is_sealed + AND number = $1 "#, i64::from(l1_batch_number.0) ) @@ -2217,7 +2312,8 @@ impl BlocksDal<'_, '_> { FROM l1_batches WHERE - protocol_version = $1 + is_sealed + AND protocol_version = $1 "#, protocol_version as i32 ) @@ -2523,8 +2619,16 @@ impl BlocksDal<'_, '_> { Ok(()) } - pub async fn insert_mock_l1_batch(&mut self, header: &L1BatchHeader) -> DalResult<()> { + pub async fn insert_mock_l1_batch(&mut self, header: &L1BatchHeader) -> anyhow::Result<()> { self.insert_l1_batch( + header.number, + header.timestamp, + header.protocol_version, + header.fee_address, + BatchFeeInput::pubdata_independent(100, 100, 100), + ) + .await?; + self.mark_l1_batch_as_sealed( header, &[], Default::default(), @@ -2835,7 +2939,17 @@ mod tests { execute: 10, }; conn.blocks_dal() - .insert_l1_batch(&header, &[], predicted_gas, &[], &[], Default::default()) + .insert_l1_batch( + header.number, + header.timestamp, + header.protocol_version, + header.fee_address, + BatchFeeInput::pubdata_independent(100, 100, 100), + ) + .await + .unwrap(); + conn.blocks_dal() + .mark_l1_batch_as_sealed(&header, &[], predicted_gas, &[], &[], Default::default()) .await .unwrap(); @@ -2843,7 +2957,17 @@ 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, + header.protocol_version, + header.fee_address, + BatchFeeInput::pubdata_independent(100, 100, 100), + ) + .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 c1a1e6765b69..829e15b5710a 100644 --- a/core/lib/dal/src/blocks_web3_dal.rs +++ b/core/lib/dal/src/blocks_web3_dal.rs @@ -656,6 +656,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/mod.rs b/core/lib/dal/src/consensus_dal/mod.rs index eb3385a992a5..9515e93f2b3c 100644 --- a/core/lib/dal/src/consensus_dal/mod.rs +++ b/core/lib/dal/src/consensus_dal/mod.rs @@ -707,6 +707,8 @@ impl ConsensusDal<'_, '_> { (MAX(number) + 1) FROM l1_batches + WHERE + is_sealed ), ( SELECT diff --git a/core/lib/dal/src/models/storage_block.rs b/core/lib/dal/src/models/storage_block.rs index 7e9a9eca9d41..3bb433a05cf8 100644 --- a/core/lib/dal/src/models/storage_block.rs +++ b/core/lib/dal/src/models/storage_block.rs @@ -6,7 +6,7 @@ use thiserror::Error; use zksync_contracts::BaseSystemContractsHashes; 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}, @@ -53,6 +53,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 { @@ -90,6 +91,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), } } } @@ -152,6 +154,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 { @@ -189,6 +192,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), } } } @@ -263,6 +267,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/dal/src/protocol_versions_dal.rs b/core/lib/dal/src/protocol_versions_dal.rs index 3b500e07a08a..3382d8c836e5 100644 --- a/core/lib/dal/src/protocol_versions_dal.rs +++ b/core/lib/dal/src/protocol_versions_dal.rs @@ -381,6 +381,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 f3a20ac39fa0..78c1dc0c3d0d 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 ab5684007d0b..265c61354887 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 b12b02186808..df0d3e86b889 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 ( @@ -205,6 +207,8 @@ impl VmRunnerDal<'_, '_> { MAX(number) AS "last_batch" FROM l1_batches + WHERE + is_sealed ), processed_batches AS ( diff --git a/core/lib/types/src/block.rs b/core/lib/types/src/block.rs index 9c1609bf1756..361e9ea56d28 100644 --- a/core/lib/types/src/block.rs +++ b/core/lib/types/src/block.rs @@ -65,6 +65,16 @@ pub struct L1BatchHeader { /// Version of protocol used for the L1 batch. pub protocol_version: Option, pub pubdata_input: Option>, + 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. @@ -132,6 +142,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 5c17add2e987..ba5e10dfb22c 100644 --- a/core/node/genesis/src/lib.rs +++ b/core/node/genesis/src/lib.rs @@ -392,6 +392,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), @@ -402,7 +403,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, @@ -419,6 +420,16 @@ pub async fn create_genesis_l1_batch( transaction .blocks_dal() .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?; + 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 7687595740a8..d4e7240da346 100644 --- a/core/node/node_sync/src/external_io.rs +++ b/core/node/node_sync/src/external_io.rs @@ -236,6 +236,19 @@ 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, + None, + params.operator_address, + 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 108283122bce..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). @@ -191,6 +215,19 @@ impl StateKeeperIO for MempoolIO { continue; } + self.pool + .connection() + .await? + .blocks_dal() + .insert_l1_batch( + cursor.l1_batch, + timestamp, + Some(protocol_version), + self.fee_account, + 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/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/persistence.rs b/core/node/state_keeper/src/io/persistence.rs index 97340d6496ab..16275ec672df 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,25 @@ 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, + None, + l1_batch_env.fee_account, + l1_batch_env.fee_input, + ) + .await + .unwrap(); let tx = create_transaction(10, 100); let tx_hash = tx.hash(); @@ -533,7 +549,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..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 @@ -141,7 +142,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/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..062fc426e8cc 100644 --- a/core/node/state_keeper/src/io/tests/tester.rs +++ b/core/node/state_keeper/src/io/tests/tester.rs @@ -25,7 +25,7 @@ use zksync_node_test_utils::{ use zksync_types::{ block::L2BlockHeader, commitment::L1BatchCommitmentMode, - fee_model::{BatchFeeInput, FeeModelConfig, FeeModelConfigV1}, + fee_model::{BatchFeeInput, FeeModelConfig, FeeModelConfigV2}, l2::L2Tx, protocol_version::{L1VerifierConfig, ProtocolSemanticVersion}, system_contracts::get_system_smart_contracts, @@ -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, }), ); diff --git a/core/node/state_keeper/src/updates/mod.rs b/core/node/state_keeper/src/updates/mod.rs index 0cebc5d8b471..6211755eb156 100644 --- a/core/node/state_keeper/src/updates/mod.rs +++ b/core/node/state_keeper/src/updates/mod.rs @@ -32,7 +32,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,