From 78373df6e75470d8158157a901ba45e2516565bf Mon Sep 17 00:00:00 2001 From: Daniyar Itegulov Date: Fri, 13 Sep 2024 15:31:03 +1000 Subject: [PATCH 01/19] add `BatchFeeInput` to L1 batch models --- ...50fa76a03907957b7a0d87ea55a7873f3312e.json | 30 +++++++++++ ...15598f5d22a3aebd893afddded0e3c6b94a3b.json | 29 ++++++++++ ...0613f921b0d9d99c1e0c219f05f8cfb5ad001.json | 32 +++++++++++ ...9fbde6eb6634d7a63005081ffc1eb6c28e9ec.json | 29 ++++++++++ ...cbf3ffb03b3791c0e9a9f39fb85cfffc65db2.json | 29 ++++++++++ ...c0371bdc118b25d64fcf526bd6575e4d675c8.json | 29 ++++++++++ ...e56e43137ac0cf45312d70dec0c407cadc1bf.json | 29 ++++++++++ ...76b563ff2f0f3a818e8c8a02c2ef632d0b960.json | 29 ++++++++++ ...a2baec4b2531ecaa8da234863e2eb810761c7.json | 29 ++++++++++ ...08c8132d0958e4e25f4954e93d2095b4f11e8.json | 29 ++++++++++ core/lib/dal/src/blocks_dal.rs | 45 ++++++++++++---- core/lib/dal/src/models/storage_block.rs | 53 ++++++++++++------- core/lib/types/src/block.rs | 2 + core/lib/types/src/fee_model.rs | 24 +++++++++ core/node/block_reverter/src/tests.rs | 7 +-- .../state_keeper/src/io/seal_logic/mod.rs | 1 + core/node/state_keeper/src/updates/mod.rs | 2 +- 17 files changed, 395 insertions(+), 33 deletions(-) create mode 100644 core/lib/dal/.sqlx/query-42fc6da4154f25fc711f194931b0613f921b0d9d99c1e0c219f05f8cfb5ad001.json diff --git a/core/lib/dal/.sqlx/query-0784f2cc13f85763cc7da29902850fa76a03907957b7a0d87ea55a7873f3312e.json b/core/lib/dal/.sqlx/query-0784f2cc13f85763cc7da29902850fa76a03907957b7a0d87ea55a7873f3312e.json index 84f677a36c86..715efb47f595 100644 --- a/core/lib/dal/.sqlx/query-0784f2cc13f85763cc7da29902850fa76a03907957b7a0d87ea55a7873f3312e.json +++ b/core/lib/dal/.sqlx/query-0784f2cc13f85763cc7da29902850fa76a03907957b7a0d87ea55a7873f3312e.json @@ -1,6 +1,10 @@ { "db_name": "PostgreSQL", +<<<<<<<< HEAD:core/lib/dal/.sqlx/query-0784f2cc13f85763cc7da29902850fa76a03907957b7a0d87ea55a7873f3312e.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 ", +======== + "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 l1_gas_price,\n l2_fair_gas_price,\n fair_pubdata_price\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 ", +>>>>>>>> 82ed8f925 (add `BatchFeeInput` to L1 batch models):core/lib/dal/.sqlx/query-de4a9c26a4a86d35a055b1c5c97d2262d4918c2226996c258c9cfe5127b71560.json "describe": { "columns": [ { @@ -139,9 +143,25 @@ "type_info": "Bytea" }, { +<<<<<<<< HEAD:core/lib/dal/.sqlx/query-0784f2cc13f85763cc7da29902850fa76a03907957b7a0d87ea55a7873f3312e.json "ordinal": 27, "name": "fee_address", "type_info": "Bytea" +======== + "ordinal": 26, + "name": "l1_gas_price", + "type_info": "Int8" + }, + { + "ordinal": 27, + "name": "l2_fair_gas_price", + "type_info": "Int8" + }, + { + "ordinal": 28, + "name": "fair_pubdata_price", + "type_info": "Int8" +>>>>>>>> 82ed8f925 (add `BatchFeeInput` to L1 batch models):core/lib/dal/.sqlx/query-de4a9c26a4a86d35a055b1c5c97d2262d4918c2226996c258c9cfe5127b71560.json } ], "parameters": { @@ -177,8 +197,18 @@ true, true, true, +<<<<<<<< HEAD:core/lib/dal/.sqlx/query-0784f2cc13f85763cc7da29902850fa76a03907957b7a0d87ea55a7873f3312e.json false ] }, "hash": "0784f2cc13f85763cc7da29902850fa76a03907957b7a0d87ea55a7873f3312e" +======== + true, + false, + false, + false + ] + }, + "hash": "de4a9c26a4a86d35a055b1c5c97d2262d4918c2226996c258c9cfe5127b71560" +>>>>>>>> 82ed8f925 (add `BatchFeeInput` to L1 batch models):core/lib/dal/.sqlx/query-de4a9c26a4a86d35a055b1c5c97d2262d4918c2226996c258c9cfe5127b71560.json } diff --git a/core/lib/dal/.sqlx/query-2def67eb8372245ed59e76e07d615598f5d22a3aebd893afddded0e3c6b94a3b.json b/core/lib/dal/.sqlx/query-2def67eb8372245ed59e76e07d615598f5d22a3aebd893afddded0e3c6b94a3b.json index afac14e6d5cd..e2d9f8044d84 100644 --- a/core/lib/dal/.sqlx/query-2def67eb8372245ed59e76e07d615598f5d22a3aebd893afddded0e3c6b94a3b.json +++ b/core/lib/dal/.sqlx/query-2def67eb8372245ed59e76e07d615598f5d22a3aebd893afddded0e3c6b94a3b.json @@ -1,6 +1,10 @@ { "db_name": "PostgreSQL", +<<<<<<<< HEAD:core/lib/dal/.sqlx/query-2def67eb8372245ed59e76e07d615598f5d22a3aebd893afddded0e3c6b94a3b.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 ", +======== + "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 l1_gas_price,\n l2_fair_gas_price,\n fair_pubdata_price\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 ", +>>>>>>>> 82ed8f925 (add `BatchFeeInput` to L1 batch models):core/lib/dal/.sqlx/query-63aa749a4a36711a5f58a0249dc475897bd7ee735707541571c694615df5ccf4.json "describe": { "columns": [ { @@ -139,9 +143,25 @@ "type_info": "Bytea" }, { +<<<<<<<< HEAD:core/lib/dal/.sqlx/query-2def67eb8372245ed59e76e07d615598f5d22a3aebd893afddded0e3c6b94a3b.json "ordinal": 27, "name": "fee_address", "type_info": "Bytea" +======== + "ordinal": 26, + "name": "l1_gas_price", + "type_info": "Int8" + }, + { + "ordinal": 27, + "name": "l2_fair_gas_price", + "type_info": "Int8" + }, + { + "ordinal": 28, + "name": "fair_pubdata_price", + "type_info": "Int8" +>>>>>>>> 82ed8f925 (add `BatchFeeInput` to L1 batch models):core/lib/dal/.sqlx/query-63aa749a4a36711a5f58a0249dc475897bd7ee735707541571c694615df5ccf4.json } ], "parameters": { @@ -180,8 +200,17 @@ true, true, true, +<<<<<<<< HEAD:core/lib/dal/.sqlx/query-2def67eb8372245ed59e76e07d615598f5d22a3aebd893afddded0e3c6b94a3b.json false ] }, "hash": "2def67eb8372245ed59e76e07d615598f5d22a3aebd893afddded0e3c6b94a3b" +======== + false, + false, + false + ] + }, + "hash": "63aa749a4a36711a5f58a0249dc475897bd7ee735707541571c694615df5ccf4" +>>>>>>>> 82ed8f925 (add `BatchFeeInput` to L1 batch models):core/lib/dal/.sqlx/query-63aa749a4a36711a5f58a0249dc475897bd7ee735707541571c694615df5ccf4.json } diff --git a/core/lib/dal/.sqlx/query-42fc6da4154f25fc711f194931b0613f921b0d9d99c1e0c219f05f8cfb5ad001.json b/core/lib/dal/.sqlx/query-42fc6da4154f25fc711f194931b0613f921b0d9d99c1e0c219f05f8cfb5ad001.json new file mode 100644 index 000000000000..af01e0671ac1 --- /dev/null +++ b/core/lib/dal/.sqlx/query-42fc6da4154f25fc711f194931b0613f921b0d9d99c1e0c219f05f8cfb5ad001.json @@ -0,0 +1,32 @@ +{ + "db_name": "PostgreSQL", + "query": "\n SELECT\n l1_gas_price,\n l2_fair_gas_price,\n fair_pubdata_price\n FROM\n l1_batches\n ORDER BY\n number DESC\n LIMIT\n 1\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "l1_gas_price", + "type_info": "Int8" + }, + { + "ordinal": 1, + "name": "l2_fair_gas_price", + "type_info": "Int8" + }, + { + "ordinal": 2, + "name": "fair_pubdata_price", + "type_info": "Int8" + } + ], + "parameters": { + "Left": [] + }, + "nullable": [ + false, + false, + false + ] + }, + "hash": "42fc6da4154f25fc711f194931b0613f921b0d9d99c1e0c219f05f8cfb5ad001" +} diff --git a/core/lib/dal/.sqlx/query-4e994d519b9c75e64a74423f8c19fbde6eb6634d7a63005081ffc1eb6c28e9ec.json b/core/lib/dal/.sqlx/query-4e994d519b9c75e64a74423f8c19fbde6eb6634d7a63005081ffc1eb6c28e9ec.json index 804318120fcc..07335e8e57c6 100644 --- a/core/lib/dal/.sqlx/query-4e994d519b9c75e64a74423f8c19fbde6eb6634d7a63005081ffc1eb6c28e9ec.json +++ b/core/lib/dal/.sqlx/query-4e994d519b9c75e64a74423f8c19fbde6eb6634d7a63005081ffc1eb6c28e9ec.json @@ -1,6 +1,10 @@ { "db_name": "PostgreSQL", +<<<<<<<< HEAD:core/lib/dal/.sqlx/query-4e994d519b9c75e64a74423f8c19fbde6eb6634d7a63005081ffc1eb6c28e9ec.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 ", +======== + "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 l1_gas_price,\n l2_fair_gas_price,\n fair_pubdata_price\n FROM\n l1_batches\n WHERE\n is_sealed\n AND number = $1\n ", +>>>>>>>> 82ed8f925 (add `BatchFeeInput` to L1 batch models):core/lib/dal/.sqlx/query-23ab5c3751fc0187cc2d7acd8a8861181be4c70cfff7c44b2b4fc2f0fbf34db7.json "describe": { "columns": [ { @@ -74,9 +78,25 @@ "type_info": "Bytea" }, { +<<<<<<<< HEAD:core/lib/dal/.sqlx/query-4e994d519b9c75e64a74423f8c19fbde6eb6634d7a63005081ffc1eb6c28e9ec.json "ordinal": 14, "name": "fee_address", "type_info": "Bytea" +======== + "ordinal": 13, + "name": "l1_gas_price", + "type_info": "Int8" + }, + { + "ordinal": 14, + "name": "l2_fair_gas_price", + "type_info": "Int8" + }, + { + "ordinal": 15, + "name": "fair_pubdata_price", + "type_info": "Int8" +>>>>>>>> 82ed8f925 (add `BatchFeeInput` to L1 batch models):core/lib/dal/.sqlx/query-23ab5c3751fc0187cc2d7acd8a8861181be4c70cfff7c44b2b4fc2f0fbf34db7.json } ], "parameters": { @@ -99,8 +119,17 @@ true, false, true, +<<<<<<<< HEAD:core/lib/dal/.sqlx/query-4e994d519b9c75e64a74423f8c19fbde6eb6634d7a63005081ffc1eb6c28e9ec.json false ] }, "hash": "4e994d519b9c75e64a74423f8c19fbde6eb6634d7a63005081ffc1eb6c28e9ec" +======== + false, + false, + false + ] + }, + "hash": "23ab5c3751fc0187cc2d7acd8a8861181be4c70cfff7c44b2b4fc2f0fbf34db7" +>>>>>>>> 82ed8f925 (add `BatchFeeInput` to L1 batch models):core/lib/dal/.sqlx/query-23ab5c3751fc0187cc2d7acd8a8861181be4c70cfff7c44b2b4fc2f0fbf34db7.json } diff --git a/core/lib/dal/.sqlx/query-5aa487a98dff53a5d32a5916a26cbf3ffb03b3791c0e9a9f39fb85cfffc65db2.json b/core/lib/dal/.sqlx/query-5aa487a98dff53a5d32a5916a26cbf3ffb03b3791c0e9a9f39fb85cfffc65db2.json index 4eae4f778cee..e1015e0f0751 100644 --- a/core/lib/dal/.sqlx/query-5aa487a98dff53a5d32a5916a26cbf3ffb03b3791c0e9a9f39fb85cfffc65db2.json +++ b/core/lib/dal/.sqlx/query-5aa487a98dff53a5d32a5916a26cbf3ffb03b3791c0e9a9f39fb85cfffc65db2.json @@ -1,6 +1,10 @@ { "db_name": "PostgreSQL", +<<<<<<<< HEAD:core/lib/dal/.sqlx/query-5aa487a98dff53a5d32a5916a26cbf3ffb03b3791c0e9a9f39fb85cfffc65db2.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 ", +======== + "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 l1_gas_price,\n l2_fair_gas_price,\n fair_pubdata_price\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 ", +>>>>>>>> 82ed8f925 (add `BatchFeeInput` to L1 batch models):core/lib/dal/.sqlx/query-800e8c07f46f023aeab1e5829664bbcec6fa1cf147131d05ad065003773a57d6.json "describe": { "columns": [ { @@ -139,9 +143,25 @@ "type_info": "Bytea" }, { +<<<<<<<< HEAD:core/lib/dal/.sqlx/query-5aa487a98dff53a5d32a5916a26cbf3ffb03b3791c0e9a9f39fb85cfffc65db2.json "ordinal": 27, "name": "fee_address", "type_info": "Bytea" +======== + "ordinal": 26, + "name": "l1_gas_price", + "type_info": "Int8" + }, + { + "ordinal": 27, + "name": "l2_fair_gas_price", + "type_info": "Int8" + }, + { + "ordinal": 28, + "name": "fair_pubdata_price", + "type_info": "Int8" +>>>>>>>> 82ed8f925 (add `BatchFeeInput` to L1 batch models):core/lib/dal/.sqlx/query-800e8c07f46f023aeab1e5829664bbcec6fa1cf147131d05ad065003773a57d6.json } ], "parameters": { @@ -177,8 +197,17 @@ true, true, true, +<<<<<<<< HEAD:core/lib/dal/.sqlx/query-5aa487a98dff53a5d32a5916a26cbf3ffb03b3791c0e9a9f39fb85cfffc65db2.json false ] }, "hash": "5aa487a98dff53a5d32a5916a26cbf3ffb03b3791c0e9a9f39fb85cfffc65db2" +======== + false, + false, + false + ] + }, + "hash": "800e8c07f46f023aeab1e5829664bbcec6fa1cf147131d05ad065003773a57d6" +>>>>>>>> 82ed8f925 (add `BatchFeeInput` to L1 batch models):core/lib/dal/.sqlx/query-800e8c07f46f023aeab1e5829664bbcec6fa1cf147131d05ad065003773a57d6.json } diff --git a/core/lib/dal/.sqlx/query-7aebc0d8eb43bd835c4f175edc4c0371bdc118b25d64fcf526bd6575e4d675c8.json b/core/lib/dal/.sqlx/query-7aebc0d8eb43bd835c4f175edc4c0371bdc118b25d64fcf526bd6575e4d675c8.json index dffd3ed8f9d2..9e4ef4905f05 100644 --- a/core/lib/dal/.sqlx/query-7aebc0d8eb43bd835c4f175edc4c0371bdc118b25d64fcf526bd6575e4d675c8.json +++ b/core/lib/dal/.sqlx/query-7aebc0d8eb43bd835c4f175edc4c0371bdc118b25d64fcf526bd6575e4d675c8.json @@ -1,6 +1,10 @@ { "db_name": "PostgreSQL", +<<<<<<<< HEAD:core/lib/dal/.sqlx/query-7aebc0d8eb43bd835c4f175edc4c0371bdc118b25d64fcf526bd6575e4d675c8.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 ", +======== + "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 l1_gas_price,\n l2_fair_gas_price,\n fair_pubdata_price\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 ", +>>>>>>>> 82ed8f925 (add `BatchFeeInput` to L1 batch models):core/lib/dal/.sqlx/query-ea5e8c520c416063b70a62b4380f36331312400eef9957e9ef896a66dedb64bf.json "describe": { "columns": [ { @@ -139,9 +143,25 @@ "type_info": "Bytea" }, { +<<<<<<<< HEAD:core/lib/dal/.sqlx/query-7aebc0d8eb43bd835c4f175edc4c0371bdc118b25d64fcf526bd6575e4d675c8.json "ordinal": 27, "name": "fee_address", "type_info": "Bytea" +======== + "ordinal": 26, + "name": "l1_gas_price", + "type_info": "Int8" + }, + { + "ordinal": 27, + "name": "l2_fair_gas_price", + "type_info": "Int8" + }, + { + "ordinal": 28, + "name": "fair_pubdata_price", + "type_info": "Int8" +>>>>>>>> 82ed8f925 (add `BatchFeeInput` to L1 batch models):core/lib/dal/.sqlx/query-ea5e8c520c416063b70a62b4380f36331312400eef9957e9ef896a66dedb64bf.json } ], "parameters": { @@ -175,8 +195,17 @@ true, true, true, +<<<<<<<< HEAD:core/lib/dal/.sqlx/query-7aebc0d8eb43bd835c4f175edc4c0371bdc118b25d64fcf526bd6575e4d675c8.json false ] }, "hash": "7aebc0d8eb43bd835c4f175edc4c0371bdc118b25d64fcf526bd6575e4d675c8" +======== + false, + false, + false + ] + }, + "hash": "ea5e8c520c416063b70a62b4380f36331312400eef9957e9ef896a66dedb64bf" +>>>>>>>> 82ed8f925 (add `BatchFeeInput` to L1 batch models):core/lib/dal/.sqlx/query-ea5e8c520c416063b70a62b4380f36331312400eef9957e9ef896a66dedb64bf.json } diff --git a/core/lib/dal/.sqlx/query-942d6d948770c374ba4d3566c50e56e43137ac0cf45312d70dec0c407cadc1bf.json b/core/lib/dal/.sqlx/query-942d6d948770c374ba4d3566c50e56e43137ac0cf45312d70dec0c407cadc1bf.json index 8c22b4f92c4e..c2bd556033e8 100644 --- a/core/lib/dal/.sqlx/query-942d6d948770c374ba4d3566c50e56e43137ac0cf45312d70dec0c407cadc1bf.json +++ b/core/lib/dal/.sqlx/query-942d6d948770c374ba4d3566c50e56e43137ac0cf45312d70dec0c407cadc1bf.json @@ -1,6 +1,10 @@ { "db_name": "PostgreSQL", +<<<<<<<< HEAD:core/lib/dal/.sqlx/query-942d6d948770c374ba4d3566c50e56e43137ac0cf45312d70dec0c407cadc1bf.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 ", +======== + "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 l1_gas_price,\n l2_fair_gas_price,\n fair_pubdata_price\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 ", +>>>>>>>> 82ed8f925 (add `BatchFeeInput` to L1 batch models):core/lib/dal/.sqlx/query-793a46ca0c51cada16596d58797b6c50b04a0c033bf5375e22132b4490789f4d.json "describe": { "columns": [ { @@ -139,9 +143,25 @@ "type_info": "Bytea" }, { +<<<<<<<< HEAD:core/lib/dal/.sqlx/query-942d6d948770c374ba4d3566c50e56e43137ac0cf45312d70dec0c407cadc1bf.json "ordinal": 27, "name": "fee_address", "type_info": "Bytea" +======== + "ordinal": 26, + "name": "l1_gas_price", + "type_info": "Int8" + }, + { + "ordinal": 27, + "name": "l2_fair_gas_price", + "type_info": "Int8" + }, + { + "ordinal": 28, + "name": "fair_pubdata_price", + "type_info": "Int8" +>>>>>>>> 82ed8f925 (add `BatchFeeInput` to L1 batch models):core/lib/dal/.sqlx/query-793a46ca0c51cada16596d58797b6c50b04a0c033bf5375e22132b4490789f4d.json } ], "parameters": { @@ -181,8 +201,17 @@ true, true, true, +<<<<<<<< HEAD:core/lib/dal/.sqlx/query-942d6d948770c374ba4d3566c50e56e43137ac0cf45312d70dec0c407cadc1bf.json false ] }, "hash": "942d6d948770c374ba4d3566c50e56e43137ac0cf45312d70dec0c407cadc1bf" +======== + false, + false, + false + ] + }, + "hash": "793a46ca0c51cada16596d58797b6c50b04a0c033bf5375e22132b4490789f4d" +>>>>>>>> 82ed8f925 (add `BatchFeeInput` to L1 batch models):core/lib/dal/.sqlx/query-793a46ca0c51cada16596d58797b6c50b04a0c033bf5375e22132b4490789f4d.json } diff --git a/core/lib/dal/.sqlx/query-b456147560b107640abdc10f7ac76b563ff2f0f3a818e8c8a02c2ef632d0b960.json b/core/lib/dal/.sqlx/query-b456147560b107640abdc10f7ac76b563ff2f0f3a818e8c8a02c2ef632d0b960.json index 80a6946026b0..8b2e2d1bb220 100644 --- a/core/lib/dal/.sqlx/query-b456147560b107640abdc10f7ac76b563ff2f0f3a818e8c8a02c2ef632d0b960.json +++ b/core/lib/dal/.sqlx/query-b456147560b107640abdc10f7ac76b563ff2f0f3a818e8c8a02c2ef632d0b960.json @@ -1,6 +1,10 @@ { "db_name": "PostgreSQL", +<<<<<<<< HEAD:core/lib/dal/.sqlx/query-b456147560b107640abdc10f7ac76b563ff2f0f3a818e8c8a02c2ef632d0b960.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 ", +======== + "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 l1_gas_price,\n l2_fair_gas_price,\n fair_pubdata_price\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 ", +>>>>>>>> 82ed8f925 (add `BatchFeeInput` to L1 batch models):core/lib/dal/.sqlx/query-f3a1a12fd9e3fef3f9fbcc24a56545da1ffa0813f79362ce4665b44c1c765fa0.json "describe": { "columns": [ { @@ -139,9 +143,25 @@ "type_info": "Bytea" }, { +<<<<<<<< HEAD:core/lib/dal/.sqlx/query-b456147560b107640abdc10f7ac76b563ff2f0f3a818e8c8a02c2ef632d0b960.json "ordinal": 27, "name": "fee_address", "type_info": "Bytea" +======== + "ordinal": 26, + "name": "l1_gas_price", + "type_info": "Int8" + }, + { + "ordinal": 27, + "name": "l2_fair_gas_price", + "type_info": "Int8" + }, + { + "ordinal": 28, + "name": "fair_pubdata_price", + "type_info": "Int8" +>>>>>>>> 82ed8f925 (add `BatchFeeInput` to L1 batch models):core/lib/dal/.sqlx/query-f3a1a12fd9e3fef3f9fbcc24a56545da1ffa0813f79362ce4665b44c1c765fa0.json } ], "parameters": { @@ -176,9 +196,18 @@ true, true, true, +<<<<<<<< HEAD:core/lib/dal/.sqlx/query-b456147560b107640abdc10f7ac76b563ff2f0f3a818e8c8a02c2ef632d0b960.json true, false ] }, "hash": "b456147560b107640abdc10f7ac76b563ff2f0f3a818e8c8a02c2ef632d0b960" +======== + false, + false, + false + ] + }, + "hash": "f3a1a12fd9e3fef3f9fbcc24a56545da1ffa0813f79362ce4665b44c1c765fa0" +>>>>>>>> 82ed8f925 (add `BatchFeeInput` to L1 batch models):core/lib/dal/.sqlx/query-f3a1a12fd9e3fef3f9fbcc24a56545da1ffa0813f79362ce4665b44c1c765fa0.json } diff --git a/core/lib/dal/.sqlx/query-e2d0bd978f76e0ce09b36b0e4b0a2baec4b2531ecaa8da234863e2eb810761c7.json b/core/lib/dal/.sqlx/query-e2d0bd978f76e0ce09b36b0e4b0a2baec4b2531ecaa8da234863e2eb810761c7.json index e55d10d6f9a8..1339e6f720f0 100644 --- a/core/lib/dal/.sqlx/query-e2d0bd978f76e0ce09b36b0e4b0a2baec4b2531ecaa8da234863e2eb810761c7.json +++ b/core/lib/dal/.sqlx/query-e2d0bd978f76e0ce09b36b0e4b0a2baec4b2531ecaa8da234863e2eb810761c7.json @@ -1,6 +1,10 @@ { "db_name": "PostgreSQL", +<<<<<<<< HEAD:core/lib/dal/.sqlx/query-e2d0bd978f76e0ce09b36b0e4b0a2baec4b2531ecaa8da234863e2eb810761c7.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 ", +======== + "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 l1_gas_price,\n l2_fair_gas_price,\n fair_pubdata_price\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 ", +>>>>>>>> 82ed8f925 (add `BatchFeeInput` to L1 batch models):core/lib/dal/.sqlx/query-d0b4e82926bf07b0b7d59a1017a076b128bcd493c4e883519ea08806353a645c.json "describe": { "columns": [ { @@ -139,9 +143,25 @@ "type_info": "Bytea" }, { +<<<<<<<< HEAD:core/lib/dal/.sqlx/query-e2d0bd978f76e0ce09b36b0e4b0a2baec4b2531ecaa8da234863e2eb810761c7.json "ordinal": 27, "name": "fee_address", "type_info": "Bytea" +======== + "ordinal": 26, + "name": "l1_gas_price", + "type_info": "Int8" + }, + { + "ordinal": 27, + "name": "l2_fair_gas_price", + "type_info": "Int8" + }, + { + "ordinal": 28, + "name": "fair_pubdata_price", + "type_info": "Int8" +>>>>>>>> 82ed8f925 (add `BatchFeeInput` to L1 batch models):core/lib/dal/.sqlx/query-d0b4e82926bf07b0b7d59a1017a076b128bcd493c4e883519ea08806353a645c.json } ], "parameters": { @@ -179,8 +199,17 @@ true, true, true, +<<<<<<<< HEAD:core/lib/dal/.sqlx/query-e2d0bd978f76e0ce09b36b0e4b0a2baec4b2531ecaa8da234863e2eb810761c7.json false ] }, "hash": "e2d0bd978f76e0ce09b36b0e4b0a2baec4b2531ecaa8da234863e2eb810761c7" +======== + false, + false, + false + ] + }, + "hash": "d0b4e82926bf07b0b7d59a1017a076b128bcd493c4e883519ea08806353a645c" +>>>>>>>> 82ed8f925 (add `BatchFeeInput` to L1 batch models):core/lib/dal/.sqlx/query-d0b4e82926bf07b0b7d59a1017a076b128bcd493c4e883519ea08806353a645c.json } diff --git a/core/lib/dal/.sqlx/query-f30748bef5f8d08b60739cdfd9508c8132d0958e4e25f4954e93d2095b4f11e8.json b/core/lib/dal/.sqlx/query-f30748bef5f8d08b60739cdfd9508c8132d0958e4e25f4954e93d2095b4f11e8.json index 4f138822ad1b..b36c89dc42fe 100644 --- a/core/lib/dal/.sqlx/query-f30748bef5f8d08b60739cdfd9508c8132d0958e4e25f4954e93d2095b4f11e8.json +++ b/core/lib/dal/.sqlx/query-f30748bef5f8d08b60739cdfd9508c8132d0958e4e25f4954e93d2095b4f11e8.json @@ -1,6 +1,10 @@ { "db_name": "PostgreSQL", +<<<<<<<< HEAD:core/lib/dal/.sqlx/query-f30748bef5f8d08b60739cdfd9508c8132d0958e4e25f4954e93d2095b4f11e8.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 ", +======== + "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 l1_gas_price,\n l2_fair_gas_price,\n fair_pubdata_price\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 ", +>>>>>>>> 82ed8f925 (add `BatchFeeInput` to L1 batch models):core/lib/dal/.sqlx/query-fdfa11130c12d0a57b28eb3f0ecaeb46303a5c35d14b31fdaac3ce5099390150.json "describe": { "columns": [ { @@ -139,9 +143,25 @@ "type_info": "Bytea" }, { +<<<<<<<< HEAD:core/lib/dal/.sqlx/query-f30748bef5f8d08b60739cdfd9508c8132d0958e4e25f4954e93d2095b4f11e8.json "ordinal": 27, "name": "fee_address", "type_info": "Bytea" +======== + "ordinal": 26, + "name": "l1_gas_price", + "type_info": "Int8" + }, + { + "ordinal": 27, + "name": "l2_fair_gas_price", + "type_info": "Int8" + }, + { + "ordinal": 28, + "name": "fair_pubdata_price", + "type_info": "Int8" +>>>>>>>> 82ed8f925 (add `BatchFeeInput` to L1 batch models):core/lib/dal/.sqlx/query-fdfa11130c12d0a57b28eb3f0ecaeb46303a5c35d14b31fdaac3ce5099390150.json } ], "parameters": { @@ -178,8 +198,17 @@ true, true, true, +<<<<<<<< HEAD:core/lib/dal/.sqlx/query-f30748bef5f8d08b60739cdfd9508c8132d0958e4e25f4954e93d2095b4f11e8.json false ] }, "hash": "f30748bef5f8d08b60739cdfd9508c8132d0958e4e25f4954e93d2095b4f11e8" +======== + false, + false, + false + ] + }, + "hash": "fdfa11130c12d0a57b28eb3f0ecaeb46303a5c35d14b31fdaac3ce5099390150" +>>>>>>>> 82ed8f925 (add `BatchFeeInput` to L1 batch models):core/lib/dal/.sqlx/query-fdfa11130c12d0a57b28eb3f0ecaeb46303a5c35d14b31fdaac3ce5099390150.json } diff --git a/core/lib/dal/src/blocks_dal.rs b/core/lib/dal/src/blocks_dal.rs index bf1b48130c40..2dbe41df8e46 100644 --- a/core/lib/dal/src/blocks_dal.rs +++ b/core/lib/dal/src/blocks_dal.rs @@ -344,7 +344,10 @@ impl BlocksDal<'_, '_> { events_queue_commitment, bootloader_initial_content_commitment, pubdata_input, - fee_address + fee_address, + l1_gas_price, + l2_fair_gas_price, + fair_pubdata_price FROM l1_batches LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number @@ -382,7 +385,10 @@ impl BlocksDal<'_, '_> { protocol_version, system_logs, pubdata_input, - fee_address + fee_address, + l1_gas_price, + l2_fair_gas_price, + fair_pubdata_price FROM l1_batches WHERE @@ -1189,7 +1195,10 @@ impl BlocksDal<'_, '_> { events_queue_commitment, bootloader_initial_content_commitment, pubdata_input, - fee_address + fee_address, + l1_gas_price, + l2_fair_gas_price, + fair_pubdata_price FROM l1_batches LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number @@ -1377,7 +1386,10 @@ impl BlocksDal<'_, '_> { events_queue_commitment, bootloader_initial_content_commitment, pubdata_input, - fee_address + fee_address, + l1_gas_price, + l2_fair_gas_price, + fair_pubdata_price FROM l1_batches LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number @@ -1459,7 +1471,10 @@ impl BlocksDal<'_, '_> { events_queue_commitment, bootloader_initial_content_commitment, pubdata_input, - fee_address + fee_address, + l1_gas_price, + l2_fair_gas_price, + fair_pubdata_price FROM ( SELECT @@ -1534,7 +1549,10 @@ impl BlocksDal<'_, '_> { events_queue_commitment, bootloader_initial_content_commitment, pubdata_input, - fee_address + fee_address, + l1_gas_price, + l2_fair_gas_price, + fair_pubdata_price FROM l1_batches LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number @@ -1663,7 +1681,10 @@ impl BlocksDal<'_, '_> { events_queue_commitment, bootloader_initial_content_commitment, pubdata_input, - fee_address + fee_address, + l1_gas_price, + l2_fair_gas_price, + fair_pubdata_price FROM l1_batches LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number @@ -1729,7 +1750,10 @@ impl BlocksDal<'_, '_> { events_queue_commitment, bootloader_initial_content_commitment, pubdata_input, - fee_address + fee_address, + l1_gas_price, + l2_fair_gas_price, + fair_pubdata_price FROM l1_batches LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number @@ -1809,7 +1833,10 @@ impl BlocksDal<'_, '_> { events_queue_commitment, bootloader_initial_content_commitment, pubdata_input, - fee_address + fee_address, + l1_gas_price, + l2_fair_gas_price, + fair_pubdata_price FROM l1_batches LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number diff --git a/core/lib/dal/src/models/storage_block.rs b/core/lib/dal/src/models/storage_block.rs index 3bb433a05cf8..ee8e24859af7 100644 --- a/core/lib/dal/src/models/storage_block.rs +++ b/core/lib/dal/src/models/storage_block.rs @@ -54,6 +54,10 @@ pub(crate) struct StorageL1BatchHeader { pub system_logs: Vec>, pub pubdata_input: Option>, pub fee_address: Vec, + + pub l1_gas_price: i64, + pub l2_fair_gas_price: i64, + pub fair_pubdata_price: Option, } impl StorageL1BatchHeader { @@ -69,6 +73,14 @@ impl StorageL1BatchHeader { let system_logs = convert_l2_to_l1_logs(self.system_logs); + let batch_fee_input = BatchFeeInput::from_protocol_version( + self.protocol_version + .map(|v| (v as u16).try_into().unwrap()), + self.l1_gas_price as u64, + self.l2_fair_gas_price as u64, + self.fair_pubdata_price.map(|p| p as u64), + ); + L1BatchHeader { number: L1BatchNumber(self.number as u32), timestamp: self.timestamp as u64, @@ -92,6 +104,7 @@ impl StorageL1BatchHeader { .map(|v| (v as u16).try_into().unwrap()), pubdata_input: self.pubdata_input, fee_address: Address::from_slice(&self.fee_address), + batch_fee_input, } } } @@ -155,6 +168,10 @@ pub(crate) struct StorageL1Batch { pub bootloader_initial_content_commitment: Option>, pub pubdata_input: Option>, pub fee_address: Vec, + + pub l1_gas_price: i64, + pub l2_fair_gas_price: i64, + pub fair_pubdata_price: Option, } impl StorageL1Batch { @@ -170,6 +187,14 @@ impl StorageL1Batch { let system_logs = convert_l2_to_l1_logs(self.system_logs); + let batch_fee_input = BatchFeeInput::from_protocol_version( + self.protocol_version + .map(|v| (v as u16).try_into().unwrap()), + self.l1_gas_price as u64, + self.l2_fair_gas_price as u64, + self.fair_pubdata_price.map(|p| p as u64), + ); + L1BatchHeader { number: L1BatchNumber(self.number as u32), timestamp: self.timestamp as u64, @@ -193,6 +218,7 @@ impl StorageL1Batch { .map(|v| (v as u16).try_into().unwrap()), pubdata_input: self.pubdata_input, fee_address: Address::from_slice(&self.fee_address), + batch_fee_input, } } } @@ -490,25 +516,12 @@ pub(crate) struct StorageL2BlockHeader { impl From for L2BlockHeader { fn from(row: StorageL2BlockHeader) -> Self { let protocol_version = row.protocol_version.map(|v| (v as u16).try_into().unwrap()); - - let fee_input = protocol_version - .filter(|version: &ProtocolVersionId| version.is_post_1_4_1()) - .map(|_| { - BatchFeeInput::PubdataIndependent(PubdataIndependentBatchFeeModelInput { - fair_pubdata_price: row - .fair_pubdata_price - .expect("No fair pubdata price for 1.4.1 miniblock") - as u64, - fair_l2_gas_price: row.l2_fair_gas_price as u64, - l1_gas_price: row.l1_gas_price as u64, - }) - }) - .unwrap_or_else(|| { - BatchFeeInput::L1Pegged(L1PeggedBatchFeeModelInput { - fair_l2_gas_price: row.l2_fair_gas_price as u64, - l1_gas_price: row.l1_gas_price as u64, - }) - }); + let batch_fee_input = BatchFeeInput::from_protocol_version( + protocol_version, + row.l1_gas_price as u64, + row.l2_fair_gas_price as u64, + row.fair_pubdata_price.map(|p| p as u64), + ); L2BlockHeader { number: L2BlockNumber(row.number as u32), @@ -518,7 +531,7 @@ impl From for L2BlockHeader { l2_tx_count: row.l2_tx_count as u16, fee_account_address: Address::from_slice(&row.fee_account_address), base_fee_per_gas: row.base_fee_per_gas.to_u64().unwrap(), - batch_fee_input: fee_input, + batch_fee_input, base_system_contracts_hashes: convert_base_system_contracts_hashes( row.bootloader_code_hash, row.default_aa_code_hash, diff --git a/core/lib/types/src/block.rs b/core/lib/types/src/block.rs index 9211a6f1d8cf..4c6ecf836680 100644 --- a/core/lib/types/src/block.rs +++ b/core/lib/types/src/block.rs @@ -66,6 +66,7 @@ pub struct L1BatchHeader { pub protocol_version: Option, pub pubdata_input: Option>, pub fee_address: Address, + pub batch_fee_input: BatchFeeInput, } impl L1BatchHeader { @@ -155,6 +156,7 @@ impl L1BatchHeader { protocol_version: Some(protocol_version), pubdata_input: Some(vec![]), fee_address: Default::default(), + batch_fee_input: BatchFeeInput::pubdata_independent(0, 0, 0), } } diff --git a/core/lib/types/src/fee_model.rs b/core/lib/types/src/fee_model.rs index b59aa65b04e0..6673a1711abc 100644 --- a/core/lib/types/src/fee_model.rs +++ b/core/lib/types/src/fee_model.rs @@ -46,6 +46,30 @@ impl BatchFeeInput { fair_pubdata_price, }) } + + pub fn from_protocol_version( + protocol_version: Option, + l1_gas_price: u64, + fair_l2_gas_price: u64, + fair_pubdata_price: Option, + ) -> Self { + protocol_version + .filter(|version: &ProtocolVersionId| version.is_post_1_4_1()) + .map(|_| { + Self::PubdataIndependent(PubdataIndependentBatchFeeModelInput { + fair_pubdata_price: fair_pubdata_price + .expect("No fair pubdata price for 1.4.1 miniblock"), + fair_l2_gas_price, + l1_gas_price, + }) + }) + .unwrap_or_else(|| { + Self::L1Pegged(L1PeggedBatchFeeModelInput { + fair_l2_gas_price, + l1_gas_price, + }) + }) + } } impl Default for BatchFeeInput { diff --git a/core/node/block_reverter/src/tests.rs b/core/node/block_reverter/src/tests.rs index 85d894b7fd57..aac9b425dd21 100644 --- a/core/node/block_reverter/src/tests.rs +++ b/core/node/block_reverter/src/tests.rs @@ -2,6 +2,7 @@ use std::{collections::HashSet, sync::Mutex}; +use super::*; use assert_matches::assert_matches; use async_trait::async_trait; use test_casing::test_casing; @@ -10,14 +11,13 @@ use zksync_dal::Connection; use zksync_merkle_tree::TreeInstruction; use zksync_object_store::{Bucket, MockObjectStore}; use zksync_state::interface::ReadStorage; +use zksync_types::fee_model::BatchFeeInput; use zksync_types::{ block::{L1BatchHeader, L2BlockHeader}, snapshots::SnapshotVersion, AccountTreeId, L2BlockNumber, ProtocolVersion, ProtocolVersionId, StorageKey, StorageLog, }; -use super::*; - fn gen_storage_logs() -> Vec { (0..10) .map(|i| { @@ -60,7 +60,7 @@ async fn setup_storage(storage: &mut Connection<'_, Core>, storage_logs: &[Stora l2_tx_count: 0, fee_account_address: Address::default(), base_fee_per_gas: 0, - batch_fee_input: Default::default(), + batch_fee_input: BatchFeeInput::pubdata_independent(0, 0, 0), gas_per_pubdata_limit: 0, base_system_contracts_hashes: Default::default(), protocol_version: Some(ProtocolVersionId::latest()), @@ -88,6 +88,7 @@ async fn setup_storage(storage: &mut Connection<'_, Core>, storage_logs: &[Stora protocol_version: Some(ProtocolVersionId::latest()), pubdata_input: None, fee_address: Default::default(), + batch_fee_input: BatchFeeInput::pubdata_independent(0, 0, 0), }; storage .blocks_dal() 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 5859d27786d9..efa8c8fa304d 100644 --- a/core/node/state_keeper/src/io/seal_logic/mod.rs +++ b/core/node/state_keeper/src/io/seal_logic/mod.rs @@ -133,6 +133,7 @@ impl UpdatesManager { system_logs: finished_batch.final_execution_state.system_logs.clone(), pubdata_input: finished_batch.pubdata_input.clone(), fee_address: self.fee_account_address, + batch_fee_input: self.batch_fee_input, }; 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 6211755eb156..cee3da5129a0 100644 --- a/core/node/state_keeper/src/updates/mod.rs +++ b/core/node/state_keeper/src/updates/mod.rs @@ -33,7 +33,7 @@ pub mod l2_block_updates; pub struct UpdatesManager { batch_timestamp: u64, pub fee_account_address: Address, - batch_fee_input: BatchFeeInput, + pub batch_fee_input: BatchFeeInput, base_fee_per_gas: u64, base_system_contract_hashes: BaseSystemContractsHashes, protocol_version: ProtocolVersionId, From a58f7ae8efc83ecf92eb6017e36e09646b207fc7 Mon Sep 17 00:00:00 2001 From: Daniyar Itegulov Date: Fri, 13 Sep 2024 15:32:11 +1000 Subject: [PATCH 02/19] make `api_server` report open batch's fee input --- core/lib/dal/src/blocks_dal.rs | 26 ++++++++++++++++++++++++++ core/node/fee_model/src/lib.rs | 17 +++++------------ 2 files changed, 31 insertions(+), 12 deletions(-) diff --git a/core/lib/dal/src/blocks_dal.rs b/core/lib/dal/src/blocks_dal.rs index 2dbe41df8e46..28bf8364ef6c 100644 --- a/core/lib/dal/src/blocks_dal.rs +++ b/core/lib/dal/src/blocks_dal.rs @@ -908,6 +908,32 @@ impl BlocksDal<'_, '_> { Ok(()) } + pub async fn get_last_l1_batch_fee_input(&mut self) -> DalResult { + let row = sqlx::query!( + r#" + SELECT + l1_gas_price, + l2_fair_gas_price, + fair_pubdata_price + FROM + l1_batches + ORDER BY + number DESC + LIMIT + 1 + "# + ) + .instrument("get_last_l1_batch_fee_input") + .fetch_one(self.storage) + .await?; + + Ok(BatchFeeInput::pubdata_independent( + row.l1_gas_price as u64, + row.l2_fair_gas_price as u64, + row.fair_pubdata_price as u64, + )) + } + pub async fn get_last_sealed_l2_block_header(&mut self) -> DalResult> { let header = sqlx::query_as!( StorageL2BlockHeader, diff --git a/core/node/fee_model/src/lib.rs b/core/node/fee_model/src/lib.rs index fe4f6a27ce29..4f48e9ee5815 100644 --- a/core/node/fee_model/src/lib.rs +++ b/core/node/fee_model/src/lib.rs @@ -141,25 +141,18 @@ impl ApiFeeInputProvider { impl BatchFeeModelInputProvider for ApiFeeInputProvider { async fn get_batch_fee_input_scaled( &self, - l1_gas_price_scale_factor: f64, - l1_pubdata_price_scale_factor: f64, + _l1_gas_price_scale_factor: f64, + _l1_pubdata_price_scale_factor: f64, ) -> anyhow::Result { - let inner_input = self - .inner - .get_batch_fee_input_scaled(l1_gas_price_scale_factor, l1_pubdata_price_scale_factor) - .await - .context("cannot get batch fee input from base provider")?; - let last_l2_block_params = self + let batch_fee_input = self .connection_pool .connection_tagged("api_fee_input_provider") .await? .blocks_dal() - .get_last_sealed_l2_block_header() + .get_last_l1_batch_fee_input() .await?; - Ok(last_l2_block_params - .map(|header| inner_input.stricter(header.batch_fee_input)) - .unwrap_or(inner_input)) + Ok(batch_fee_input) } /// Returns the fee model parameters. From ccb1e64128210d3dac3b0d9026a2346461674c26 Mon Sep 17 00:00:00 2001 From: Daniyar Itegulov Date: Fri, 13 Sep 2024 16:15:04 +1000 Subject: [PATCH 03/19] fmt + lint --- core/lib/dal/src/models/storage_block.rs | 4 ++-- core/node/block_reverter/src/tests.rs | 5 +++-- core/node/fee_model/src/lib.rs | 1 - 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/core/lib/dal/src/models/storage_block.rs b/core/lib/dal/src/models/storage_block.rs index ee8e24859af7..59f0e6f01c7b 100644 --- a/core/lib/dal/src/models/storage_block.rs +++ b/core/lib/dal/src/models/storage_block.rs @@ -8,9 +8,9 @@ use zksync_types::{ api, block::{L1BatchHeader, L2BlockHeader, UnsealedL1BatchHeader}, commitment::{L1BatchMetaParameters, L1BatchMetadata}, - fee_model::{BatchFeeInput, L1PeggedBatchFeeModelInput, PubdataIndependentBatchFeeModelInput}, + fee_model::BatchFeeInput, l2_to_l1_log::{L2ToL1Log, SystemL2ToL1Log, UserL2ToL1Log}, - Address, Bloom, L1BatchNumber, L2BlockNumber, ProtocolVersionId, H256, + Address, Bloom, L1BatchNumber, L2BlockNumber, H256, }; /// This is the gas limit that was used inside blocks before we started saving block gas limit into the database. diff --git a/core/node/block_reverter/src/tests.rs b/core/node/block_reverter/src/tests.rs index aac9b425dd21..f6cbd7e55e92 100644 --- a/core/node/block_reverter/src/tests.rs +++ b/core/node/block_reverter/src/tests.rs @@ -2,7 +2,6 @@ use std::{collections::HashSet, sync::Mutex}; -use super::*; use assert_matches::assert_matches; use async_trait::async_trait; use test_casing::test_casing; @@ -11,13 +10,15 @@ use zksync_dal::Connection; use zksync_merkle_tree::TreeInstruction; use zksync_object_store::{Bucket, MockObjectStore}; use zksync_state::interface::ReadStorage; -use zksync_types::fee_model::BatchFeeInput; use zksync_types::{ block::{L1BatchHeader, L2BlockHeader}, + fee_model::BatchFeeInput, snapshots::SnapshotVersion, AccountTreeId, L2BlockNumber, ProtocolVersion, ProtocolVersionId, StorageKey, StorageLog, }; +use super::*; + fn gen_storage_logs() -> Vec { (0..10) .map(|i| { diff --git a/core/node/fee_model/src/lib.rs b/core/node/fee_model/src/lib.rs index 4f48e9ee5815..e6575f995d10 100644 --- a/core/node/fee_model/src/lib.rs +++ b/core/node/fee_model/src/lib.rs @@ -1,6 +1,5 @@ use std::{fmt, fmt::Debug, sync::Arc}; -use anyhow::Context as _; use async_trait::async_trait; use zksync_dal::{ConnectionPool, Core, CoreDal}; use zksync_types::{ From 9246e7e6f051f740738e3cb53a6ad2c28842d14f Mon Sep 17 00:00:00 2001 From: Daniyar Itegulov Date: Fri, 13 Sep 2024 16:51:25 +1000 Subject: [PATCH 04/19] add test --- core/node/fee_model/src/lib.rs | 42 +++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/core/node/fee_model/src/lib.rs b/core/node/fee_model/src/lib.rs index e6575f995d10..7fb60e6454c5 100644 --- a/core/node/fee_model/src/lib.rs +++ b/core/node/fee_model/src/lib.rs @@ -301,7 +301,10 @@ mod tests { use l1_gas_price::GasAdjusterClient; use zksync_config::{configs::eth_sender::PubdataSendingMode, GasAdjusterConfig}; use zksync_eth_client::{clients::MockSettlementLayer, BaseFees}; - use zksync_types::{commitment::L1BatchCommitmentMode, fee_model::BaseTokenConversionRatio}; + use zksync_types::{ + block::L1BatchHeader, commitment::L1BatchCommitmentMode, + fee_model::BaseTokenConversionRatio, L1BatchNumber, + }; use super::*; @@ -809,4 +812,41 @@ mod tests { .await .expect("Failed to create GasAdjuster") } + + #[tokio::test] + async fn test_take_fee_input_from_unsealed_batch() { + let sealed_batch_fee_input = BatchFeeInput::pubdata_independent(1, 2, 3); + let unsealed_batch_fee_input = BatchFeeInput::pubdata_independent(101, 102, 103); + + let pool = ConnectionPool::::test_pool().await; + let mut conn = pool.connection().await.unwrap(); + let l1_batch_header = L1BatchHeader { + number: L1BatchNumber(1), + timestamp: 1, + l1_tx_count: 0, + l2_tx_count: 0, + priority_ops_onchain_data: vec![], + l2_to_l1_logs: vec![], + l2_to_l1_messages: vec![], + bloom: Default::default(), + used_contract_hashes: vec![], + base_system_contracts_hashes: Default::default(), + system_logs: vec![], + protocol_version: None, + pubdata_input: None, + batch_fee_input: sealed_batch_fee_input, + }; + conn.blocks_dal() + .insert_mock_l1_batch(&l1_batch_header) + .await + .unwrap(); + conn.blocks_dal() + .insert_l1_batch(L1BatchNumber(2), 2, unsealed_batch_fee_input) + .await + .unwrap(); + let provider = + ApiFeeInputProvider::new(Arc::new(MockBatchFeeParamsProvider::default()), pool); + let fee_input = provider.get_batch_fee_input_scaled(1.0, 1.0).await.unwrap(); + assert_eq!(fee_input, unsealed_batch_fee_input); + } } From 0482421fc20352067bd635bd3906f593f166acfb Mon Sep 17 00:00:00 2001 From: Daniyar Itegulov Date: Fri, 13 Sep 2024 18:57:13 +1000 Subject: [PATCH 05/19] tweak the logic to rely on unsealed batches with a fallback --- ...138f12752acc992e0a9065c9c73b90a7aa4c.json} | 4 +-- core/lib/dal/src/blocks_dal.rs | 24 +++++++------ core/node/fee_model/src/lib.rs | 35 +++++++++++++++---- 3 files changed, 43 insertions(+), 20 deletions(-) rename core/lib/dal/.sqlx/{query-42fc6da4154f25fc711f194931b0613f921b0d9d99c1e0c219f05f8cfb5ad001.json => query-e3edcff8544b05ee2b2c58aa040b138f12752acc992e0a9065c9c73b90a7aa4c.json} (79%) diff --git a/core/lib/dal/.sqlx/query-42fc6da4154f25fc711f194931b0613f921b0d9d99c1e0c219f05f8cfb5ad001.json b/core/lib/dal/.sqlx/query-e3edcff8544b05ee2b2c58aa040b138f12752acc992e0a9065c9c73b90a7aa4c.json similarity index 79% rename from core/lib/dal/.sqlx/query-42fc6da4154f25fc711f194931b0613f921b0d9d99c1e0c219f05f8cfb5ad001.json rename to core/lib/dal/.sqlx/query-e3edcff8544b05ee2b2c58aa040b138f12752acc992e0a9065c9c73b90a7aa4c.json index af01e0671ac1..0039bf67e74b 100644 --- a/core/lib/dal/.sqlx/query-42fc6da4154f25fc711f194931b0613f921b0d9d99c1e0c219f05f8cfb5ad001.json +++ b/core/lib/dal/.sqlx/query-e3edcff8544b05ee2b2c58aa040b138f12752acc992e0a9065c9c73b90a7aa4c.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n l1_gas_price,\n l2_fair_gas_price,\n fair_pubdata_price\n FROM\n l1_batches\n ORDER BY\n number DESC\n LIMIT\n 1\n ", + "query": "\n SELECT\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": [ { @@ -28,5 +28,5 @@ false ] }, - "hash": "42fc6da4154f25fc711f194931b0613f921b0d9d99c1e0c219f05f8cfb5ad001" + "hash": "e3edcff8544b05ee2b2c58aa040b138f12752acc992e0a9065c9c73b90a7aa4c" } diff --git a/core/lib/dal/src/blocks_dal.rs b/core/lib/dal/src/blocks_dal.rs index 28bf8364ef6c..fa64bc878372 100644 --- a/core/lib/dal/src/blocks_dal.rs +++ b/core/lib/dal/src/blocks_dal.rs @@ -908,7 +908,7 @@ impl BlocksDal<'_, '_> { Ok(()) } - pub async fn get_last_l1_batch_fee_input(&mut self) -> DalResult { + pub async fn get_unsealed_l1_batch_fee_input(&mut self) -> DalResult> { let row = sqlx::query!( r#" SELECT @@ -917,21 +917,23 @@ impl BlocksDal<'_, '_> { fair_pubdata_price FROM l1_batches - ORDER BY - number DESC - LIMIT - 1 + WHERE + NOT is_sealed "# ) .instrument("get_last_l1_batch_fee_input") - .fetch_one(self.storage) + .fetch_optional(self.storage) .await?; - Ok(BatchFeeInput::pubdata_independent( - row.l1_gas_price as u64, - row.l2_fair_gas_price as u64, - row.fair_pubdata_price as u64, - )) + if let Some(row) = row { + Ok(Some(BatchFeeInput::pubdata_independent( + row.l1_gas_price as u64, + row.l2_fair_gas_price as u64, + row.fair_pubdata_price as u64, + ))) + } else { + Ok(None) + } } pub async fn get_last_sealed_l2_block_header(&mut self) -> DalResult> { diff --git a/core/node/fee_model/src/lib.rs b/core/node/fee_model/src/lib.rs index 7fb60e6454c5..d0ee685d08fd 100644 --- a/core/node/fee_model/src/lib.rs +++ b/core/node/fee_model/src/lib.rs @@ -1,5 +1,6 @@ use std::{fmt, fmt::Debug, sync::Arc}; +use anyhow::Context; use async_trait::async_trait; use zksync_dal::{ConnectionPool, Core, CoreDal}; use zksync_types::{ @@ -140,18 +141,38 @@ impl ApiFeeInputProvider { impl BatchFeeModelInputProvider for ApiFeeInputProvider { async fn get_batch_fee_input_scaled( &self, - _l1_gas_price_scale_factor: f64, - _l1_pubdata_price_scale_factor: f64, + l1_gas_price_scale_factor: f64, + l1_pubdata_price_scale_factor: f64, ) -> anyhow::Result { - let batch_fee_input = self + if let Some(batch_fee_input) = self .connection_pool .connection_tagged("api_fee_input_provider") .await? .blocks_dal() - .get_last_l1_batch_fee_input() - .await?; - - Ok(batch_fee_input) + .get_unsealed_l1_batch_fee_input() + .await? + { + Ok(batch_fee_input) + } else { + let inner_input = self + .inner + .get_batch_fee_input_scaled( + l1_gas_price_scale_factor, + l1_pubdata_price_scale_factor, + ) + .await + .context("cannot get batch fee input from base provider")?; + let last_l2_block_params = self + .connection_pool + .connection_tagged("api_fee_input_provider") + .await? + .blocks_dal() + .get_last_sealed_l2_block_header() + .await?; + Ok(last_l2_block_params + .map(|header| inner_input.stricter(header.batch_fee_input)) + .unwrap_or(inner_input)) + } } /// Returns the fee model parameters. From 6fd7c946efbb72cd22ded2fdbd036480dee95519 Mon Sep 17 00:00:00 2001 From: Daniyar Itegulov Date: Wed, 16 Oct 2024 12:33:31 +1100 Subject: [PATCH 06/19] fix compilation issues after rebase --- ...83f078e7e7967bab5612052b317e61dcadff.json} | 27 ++++++------------ ...e40c0eb18083b0e69cf1def2bca5fec0cedf.json} | 27 ++++++------------ ...f613991ce348081b2b698376f59efc2bc694.json} | 27 ++++++------------ ...b3f11231e6a8b9f14a4e0b3b7a7ab51e77e0.json} | 27 ++++++------------ ...db4854dfe4a77877d6ba311ad84abbde17fa.json} | 28 ++++++------------- ...33d22c94aa47b7a8863da2afa5ab1a8502bf.json} | 27 ++++++------------ ...e9505be5b57f96bf9a8f9cab28d3b3e2d807.json} | 27 ++++++------------ ...558a7b5a8b155acf41c4ac92536a94c49f0b.json} | 27 ++++++------------ ...26bbcaea65b3499c9aff3a42dbd4e66aff7f.json} | 27 ++++++------------ ...76fb01e6629e8c982c265f2af1d5000090572.json | 20 ------------- core/lib/dal/src/models/storage_block.rs | 2 +- core/node/fee_model/src/lib.rs | 15 ++++++++-- 12 files changed, 85 insertions(+), 196 deletions(-) rename core/lib/dal/.sqlx/{query-f30748bef5f8d08b60739cdfd9508c8132d0958e4e25f4954e93d2095b4f11e8.json => query-0440d673c832f5e0706bf8c527c183f078e7e7967bab5612052b317e61dcadff.json} (55%) rename core/lib/dal/.sqlx/{query-e2d0bd978f76e0ce09b36b0e4b0a2baec4b2531ecaa8da234863e2eb810761c7.json => query-06cca389c6fd4bef75c18e5d65d9e40c0eb18083b0e69cf1def2bca5fec0cedf.json} (62%) rename core/lib/dal/.sqlx/{query-5aa487a98dff53a5d32a5916a26cbf3ffb03b3791c0e9a9f39fb85cfffc65db2.json => query-101500cfc0fe0bb7c0645d48735ef613991ce348081b2b698376f59efc2bc694.json} (65%) rename core/lib/dal/.sqlx/{query-2def67eb8372245ed59e76e07d615598f5d22a3aebd893afddded0e3c6b94a3b.json => query-153f7935c209d718eb10c06c82d0b3f11231e6a8b9f14a4e0b3b7a7ab51e77e0.json} (56%) rename core/lib/dal/.sqlx/{query-0784f2cc13f85763cc7da29902850fa76a03907957b7a0d87ea55a7873f3312e.json => query-2a440d1650ade18b57f5133060f0db4854dfe4a77877d6ba311ad84abbde17fa.json} (63%) rename core/lib/dal/.sqlx/{query-4e994d519b9c75e64a74423f8c19fbde6eb6634d7a63005081ffc1eb6c28e9ec.json => query-54f41fccbe8c100015ccf4d87e0e33d22c94aa47b7a8863da2afa5ab1a8502bf.json} (58%) rename core/lib/dal/.sqlx/{query-7aebc0d8eb43bd835c4f175edc4c0371bdc118b25d64fcf526bd6575e4d675c8.json => query-94e96a05c007c08251589d119d47e9505be5b57f96bf9a8f9cab28d3b3e2d807.json} (62%) rename core/lib/dal/.sqlx/{query-942d6d948770c374ba4d3566c50e56e43137ac0cf45312d70dec0c407cadc1bf.json => query-9d15617462abf24dde82444482d4558a7b5a8b155acf41c4ac92536a94c49f0b.json} (51%) rename core/lib/dal/.sqlx/{query-b456147560b107640abdc10f7ac76b563ff2f0f3a818e8c8a02c2ef632d0b960.json => query-b006720c989bd289181d6398775726bbcaea65b3499c9aff3a42dbd4e66aff7f.json} (63%) delete mode 100644 core/lib/dal/.sqlx/query-dc16d0fac093a52480b66dfcb5976fb01e6629e8c982c265f2af1d5000090572.json diff --git a/core/lib/dal/.sqlx/query-f30748bef5f8d08b60739cdfd9508c8132d0958e4e25f4954e93d2095b4f11e8.json b/core/lib/dal/.sqlx/query-0440d673c832f5e0706bf8c527c183f078e7e7967bab5612052b317e61dcadff.json similarity index 55% rename from core/lib/dal/.sqlx/query-f30748bef5f8d08b60739cdfd9508c8132d0958e4e25f4954e93d2095b4f11e8.json rename to core/lib/dal/.sqlx/query-0440d673c832f5e0706bf8c527c183f078e7e7967bab5612052b317e61dcadff.json index b36c89dc42fe..de28bde4a0dc 100644 --- a/core/lib/dal/.sqlx/query-f30748bef5f8d08b60739cdfd9508c8132d0958e4e25f4954e93d2095b4f11e8.json +++ b/core/lib/dal/.sqlx/query-0440d673c832f5e0706bf8c527c183f078e7e7967bab5612052b317e61dcadff.json @@ -1,10 +1,6 @@ { "db_name": "PostgreSQL", -<<<<<<<< HEAD:core/lib/dal/.sqlx/query-f30748bef5f8d08b60739cdfd9508c8132d0958e4e25f4954e93d2095b4f11e8.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 ", -======== - "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 l1_gas_price,\n l2_fair_gas_price,\n fair_pubdata_price\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 ", ->>>>>>>> 82ed8f925 (add `BatchFeeInput` to L1 batch models):core/lib/dal/.sqlx/query-fdfa11130c12d0a57b28eb3f0ecaeb46303a5c35d14b31fdaac3ce5099390150.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 l1_gas_price,\n l2_fair_gas_price,\n fair_pubdata_price\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,25 +139,24 @@ "type_info": "Bytea" }, { -<<<<<<<< HEAD:core/lib/dal/.sqlx/query-f30748bef5f8d08b60739cdfd9508c8132d0958e4e25f4954e93d2095b4f11e8.json "ordinal": 27, "name": "fee_address", "type_info": "Bytea" -======== - "ordinal": 26, + }, + { + "ordinal": 28, "name": "l1_gas_price", "type_info": "Int8" }, { - "ordinal": 27, + "ordinal": 29, "name": "l2_fair_gas_price", "type_info": "Int8" }, { - "ordinal": 28, + "ordinal": 30, "name": "fair_pubdata_price", "type_info": "Int8" ->>>>>>>> 82ed8f925 (add `BatchFeeInput` to L1 batch models):core/lib/dal/.sqlx/query-fdfa11130c12d0a57b28eb3f0ecaeb46303a5c35d14b31fdaac3ce5099390150.json } ], "parameters": { @@ -198,17 +193,11 @@ true, true, true, -<<<<<<<< HEAD:core/lib/dal/.sqlx/query-f30748bef5f8d08b60739cdfd9508c8132d0958e4e25f4954e93d2095b4f11e8.json - false - ] - }, - "hash": "f30748bef5f8d08b60739cdfd9508c8132d0958e4e25f4954e93d2095b4f11e8" -======== + false, false, false, false ] }, - "hash": "fdfa11130c12d0a57b28eb3f0ecaeb46303a5c35d14b31fdaac3ce5099390150" ->>>>>>>> 82ed8f925 (add `BatchFeeInput` to L1 batch models):core/lib/dal/.sqlx/query-fdfa11130c12d0a57b28eb3f0ecaeb46303a5c35d14b31fdaac3ce5099390150.json + "hash": "0440d673c832f5e0706bf8c527c183f078e7e7967bab5612052b317e61dcadff" } diff --git a/core/lib/dal/.sqlx/query-e2d0bd978f76e0ce09b36b0e4b0a2baec4b2531ecaa8da234863e2eb810761c7.json b/core/lib/dal/.sqlx/query-06cca389c6fd4bef75c18e5d65d9e40c0eb18083b0e69cf1def2bca5fec0cedf.json similarity index 62% rename from core/lib/dal/.sqlx/query-e2d0bd978f76e0ce09b36b0e4b0a2baec4b2531ecaa8da234863e2eb810761c7.json rename to core/lib/dal/.sqlx/query-06cca389c6fd4bef75c18e5d65d9e40c0eb18083b0e69cf1def2bca5fec0cedf.json index 1339e6f720f0..4ddd157ca6d4 100644 --- a/core/lib/dal/.sqlx/query-e2d0bd978f76e0ce09b36b0e4b0a2baec4b2531ecaa8da234863e2eb810761c7.json +++ b/core/lib/dal/.sqlx/query-06cca389c6fd4bef75c18e5d65d9e40c0eb18083b0e69cf1def2bca5fec0cedf.json @@ -1,10 +1,6 @@ { "db_name": "PostgreSQL", -<<<<<<<< HEAD:core/lib/dal/.sqlx/query-e2d0bd978f76e0ce09b36b0e4b0a2baec4b2531ecaa8da234863e2eb810761c7.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 ", -======== - "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 l1_gas_price,\n l2_fair_gas_price,\n fair_pubdata_price\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 ", ->>>>>>>> 82ed8f925 (add `BatchFeeInput` to L1 batch models):core/lib/dal/.sqlx/query-d0b4e82926bf07b0b7d59a1017a076b128bcd493c4e883519ea08806353a645c.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 l1_gas_price,\n l2_fair_gas_price,\n fair_pubdata_price\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,25 +139,24 @@ "type_info": "Bytea" }, { -<<<<<<<< HEAD:core/lib/dal/.sqlx/query-e2d0bd978f76e0ce09b36b0e4b0a2baec4b2531ecaa8da234863e2eb810761c7.json "ordinal": 27, "name": "fee_address", "type_info": "Bytea" -======== - "ordinal": 26, + }, + { + "ordinal": 28, "name": "l1_gas_price", "type_info": "Int8" }, { - "ordinal": 27, + "ordinal": 29, "name": "l2_fair_gas_price", "type_info": "Int8" }, { - "ordinal": 28, + "ordinal": 30, "name": "fair_pubdata_price", "type_info": "Int8" ->>>>>>>> 82ed8f925 (add `BatchFeeInput` to L1 batch models):core/lib/dal/.sqlx/query-d0b4e82926bf07b0b7d59a1017a076b128bcd493c4e883519ea08806353a645c.json } ], "parameters": { @@ -199,17 +194,11 @@ true, true, true, -<<<<<<<< HEAD:core/lib/dal/.sqlx/query-e2d0bd978f76e0ce09b36b0e4b0a2baec4b2531ecaa8da234863e2eb810761c7.json - false - ] - }, - "hash": "e2d0bd978f76e0ce09b36b0e4b0a2baec4b2531ecaa8da234863e2eb810761c7" -======== + false, false, false, false ] }, - "hash": "d0b4e82926bf07b0b7d59a1017a076b128bcd493c4e883519ea08806353a645c" ->>>>>>>> 82ed8f925 (add `BatchFeeInput` to L1 batch models):core/lib/dal/.sqlx/query-d0b4e82926bf07b0b7d59a1017a076b128bcd493c4e883519ea08806353a645c.json + "hash": "06cca389c6fd4bef75c18e5d65d9e40c0eb18083b0e69cf1def2bca5fec0cedf" } diff --git a/core/lib/dal/.sqlx/query-5aa487a98dff53a5d32a5916a26cbf3ffb03b3791c0e9a9f39fb85cfffc65db2.json b/core/lib/dal/.sqlx/query-101500cfc0fe0bb7c0645d48735ef613991ce348081b2b698376f59efc2bc694.json similarity index 65% rename from core/lib/dal/.sqlx/query-5aa487a98dff53a5d32a5916a26cbf3ffb03b3791c0e9a9f39fb85cfffc65db2.json rename to core/lib/dal/.sqlx/query-101500cfc0fe0bb7c0645d48735ef613991ce348081b2b698376f59efc2bc694.json index e1015e0f0751..6129d4ddf3a7 100644 --- a/core/lib/dal/.sqlx/query-5aa487a98dff53a5d32a5916a26cbf3ffb03b3791c0e9a9f39fb85cfffc65db2.json +++ b/core/lib/dal/.sqlx/query-101500cfc0fe0bb7c0645d48735ef613991ce348081b2b698376f59efc2bc694.json @@ -1,10 +1,6 @@ { "db_name": "PostgreSQL", -<<<<<<<< HEAD:core/lib/dal/.sqlx/query-5aa487a98dff53a5d32a5916a26cbf3ffb03b3791c0e9a9f39fb85cfffc65db2.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 ", -======== - "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 l1_gas_price,\n l2_fair_gas_price,\n fair_pubdata_price\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 ", ->>>>>>>> 82ed8f925 (add `BatchFeeInput` to L1 batch models):core/lib/dal/.sqlx/query-800e8c07f46f023aeab1e5829664bbcec6fa1cf147131d05ad065003773a57d6.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 l1_gas_price,\n l2_fair_gas_price,\n fair_pubdata_price\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,25 +139,24 @@ "type_info": "Bytea" }, { -<<<<<<<< HEAD:core/lib/dal/.sqlx/query-5aa487a98dff53a5d32a5916a26cbf3ffb03b3791c0e9a9f39fb85cfffc65db2.json "ordinal": 27, "name": "fee_address", "type_info": "Bytea" -======== - "ordinal": 26, + }, + { + "ordinal": 28, "name": "l1_gas_price", "type_info": "Int8" }, { - "ordinal": 27, + "ordinal": 29, "name": "l2_fair_gas_price", "type_info": "Int8" }, { - "ordinal": 28, + "ordinal": 30, "name": "fair_pubdata_price", "type_info": "Int8" ->>>>>>>> 82ed8f925 (add `BatchFeeInput` to L1 batch models):core/lib/dal/.sqlx/query-800e8c07f46f023aeab1e5829664bbcec6fa1cf147131d05ad065003773a57d6.json } ], "parameters": { @@ -197,17 +192,11 @@ true, true, true, -<<<<<<<< HEAD:core/lib/dal/.sqlx/query-5aa487a98dff53a5d32a5916a26cbf3ffb03b3791c0e9a9f39fb85cfffc65db2.json - false - ] - }, - "hash": "5aa487a98dff53a5d32a5916a26cbf3ffb03b3791c0e9a9f39fb85cfffc65db2" -======== + false, false, false, false ] }, - "hash": "800e8c07f46f023aeab1e5829664bbcec6fa1cf147131d05ad065003773a57d6" ->>>>>>>> 82ed8f925 (add `BatchFeeInput` to L1 batch models):core/lib/dal/.sqlx/query-800e8c07f46f023aeab1e5829664bbcec6fa1cf147131d05ad065003773a57d6.json + "hash": "101500cfc0fe0bb7c0645d48735ef613991ce348081b2b698376f59efc2bc694" } diff --git a/core/lib/dal/.sqlx/query-2def67eb8372245ed59e76e07d615598f5d22a3aebd893afddded0e3c6b94a3b.json b/core/lib/dal/.sqlx/query-153f7935c209d718eb10c06c82d0b3f11231e6a8b9f14a4e0b3b7a7ab51e77e0.json similarity index 56% rename from core/lib/dal/.sqlx/query-2def67eb8372245ed59e76e07d615598f5d22a3aebd893afddded0e3c6b94a3b.json rename to core/lib/dal/.sqlx/query-153f7935c209d718eb10c06c82d0b3f11231e6a8b9f14a4e0b3b7a7ab51e77e0.json index e2d9f8044d84..3a06b10ea6a0 100644 --- a/core/lib/dal/.sqlx/query-2def67eb8372245ed59e76e07d615598f5d22a3aebd893afddded0e3c6b94a3b.json +++ b/core/lib/dal/.sqlx/query-153f7935c209d718eb10c06c82d0b3f11231e6a8b9f14a4e0b3b7a7ab51e77e0.json @@ -1,10 +1,6 @@ { "db_name": "PostgreSQL", -<<<<<<<< HEAD:core/lib/dal/.sqlx/query-2def67eb8372245ed59e76e07d615598f5d22a3aebd893afddded0e3c6b94a3b.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 ", -======== - "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 l1_gas_price,\n l2_fair_gas_price,\n fair_pubdata_price\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 ", ->>>>>>>> 82ed8f925 (add `BatchFeeInput` to L1 batch models):core/lib/dal/.sqlx/query-63aa749a4a36711a5f58a0249dc475897bd7ee735707541571c694615df5ccf4.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 l1_gas_price,\n l2_fair_gas_price,\n fair_pubdata_price\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,25 +139,24 @@ "type_info": "Bytea" }, { -<<<<<<<< HEAD:core/lib/dal/.sqlx/query-2def67eb8372245ed59e76e07d615598f5d22a3aebd893afddded0e3c6b94a3b.json "ordinal": 27, "name": "fee_address", "type_info": "Bytea" -======== - "ordinal": 26, + }, + { + "ordinal": 28, "name": "l1_gas_price", "type_info": "Int8" }, { - "ordinal": 27, + "ordinal": 29, "name": "l2_fair_gas_price", "type_info": "Int8" }, { - "ordinal": 28, + "ordinal": 30, "name": "fair_pubdata_price", "type_info": "Int8" ->>>>>>>> 82ed8f925 (add `BatchFeeInput` to L1 batch models):core/lib/dal/.sqlx/query-63aa749a4a36711a5f58a0249dc475897bd7ee735707541571c694615df5ccf4.json } ], "parameters": { @@ -200,17 +195,11 @@ true, true, true, -<<<<<<<< HEAD:core/lib/dal/.sqlx/query-2def67eb8372245ed59e76e07d615598f5d22a3aebd893afddded0e3c6b94a3b.json - false - ] - }, - "hash": "2def67eb8372245ed59e76e07d615598f5d22a3aebd893afddded0e3c6b94a3b" -======== + false, false, false, false ] }, - "hash": "63aa749a4a36711a5f58a0249dc475897bd7ee735707541571c694615df5ccf4" ->>>>>>>> 82ed8f925 (add `BatchFeeInput` to L1 batch models):core/lib/dal/.sqlx/query-63aa749a4a36711a5f58a0249dc475897bd7ee735707541571c694615df5ccf4.json + "hash": "153f7935c209d718eb10c06c82d0b3f11231e6a8b9f14a4e0b3b7a7ab51e77e0" } diff --git a/core/lib/dal/.sqlx/query-0784f2cc13f85763cc7da29902850fa76a03907957b7a0d87ea55a7873f3312e.json b/core/lib/dal/.sqlx/query-2a440d1650ade18b57f5133060f0db4854dfe4a77877d6ba311ad84abbde17fa.json similarity index 63% rename from core/lib/dal/.sqlx/query-0784f2cc13f85763cc7da29902850fa76a03907957b7a0d87ea55a7873f3312e.json rename to core/lib/dal/.sqlx/query-2a440d1650ade18b57f5133060f0db4854dfe4a77877d6ba311ad84abbde17fa.json index 715efb47f595..c2105797e870 100644 --- a/core/lib/dal/.sqlx/query-0784f2cc13f85763cc7da29902850fa76a03907957b7a0d87ea55a7873f3312e.json +++ b/core/lib/dal/.sqlx/query-2a440d1650ade18b57f5133060f0db4854dfe4a77877d6ba311ad84abbde17fa.json @@ -1,10 +1,6 @@ { "db_name": "PostgreSQL", -<<<<<<<< HEAD:core/lib/dal/.sqlx/query-0784f2cc13f85763cc7da29902850fa76a03907957b7a0d87ea55a7873f3312e.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 ", -======== - "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 l1_gas_price,\n l2_fair_gas_price,\n fair_pubdata_price\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 ", ->>>>>>>> 82ed8f925 (add `BatchFeeInput` to L1 batch models):core/lib/dal/.sqlx/query-de4a9c26a4a86d35a055b1c5c97d2262d4918c2226996c258c9cfe5127b71560.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 l1_gas_price,\n l2_fair_gas_price,\n fair_pubdata_price\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,25 +139,24 @@ "type_info": "Bytea" }, { -<<<<<<<< HEAD:core/lib/dal/.sqlx/query-0784f2cc13f85763cc7da29902850fa76a03907957b7a0d87ea55a7873f3312e.json "ordinal": 27, "name": "fee_address", "type_info": "Bytea" -======== - "ordinal": 26, + }, + { + "ordinal": 28, "name": "l1_gas_price", "type_info": "Int8" }, { - "ordinal": 27, + "ordinal": 29, "name": "l2_fair_gas_price", "type_info": "Int8" }, { - "ordinal": 28, + "ordinal": 30, "name": "fair_pubdata_price", "type_info": "Int8" ->>>>>>>> 82ed8f925 (add `BatchFeeInput` to L1 batch models):core/lib/dal/.sqlx/query-de4a9c26a4a86d35a055b1c5c97d2262d4918c2226996c258c9cfe5127b71560.json } ], "parameters": { @@ -197,18 +192,11 @@ true, true, true, -<<<<<<<< HEAD:core/lib/dal/.sqlx/query-0784f2cc13f85763cc7da29902850fa76a03907957b7a0d87ea55a7873f3312e.json - false - ] - }, - "hash": "0784f2cc13f85763cc7da29902850fa76a03907957b7a0d87ea55a7873f3312e" -======== - true, + false, false, false, false ] }, - "hash": "de4a9c26a4a86d35a055b1c5c97d2262d4918c2226996c258c9cfe5127b71560" ->>>>>>>> 82ed8f925 (add `BatchFeeInput` to L1 batch models):core/lib/dal/.sqlx/query-de4a9c26a4a86d35a055b1c5c97d2262d4918c2226996c258c9cfe5127b71560.json + "hash": "2a440d1650ade18b57f5133060f0db4854dfe4a77877d6ba311ad84abbde17fa" } diff --git a/core/lib/dal/.sqlx/query-4e994d519b9c75e64a74423f8c19fbde6eb6634d7a63005081ffc1eb6c28e9ec.json b/core/lib/dal/.sqlx/query-54f41fccbe8c100015ccf4d87e0e33d22c94aa47b7a8863da2afa5ab1a8502bf.json similarity index 58% rename from core/lib/dal/.sqlx/query-4e994d519b9c75e64a74423f8c19fbde6eb6634d7a63005081ffc1eb6c28e9ec.json rename to core/lib/dal/.sqlx/query-54f41fccbe8c100015ccf4d87e0e33d22c94aa47b7a8863da2afa5ab1a8502bf.json index 07335e8e57c6..2cdfad08c830 100644 --- a/core/lib/dal/.sqlx/query-4e994d519b9c75e64a74423f8c19fbde6eb6634d7a63005081ffc1eb6c28e9ec.json +++ b/core/lib/dal/.sqlx/query-54f41fccbe8c100015ccf4d87e0e33d22c94aa47b7a8863da2afa5ab1a8502bf.json @@ -1,10 +1,6 @@ { "db_name": "PostgreSQL", -<<<<<<<< HEAD:core/lib/dal/.sqlx/query-4e994d519b9c75e64a74423f8c19fbde6eb6634d7a63005081ffc1eb6c28e9ec.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 ", -======== - "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 l1_gas_price,\n l2_fair_gas_price,\n fair_pubdata_price\n FROM\n l1_batches\n WHERE\n is_sealed\n AND number = $1\n ", ->>>>>>>> 82ed8f925 (add `BatchFeeInput` to L1 batch models):core/lib/dal/.sqlx/query-23ab5c3751fc0187cc2d7acd8a8861181be4c70cfff7c44b2b4fc2f0fbf34db7.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 l1_gas_price,\n l2_fair_gas_price,\n fair_pubdata_price\n FROM\n l1_batches\n WHERE\n is_sealed\n AND number = $1\n ", "describe": { "columns": [ { @@ -78,25 +74,24 @@ "type_info": "Bytea" }, { -<<<<<<<< HEAD:core/lib/dal/.sqlx/query-4e994d519b9c75e64a74423f8c19fbde6eb6634d7a63005081ffc1eb6c28e9ec.json "ordinal": 14, "name": "fee_address", "type_info": "Bytea" -======== - "ordinal": 13, + }, + { + "ordinal": 15, "name": "l1_gas_price", "type_info": "Int8" }, { - "ordinal": 14, + "ordinal": 16, "name": "l2_fair_gas_price", "type_info": "Int8" }, { - "ordinal": 15, + "ordinal": 17, "name": "fair_pubdata_price", "type_info": "Int8" ->>>>>>>> 82ed8f925 (add `BatchFeeInput` to L1 batch models):core/lib/dal/.sqlx/query-23ab5c3751fc0187cc2d7acd8a8861181be4c70cfff7c44b2b4fc2f0fbf34db7.json } ], "parameters": { @@ -119,17 +114,11 @@ true, false, true, -<<<<<<<< HEAD:core/lib/dal/.sqlx/query-4e994d519b9c75e64a74423f8c19fbde6eb6634d7a63005081ffc1eb6c28e9ec.json - false - ] - }, - "hash": "4e994d519b9c75e64a74423f8c19fbde6eb6634d7a63005081ffc1eb6c28e9ec" -======== + false, false, false, false ] }, - "hash": "23ab5c3751fc0187cc2d7acd8a8861181be4c70cfff7c44b2b4fc2f0fbf34db7" ->>>>>>>> 82ed8f925 (add `BatchFeeInput` to L1 batch models):core/lib/dal/.sqlx/query-23ab5c3751fc0187cc2d7acd8a8861181be4c70cfff7c44b2b4fc2f0fbf34db7.json + "hash": "54f41fccbe8c100015ccf4d87e0e33d22c94aa47b7a8863da2afa5ab1a8502bf" } diff --git a/core/lib/dal/.sqlx/query-7aebc0d8eb43bd835c4f175edc4c0371bdc118b25d64fcf526bd6575e4d675c8.json b/core/lib/dal/.sqlx/query-94e96a05c007c08251589d119d47e9505be5b57f96bf9a8f9cab28d3b3e2d807.json similarity index 62% rename from core/lib/dal/.sqlx/query-7aebc0d8eb43bd835c4f175edc4c0371bdc118b25d64fcf526bd6575e4d675c8.json rename to core/lib/dal/.sqlx/query-94e96a05c007c08251589d119d47e9505be5b57f96bf9a8f9cab28d3b3e2d807.json index 9e4ef4905f05..d9d6c6753ddd 100644 --- a/core/lib/dal/.sqlx/query-7aebc0d8eb43bd835c4f175edc4c0371bdc118b25d64fcf526bd6575e4d675c8.json +++ b/core/lib/dal/.sqlx/query-94e96a05c007c08251589d119d47e9505be5b57f96bf9a8f9cab28d3b3e2d807.json @@ -1,10 +1,6 @@ { "db_name": "PostgreSQL", -<<<<<<<< HEAD:core/lib/dal/.sqlx/query-7aebc0d8eb43bd835c4f175edc4c0371bdc118b25d64fcf526bd6575e4d675c8.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 ", -======== - "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 l1_gas_price,\n l2_fair_gas_price,\n fair_pubdata_price\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 ", ->>>>>>>> 82ed8f925 (add `BatchFeeInput` to L1 batch models):core/lib/dal/.sqlx/query-ea5e8c520c416063b70a62b4380f36331312400eef9957e9ef896a66dedb64bf.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 l1_gas_price,\n l2_fair_gas_price,\n fair_pubdata_price\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,25 +139,24 @@ "type_info": "Bytea" }, { -<<<<<<<< HEAD:core/lib/dal/.sqlx/query-7aebc0d8eb43bd835c4f175edc4c0371bdc118b25d64fcf526bd6575e4d675c8.json "ordinal": 27, "name": "fee_address", "type_info": "Bytea" -======== - "ordinal": 26, + }, + { + "ordinal": 28, "name": "l1_gas_price", "type_info": "Int8" }, { - "ordinal": 27, + "ordinal": 29, "name": "l2_fair_gas_price", "type_info": "Int8" }, { - "ordinal": 28, + "ordinal": 30, "name": "fair_pubdata_price", "type_info": "Int8" ->>>>>>>> 82ed8f925 (add `BatchFeeInput` to L1 batch models):core/lib/dal/.sqlx/query-ea5e8c520c416063b70a62b4380f36331312400eef9957e9ef896a66dedb64bf.json } ], "parameters": { @@ -195,17 +190,11 @@ true, true, true, -<<<<<<<< HEAD:core/lib/dal/.sqlx/query-7aebc0d8eb43bd835c4f175edc4c0371bdc118b25d64fcf526bd6575e4d675c8.json - false - ] - }, - "hash": "7aebc0d8eb43bd835c4f175edc4c0371bdc118b25d64fcf526bd6575e4d675c8" -======== + false, false, false, false ] }, - "hash": "ea5e8c520c416063b70a62b4380f36331312400eef9957e9ef896a66dedb64bf" ->>>>>>>> 82ed8f925 (add `BatchFeeInput` to L1 batch models):core/lib/dal/.sqlx/query-ea5e8c520c416063b70a62b4380f36331312400eef9957e9ef896a66dedb64bf.json + "hash": "94e96a05c007c08251589d119d47e9505be5b57f96bf9a8f9cab28d3b3e2d807" } diff --git a/core/lib/dal/.sqlx/query-942d6d948770c374ba4d3566c50e56e43137ac0cf45312d70dec0c407cadc1bf.json b/core/lib/dal/.sqlx/query-9d15617462abf24dde82444482d4558a7b5a8b155acf41c4ac92536a94c49f0b.json similarity index 51% rename from core/lib/dal/.sqlx/query-942d6d948770c374ba4d3566c50e56e43137ac0cf45312d70dec0c407cadc1bf.json rename to core/lib/dal/.sqlx/query-9d15617462abf24dde82444482d4558a7b5a8b155acf41c4ac92536a94c49f0b.json index c2bd556033e8..3cf07030031e 100644 --- a/core/lib/dal/.sqlx/query-942d6d948770c374ba4d3566c50e56e43137ac0cf45312d70dec0c407cadc1bf.json +++ b/core/lib/dal/.sqlx/query-9d15617462abf24dde82444482d4558a7b5a8b155acf41c4ac92536a94c49f0b.json @@ -1,10 +1,6 @@ { "db_name": "PostgreSQL", -<<<<<<<< HEAD:core/lib/dal/.sqlx/query-942d6d948770c374ba4d3566c50e56e43137ac0cf45312d70dec0c407cadc1bf.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 ", -======== - "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 l1_gas_price,\n l2_fair_gas_price,\n fair_pubdata_price\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 ", ->>>>>>>> 82ed8f925 (add `BatchFeeInput` to L1 batch models):core/lib/dal/.sqlx/query-793a46ca0c51cada16596d58797b6c50b04a0c033bf5375e22132b4490789f4d.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 l1_gas_price,\n l2_fair_gas_price,\n fair_pubdata_price\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,25 +139,24 @@ "type_info": "Bytea" }, { -<<<<<<<< HEAD:core/lib/dal/.sqlx/query-942d6d948770c374ba4d3566c50e56e43137ac0cf45312d70dec0c407cadc1bf.json "ordinal": 27, "name": "fee_address", "type_info": "Bytea" -======== - "ordinal": 26, + }, + { + "ordinal": 28, "name": "l1_gas_price", "type_info": "Int8" }, { - "ordinal": 27, + "ordinal": 29, "name": "l2_fair_gas_price", "type_info": "Int8" }, { - "ordinal": 28, + "ordinal": 30, "name": "fair_pubdata_price", "type_info": "Int8" ->>>>>>>> 82ed8f925 (add `BatchFeeInput` to L1 batch models):core/lib/dal/.sqlx/query-793a46ca0c51cada16596d58797b6c50b04a0c033bf5375e22132b4490789f4d.json } ], "parameters": { @@ -201,17 +196,11 @@ true, true, true, -<<<<<<<< HEAD:core/lib/dal/.sqlx/query-942d6d948770c374ba4d3566c50e56e43137ac0cf45312d70dec0c407cadc1bf.json - false - ] - }, - "hash": "942d6d948770c374ba4d3566c50e56e43137ac0cf45312d70dec0c407cadc1bf" -======== + false, false, false, false ] }, - "hash": "793a46ca0c51cada16596d58797b6c50b04a0c033bf5375e22132b4490789f4d" ->>>>>>>> 82ed8f925 (add `BatchFeeInput` to L1 batch models):core/lib/dal/.sqlx/query-793a46ca0c51cada16596d58797b6c50b04a0c033bf5375e22132b4490789f4d.json + "hash": "9d15617462abf24dde82444482d4558a7b5a8b155acf41c4ac92536a94c49f0b" } diff --git a/core/lib/dal/.sqlx/query-b456147560b107640abdc10f7ac76b563ff2f0f3a818e8c8a02c2ef632d0b960.json b/core/lib/dal/.sqlx/query-b006720c989bd289181d6398775726bbcaea65b3499c9aff3a42dbd4e66aff7f.json similarity index 63% rename from core/lib/dal/.sqlx/query-b456147560b107640abdc10f7ac76b563ff2f0f3a818e8c8a02c2ef632d0b960.json rename to core/lib/dal/.sqlx/query-b006720c989bd289181d6398775726bbcaea65b3499c9aff3a42dbd4e66aff7f.json index 8b2e2d1bb220..7850462642e4 100644 --- a/core/lib/dal/.sqlx/query-b456147560b107640abdc10f7ac76b563ff2f0f3a818e8c8a02c2ef632d0b960.json +++ b/core/lib/dal/.sqlx/query-b006720c989bd289181d6398775726bbcaea65b3499c9aff3a42dbd4e66aff7f.json @@ -1,10 +1,6 @@ { "db_name": "PostgreSQL", -<<<<<<<< HEAD:core/lib/dal/.sqlx/query-b456147560b107640abdc10f7ac76b563ff2f0f3a818e8c8a02c2ef632d0b960.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 ", -======== - "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 l1_gas_price,\n l2_fair_gas_price,\n fair_pubdata_price\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 ", ->>>>>>>> 82ed8f925 (add `BatchFeeInput` to L1 batch models):core/lib/dal/.sqlx/query-f3a1a12fd9e3fef3f9fbcc24a56545da1ffa0813f79362ce4665b44c1c765fa0.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 l1_gas_price,\n l2_fair_gas_price,\n fair_pubdata_price\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,25 +139,24 @@ "type_info": "Bytea" }, { -<<<<<<<< HEAD:core/lib/dal/.sqlx/query-b456147560b107640abdc10f7ac76b563ff2f0f3a818e8c8a02c2ef632d0b960.json "ordinal": 27, "name": "fee_address", "type_info": "Bytea" -======== - "ordinal": 26, + }, + { + "ordinal": 28, "name": "l1_gas_price", "type_info": "Int8" }, { - "ordinal": 27, + "ordinal": 29, "name": "l2_fair_gas_price", "type_info": "Int8" }, { - "ordinal": 28, + "ordinal": 30, "name": "fair_pubdata_price", "type_info": "Int8" ->>>>>>>> 82ed8f925 (add `BatchFeeInput` to L1 batch models):core/lib/dal/.sqlx/query-f3a1a12fd9e3fef3f9fbcc24a56545da1ffa0813f79362ce4665b44c1c765fa0.json } ], "parameters": { @@ -196,18 +191,12 @@ true, true, true, -<<<<<<<< HEAD:core/lib/dal/.sqlx/query-b456147560b107640abdc10f7ac76b563ff2f0f3a818e8c8a02c2ef632d0b960.json true, - false - ] - }, - "hash": "b456147560b107640abdc10f7ac76b563ff2f0f3a818e8c8a02c2ef632d0b960" -======== + false, false, false, false ] }, - "hash": "f3a1a12fd9e3fef3f9fbcc24a56545da1ffa0813f79362ce4665b44c1c765fa0" ->>>>>>>> 82ed8f925 (add `BatchFeeInput` to L1 batch models):core/lib/dal/.sqlx/query-f3a1a12fd9e3fef3f9fbcc24a56545da1ffa0813f79362ce4665b44c1c765fa0.json + "hash": "b006720c989bd289181d6398775726bbcaea65b3499c9aff3a42dbd4e66aff7f" } diff --git a/core/lib/dal/.sqlx/query-dc16d0fac093a52480b66dfcb5976fb01e6629e8c982c265f2af1d5000090572.json b/core/lib/dal/.sqlx/query-dc16d0fac093a52480b66dfcb5976fb01e6629e8c982c265f2af1d5000090572.json deleted file mode 100644 index 9669622f5cf2..000000000000 --- a/core/lib/dal/.sqlx/query-dc16d0fac093a52480b66dfcb5976fb01e6629e8c982c265f2af1d5000090572.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "SELECT COUNT(miniblocks.number) FROM miniblocks WHERE l1_batch_number IS NULL", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "count", - "type_info": "Int8" - } - ], - "parameters": { - "Left": [] - }, - "nullable": [ - null - ] - }, - "hash": "dc16d0fac093a52480b66dfcb5976fb01e6629e8c982c265f2af1d5000090572" -} diff --git a/core/lib/dal/src/models/storage_block.rs b/core/lib/dal/src/models/storage_block.rs index 59f0e6f01c7b..0f780091818d 100644 --- a/core/lib/dal/src/models/storage_block.rs +++ b/core/lib/dal/src/models/storage_block.rs @@ -10,7 +10,7 @@ use zksync_types::{ commitment::{L1BatchMetaParameters, L1BatchMetadata}, fee_model::BatchFeeInput, l2_to_l1_log::{L2ToL1Log, SystemL2ToL1Log, UserL2ToL1Log}, - Address, Bloom, L1BatchNumber, L2BlockNumber, H256, + Address, Bloom, L1BatchNumber, L2BlockNumber, ProtocolVersionId, H256, }; /// This is the gas limit that was used inside blocks before we started saving block gas limit into the database. diff --git a/core/node/fee_model/src/lib.rs b/core/node/fee_model/src/lib.rs index d0ee685d08fd..56d0661bdac6 100644 --- a/core/node/fee_model/src/lib.rs +++ b/core/node/fee_model/src/lib.rs @@ -323,8 +323,10 @@ mod tests { use zksync_config::{configs::eth_sender::PubdataSendingMode, GasAdjusterConfig}; use zksync_eth_client::{clients::MockSettlementLayer, BaseFees}; use zksync_types::{ - block::L1BatchHeader, commitment::L1BatchCommitmentMode, - fee_model::BaseTokenConversionRatio, L1BatchNumber, + block::{L1BatchHeader, UnsealedL1BatchHeader}, + commitment::L1BatchCommitmentMode, + fee_model::BaseTokenConversionRatio, + L1BatchNumber, }; use super::*; @@ -855,6 +857,7 @@ mod tests { system_logs: vec![], protocol_version: None, pubdata_input: None, + fee_address: Default::default(), batch_fee_input: sealed_batch_fee_input, }; conn.blocks_dal() @@ -862,7 +865,13 @@ mod tests { .await .unwrap(); conn.blocks_dal() - .insert_l1_batch(L1BatchNumber(2), 2, unsealed_batch_fee_input) + .insert_l1_batch(UnsealedL1BatchHeader { + number: L1BatchNumber(2), + timestamp: 2, + protocol_version: None, + fee_address: Default::default(), + fee_input: unsealed_batch_fee_input, + }) .await .unwrap(); let provider = From 9e1826db413dd9430e9dd2dd63920bb46f31d5d7 Mon Sep 17 00:00:00 2001 From: Daniyar Itegulov Date: Wed, 16 Oct 2024 13:48:40 +1100 Subject: [PATCH 07/19] reuse the same connection --- core/node/fee_model/src/lib.rs | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/core/node/fee_model/src/lib.rs b/core/node/fee_model/src/lib.rs index 56d0661bdac6..fd77d13138ee 100644 --- a/core/node/fee_model/src/lib.rs +++ b/core/node/fee_model/src/lib.rs @@ -144,14 +144,11 @@ impl BatchFeeModelInputProvider for ApiFeeInputProvider { l1_gas_price_scale_factor: f64, l1_pubdata_price_scale_factor: f64, ) -> anyhow::Result { - if let Some(batch_fee_input) = self + let mut conn = self .connection_pool .connection_tagged("api_fee_input_provider") - .await? - .blocks_dal() - .get_unsealed_l1_batch_fee_input() - .await? - { + .await?; + if let Some(batch_fee_input) = conn.blocks_dal().get_unsealed_l1_batch_fee_input().await? { Ok(batch_fee_input) } else { let inner_input = self @@ -162,13 +159,7 @@ impl BatchFeeModelInputProvider for ApiFeeInputProvider { ) .await .context("cannot get batch fee input from base provider")?; - let last_l2_block_params = self - .connection_pool - .connection_tagged("api_fee_input_provider") - .await? - .blocks_dal() - .get_last_sealed_l2_block_header() - .await?; + let last_l2_block_params = conn.blocks_dal().get_last_sealed_l2_block_header().await?; Ok(last_l2_block_params .map(|header| inner_input.stricter(header.batch_fee_input)) .unwrap_or(inner_input)) From f58182f054b1931aae3814e543b2e2c8aac0c309 Mon Sep 17 00:00:00 2001 From: Daniyar Itegulov Date: Thu, 17 Oct 2024 16:51:35 +1100 Subject: [PATCH 08/19] rely on batch fee input to be present --- ...3f86f59a2b4ccb105601968d3a6321e5b2c3.json} | 4 +-- core/lib/dal/src/blocks_dal.rs | 28 +++++++++---------- core/node/fee_model/src/lib.rs | 22 ++------------- 3 files changed, 19 insertions(+), 35 deletions(-) rename core/lib/dal/.sqlx/{query-e3edcff8544b05ee2b2c58aa040b138f12752acc992e0a9065c9c73b90a7aa4c.json => query-2278213c2ce8a8b5f3fddf03e1713f86f59a2b4ccb105601968d3a6321e5b2c3.json} (80%) diff --git a/core/lib/dal/.sqlx/query-e3edcff8544b05ee2b2c58aa040b138f12752acc992e0a9065c9c73b90a7aa4c.json b/core/lib/dal/.sqlx/query-2278213c2ce8a8b5f3fddf03e1713f86f59a2b4ccb105601968d3a6321e5b2c3.json similarity index 80% rename from core/lib/dal/.sqlx/query-e3edcff8544b05ee2b2c58aa040b138f12752acc992e0a9065c9c73b90a7aa4c.json rename to core/lib/dal/.sqlx/query-2278213c2ce8a8b5f3fddf03e1713f86f59a2b4ccb105601968d3a6321e5b2c3.json index 0039bf67e74b..6643b01eb064 100644 --- a/core/lib/dal/.sqlx/query-e3edcff8544b05ee2b2c58aa040b138f12752acc992e0a9065c9c73b90a7aa4c.json +++ b/core/lib/dal/.sqlx/query-2278213c2ce8a8b5f3fddf03e1713f86f59a2b4ccb105601968d3a6321e5b2c3.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\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 ", + "query": "\n SELECT\n l1_gas_price,\n l2_fair_gas_price,\n fair_pubdata_price\n FROM\n l1_batches\n ORDER BY\n number\n LIMIT\n 1\n ", "describe": { "columns": [ { @@ -28,5 +28,5 @@ false ] }, - "hash": "e3edcff8544b05ee2b2c58aa040b138f12752acc992e0a9065c9c73b90a7aa4c" + "hash": "2278213c2ce8a8b5f3fddf03e1713f86f59a2b4ccb105601968d3a6321e5b2c3" } diff --git a/core/lib/dal/src/blocks_dal.rs b/core/lib/dal/src/blocks_dal.rs index fa64bc878372..5dd458d624d2 100644 --- a/core/lib/dal/src/blocks_dal.rs +++ b/core/lib/dal/src/blocks_dal.rs @@ -908,7 +908,9 @@ impl BlocksDal<'_, '_> { Ok(()) } - pub async fn get_unsealed_l1_batch_fee_input(&mut self) -> DalResult> { + /// Returns fee input as of the latest (current unsealed if exists or last sealed if not) L1 + /// batch present in DB. + pub async fn get_latest_l1_batch_fee_input(&mut self) -> DalResult { let row = sqlx::query!( r#" SELECT @@ -917,23 +919,21 @@ impl BlocksDal<'_, '_> { fair_pubdata_price FROM l1_batches - WHERE - NOT is_sealed + ORDER BY + number + LIMIT + 1 "# ) - .instrument("get_last_l1_batch_fee_input") - .fetch_optional(self.storage) + .instrument("get_latest_l1_batch_fee_input") + .fetch_one(self.storage) .await?; - if let Some(row) = row { - Ok(Some(BatchFeeInput::pubdata_independent( - row.l1_gas_price as u64, - row.l2_fair_gas_price as u64, - row.fair_pubdata_price as u64, - ))) - } else { - Ok(None) - } + Ok(BatchFeeInput::pubdata_independent( + row.l1_gas_price as u64, + row.l2_fair_gas_price as u64, + row.fair_pubdata_price as u64, + )) } pub async fn get_last_sealed_l2_block_header(&mut self) -> DalResult> { diff --git a/core/node/fee_model/src/lib.rs b/core/node/fee_model/src/lib.rs index fd77d13138ee..c7a2a519e246 100644 --- a/core/node/fee_model/src/lib.rs +++ b/core/node/fee_model/src/lib.rs @@ -1,6 +1,5 @@ use std::{fmt, fmt::Debug, sync::Arc}; -use anyhow::Context; use async_trait::async_trait; use zksync_dal::{ConnectionPool, Core, CoreDal}; use zksync_types::{ @@ -141,29 +140,14 @@ impl ApiFeeInputProvider { impl BatchFeeModelInputProvider for ApiFeeInputProvider { async fn get_batch_fee_input_scaled( &self, - l1_gas_price_scale_factor: f64, - l1_pubdata_price_scale_factor: f64, + _l1_gas_price_scale_factor: f64, + _l1_pubdata_price_scale_factor: f64, ) -> anyhow::Result { let mut conn = self .connection_pool .connection_tagged("api_fee_input_provider") .await?; - if let Some(batch_fee_input) = conn.blocks_dal().get_unsealed_l1_batch_fee_input().await? { - Ok(batch_fee_input) - } else { - let inner_input = self - .inner - .get_batch_fee_input_scaled( - l1_gas_price_scale_factor, - l1_pubdata_price_scale_factor, - ) - .await - .context("cannot get batch fee input from base provider")?; - let last_l2_block_params = conn.blocks_dal().get_last_sealed_l2_block_header().await?; - Ok(last_l2_block_params - .map(|header| inner_input.stricter(header.batch_fee_input)) - .unwrap_or(inner_input)) - } + Ok(conn.blocks_dal().get_latest_l1_batch_fee_input().await?) } /// Returns the fee model parameters. From 919ae8c62f8669cfb38a0236b4674f48dbadd425 Mon Sep 17 00:00:00 2001 From: Daniyar Itegulov Date: Thu, 17 Oct 2024 17:04:50 +1100 Subject: [PATCH 09/19] clarify fair pubdata error message --- core/lib/types/src/fee_model.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/lib/types/src/fee_model.rs b/core/lib/types/src/fee_model.rs index 6673a1711abc..56e48af55ea2 100644 --- a/core/lib/types/src/fee_model.rs +++ b/core/lib/types/src/fee_model.rs @@ -58,7 +58,7 @@ impl BatchFeeInput { .map(|_| { Self::PubdataIndependent(PubdataIndependentBatchFeeModelInput { fair_pubdata_price: fair_pubdata_price - .expect("No fair pubdata price for 1.4.1 miniblock"), + .expect("No fair pubdata price for 1.4.1"), fair_l2_gas_price, l1_gas_price, }) From ddd3a6d102004917148a5e9137edf2dd293fc58a Mon Sep 17 00:00:00 2001 From: Daniyar Itegulov Date: Thu, 17 Oct 2024 19:56:58 +1100 Subject: [PATCH 10/19] add a special case for genesis --- ...df7e127e38424c7f89f41f2bd30d5d30c938.json} | 4 ++-- core/lib/dal/src/blocks_dal.rs | 15 ++++++++---- core/node/fee_model/src/lib.rs | 24 ++++++++++++++++--- 3 files changed, 34 insertions(+), 9 deletions(-) rename core/lib/dal/.sqlx/{query-2278213c2ce8a8b5f3fddf03e1713f86f59a2b4ccb105601968d3a6321e5b2c3.json => query-dea948be4884bd61e9de2921a02fdf7e127e38424c7f89f41f2bd30d5d30c938.json} (76%) diff --git a/core/lib/dal/.sqlx/query-2278213c2ce8a8b5f3fddf03e1713f86f59a2b4ccb105601968d3a6321e5b2c3.json b/core/lib/dal/.sqlx/query-dea948be4884bd61e9de2921a02fdf7e127e38424c7f89f41f2bd30d5d30c938.json similarity index 76% rename from core/lib/dal/.sqlx/query-2278213c2ce8a8b5f3fddf03e1713f86f59a2b4ccb105601968d3a6321e5b2c3.json rename to core/lib/dal/.sqlx/query-dea948be4884bd61e9de2921a02fdf7e127e38424c7f89f41f2bd30d5d30c938.json index 6643b01eb064..24916f6fcd86 100644 --- a/core/lib/dal/.sqlx/query-2278213c2ce8a8b5f3fddf03e1713f86f59a2b4ccb105601968d3a6321e5b2c3.json +++ b/core/lib/dal/.sqlx/query-dea948be4884bd61e9de2921a02fdf7e127e38424c7f89f41f2bd30d5d30c938.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n l1_gas_price,\n l2_fair_gas_price,\n fair_pubdata_price\n FROM\n l1_batches\n ORDER BY\n number\n LIMIT\n 1\n ", + "query": "\n SELECT\n l1_gas_price,\n l2_fair_gas_price,\n fair_pubdata_price\n FROM\n l1_batches\n WHERE\n number > 0\n ORDER BY\n number\n LIMIT\n 1\n ", "describe": { "columns": [ { @@ -28,5 +28,5 @@ false ] }, - "hash": "2278213c2ce8a8b5f3fddf03e1713f86f59a2b4ccb105601968d3a6321e5b2c3" + "hash": "dea948be4884bd61e9de2921a02fdf7e127e38424c7f89f41f2bd30d5d30c938" } diff --git a/core/lib/dal/src/blocks_dal.rs b/core/lib/dal/src/blocks_dal.rs index 5dd458d624d2..0fbe289811c9 100644 --- a/core/lib/dal/src/blocks_dal.rs +++ b/core/lib/dal/src/blocks_dal.rs @@ -910,7 +910,9 @@ impl BlocksDal<'_, '_> { /// Returns fee input as of the latest (current unsealed if exists or last sealed if not) L1 /// batch present in DB. - pub async fn get_latest_l1_batch_fee_input(&mut self) -> DalResult { + /// + /// `None` if the only batch in DB is genesis as it never has valid fee input. + pub async fn get_latest_l1_batch_fee_input(&mut self) -> DalResult> { let row = sqlx::query!( r#" SELECT @@ -919,6 +921,8 @@ impl BlocksDal<'_, '_> { fair_pubdata_price FROM l1_batches + WHERE + number > 0 ORDER BY number LIMIT @@ -926,14 +930,17 @@ impl BlocksDal<'_, '_> { "# ) .instrument("get_latest_l1_batch_fee_input") - .fetch_one(self.storage) + .fetch_optional(self.storage) .await?; - Ok(BatchFeeInput::pubdata_independent( + let Some(row) = row else { + return Ok(None); + }; + Ok(Some(BatchFeeInput::pubdata_independent( row.l1_gas_price as u64, row.l2_fair_gas_price as u64, row.fair_pubdata_price as u64, - )) + ))) } pub async fn get_last_sealed_l2_block_header(&mut self) -> DalResult> { diff --git a/core/node/fee_model/src/lib.rs b/core/node/fee_model/src/lib.rs index c7a2a519e246..9073a887515d 100644 --- a/core/node/fee_model/src/lib.rs +++ b/core/node/fee_model/src/lib.rs @@ -1,5 +1,6 @@ use std::{fmt, fmt::Debug, sync::Arc}; +use anyhow::Context; use async_trait::async_trait; use zksync_dal::{ConnectionPool, Core, CoreDal}; use zksync_types::{ @@ -140,14 +141,31 @@ impl ApiFeeInputProvider { impl BatchFeeModelInputProvider for ApiFeeInputProvider { async fn get_batch_fee_input_scaled( &self, - _l1_gas_price_scale_factor: f64, - _l1_pubdata_price_scale_factor: f64, + l1_gas_price_scale_factor: f64, + l1_pubdata_price_scale_factor: f64, ) -> anyhow::Result { let mut conn = self .connection_pool .connection_tagged("api_fee_input_provider") .await?; - Ok(conn.blocks_dal().get_latest_l1_batch_fee_input().await?) + let batch_fee_input = conn.blocks_dal().get_latest_l1_batch_fee_input().await?; + if let Some(batch_fee_input) = batch_fee_input { + Ok(batch_fee_input) + } else { + tracing::info!("No batch fee input available, presuming this is the first batch ever"); + let inner_input = self + .inner + .get_batch_fee_input_scaled( + l1_gas_price_scale_factor, + l1_pubdata_price_scale_factor, + ) + .await + .context("cannot get batch fee input from base provider")?; + let last_l2_block_params = conn.blocks_dal().get_last_sealed_l2_block_header().await?; + Ok(last_l2_block_params + .map(|header| inner_input.stricter(header.batch_fee_input)) + .unwrap_or(inner_input)) + } } /// Returns the fee model parameters. From bee1f0975cd42c2f137cf89b3a997a7447d26f67 Mon Sep 17 00:00:00 2001 From: Daniyar Itegulov Date: Thu, 17 Oct 2024 23:34:52 +1100 Subject: [PATCH 11/19] clarify genesis logic --- core/lib/dal/src/blocks_dal.rs | 20 +++++++------------- core/node/fee_model/src/lib.rs | 2 ++ 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/core/lib/dal/src/blocks_dal.rs b/core/lib/dal/src/blocks_dal.rs index 0fbe289811c9..103692d0966a 100644 --- a/core/lib/dal/src/blocks_dal.rs +++ b/core/lib/dal/src/blocks_dal.rs @@ -908,10 +908,11 @@ impl BlocksDal<'_, '_> { Ok(()) } - /// Returns fee input as of the latest (current unsealed if exists or last sealed if not) L1 - /// batch present in DB. + /// Returns fee input as of the latest non-genesis L1 batch present in DB, where latest means: + /// * Current unsealed L1 batch if it exists + /// * Last sealed L1 batch if it does not (excluding genesis as it does not have valid fee input) /// - /// `None` if the only batch in DB is genesis as it never has valid fee input. + /// `None` if the only batch in DB is genesis or if there are no batches at all. pub async fn get_latest_l1_batch_fee_input(&mut self) -> DalResult> { let row = sqlx::query!( r#" @@ -2707,10 +2708,7 @@ impl BlocksDal<'_, '_> { } pub async fn insert_mock_l1_batch(&mut self, header: &L1BatchHeader) -> anyhow::Result<()> { - self.insert_l1_batch( - header.to_unsealed_header(BatchFeeInput::pubdata_independent(100, 100, 100)), - ) - .await?; + self.insert_l1_batch(header.to_unsealed_header()).await?; self.mark_l1_batch_as_sealed( header, &[], @@ -3022,9 +3020,7 @@ mod tests { execute: 10, }; conn.blocks_dal() - .insert_l1_batch( - header.to_unsealed_header(BatchFeeInput::pubdata_independent(100, 100, 100)), - ) + .insert_l1_batch(header.to_unsealed_header()) .await .unwrap(); conn.blocks_dal() @@ -3036,9 +3032,7 @@ mod tests { header.timestamp += 100; predicted_gas += predicted_gas; conn.blocks_dal() - .insert_l1_batch( - header.to_unsealed_header(BatchFeeInput::pubdata_independent(100, 100, 100)), - ) + .insert_l1_batch(header.to_unsealed_header()) .await .unwrap(); conn.blocks_dal() diff --git a/core/node/fee_model/src/lib.rs b/core/node/fee_model/src/lib.rs index 9073a887515d..b2cc20c07997 100644 --- a/core/node/fee_model/src/lib.rs +++ b/core/node/fee_model/src/lib.rs @@ -152,6 +152,8 @@ impl BatchFeeModelInputProvider for ApiFeeInputProvider { if let Some(batch_fee_input) = batch_fee_input { Ok(batch_fee_input) } else { + // This method is not supposed to be used in components with no batches; API server + // always waits until it has at least one L1 batch present. tracing::info!("No batch fee input available, presuming this is the first batch ever"); let inner_input = self .inner From 796c9b559a8434f077c6a6f704a792008a118318 Mon Sep 17 00:00:00 2001 From: Daniyar Itegulov Date: Thu, 17 Oct 2024 23:35:22 +1100 Subject: [PATCH 12/19] fix api fee tests --- core/lib/types/src/block.rs | 4 +-- core/node/api_server/src/web3/tests/mod.rs | 23 +++++++++++++-- .../api_server/src/web3/tests/snapshots.rs | 2 +- core/node/api_server/src/web3/tests/vm.rs | 28 +++++++++++++++---- core/node/genesis/src/lib.rs | 2 +- 5 files changed, 47 insertions(+), 12 deletions(-) diff --git a/core/lib/types/src/block.rs b/core/lib/types/src/block.rs index 4c6ecf836680..d5739cbef62f 100644 --- a/core/lib/types/src/block.rs +++ b/core/lib/types/src/block.rs @@ -70,13 +70,13 @@ pub struct L1BatchHeader { } impl L1BatchHeader { - pub fn to_unsealed_header(&self, fee_input: BatchFeeInput) -> UnsealedL1BatchHeader { + pub fn to_unsealed_header(&self) -> UnsealedL1BatchHeader { UnsealedL1BatchHeader { number: self.number, timestamp: self.timestamp, protocol_version: self.protocol_version, fee_address: self.fee_address, - fee_input, + fee_input: self.batch_fee_input, } } } diff --git a/core/node/api_server/src/web3/tests/mod.rs b/core/node/api_server/src/web3/tests/mod.rs index c83279709a30..b2d2ad7baea4 100644 --- a/core/node/api_server/src/web3/tests/mod.rs +++ b/core/node/api_server/src/web3/tests/mod.rs @@ -179,6 +179,7 @@ enum StorageInitialization { Recovery { logs: Vec, factory_deps: HashMap>, + batch_fee_input: BatchFeeInput, }, } @@ -200,6 +201,7 @@ impl StorageInitialization { Self::Recovery { logs: vec![], factory_deps: HashMap::new(), + batch_fee_input: BatchFeeInput::pubdata_independent(0, 0, 0), } } @@ -239,6 +241,7 @@ impl StorageInitialization { Self::Recovery { mut logs, factory_deps, + batch_fee_input, } => { let l2_block_info_key = StorageKey::new( AccountTreeId::new(SYSTEM_CONTEXT_ADDRESS), @@ -267,7 +270,12 @@ impl StorageInitialization { // Insert the next L1 batch in the storage so that the API server doesn't hang up. store_l2_block(storage, Self::SNAPSHOT_RECOVERY_BLOCK + 1, &[]).await?; - seal_l1_batch(storage, Self::SNAPSHOT_RECOVERY_BATCH + 1).await?; + seal_l1_batch( + storage, + Self::SNAPSHOT_RECOVERY_BATCH + 1, + Some(batch_fee_input), + ) + .await?; } } Ok(()) @@ -400,8 +408,12 @@ async fn store_custom_l2_block( async fn seal_l1_batch( storage: &mut Connection<'_, Core>, number: L1BatchNumber, + batch_fee_input: Option, ) -> anyhow::Result<()> { - let header = create_l1_batch(number.0); + let mut header = create_l1_batch(number.0); + if let Some(batch_fee_input) = batch_fee_input { + header.batch_fee_input = batch_fee_input; + } storage.blocks_dal().insert_mock_l1_batch(&header).await?; storage .blocks_dal() @@ -691,7 +703,11 @@ impl HttpTest for StorageAccessWithSnapshotRecovery { ), ]; let factory_deps = [(code_hash, b"code".to_vec())].into(); - StorageInitialization::Recovery { logs, factory_deps } + StorageInitialization::Recovery { + logs, + factory_deps, + batch_fee_input: BatchFeeInput::pubdata_independent(0, 0, 0), + } } async fn test( @@ -838,6 +854,7 @@ impl HttpTest for TransactionCountAfterSnapshotRecoveryTest { StorageInitialization::Recovery { logs: vec![nonce_log], factory_deps: HashMap::new(), + batch_fee_input: BatchFeeInput::pubdata_independent(0, 0, 0), } } diff --git a/core/node/api_server/src/web3/tests/snapshots.rs b/core/node/api_server/src/web3/tests/snapshots.rs index 46261c8c6fb7..c54cdc840b1e 100644 --- a/core/node/api_server/src/web3/tests/snapshots.rs +++ b/core/node/api_server/src/web3/tests/snapshots.rs @@ -40,7 +40,7 @@ impl HttpTest for SnapshotBasicsTest { &[execute_l2_transaction(create_l2_transaction(1, 2))], ) .await?; - seal_l1_batch(&mut storage, L1BatchNumber(1)).await?; + seal_l1_batch(&mut storage, L1BatchNumber(1), None).await?; storage .snapshots_dal() .add_snapshot( diff --git a/core/node/api_server/src/web3/tests/vm.rs b/core/node/api_server/src/web3/tests/vm.rs index 45128f579cda..1db10f14d8a1 100644 --- a/core/node/api_server/src/web3/tests/vm.rs +++ b/core/node/api_server/src/web3/tests/vm.rs @@ -325,7 +325,12 @@ struct CallTestAfterSnapshotRecovery { #[async_trait] impl HttpTest for CallTestAfterSnapshotRecovery { fn storage_initialization(&self) -> StorageInitialization { - StorageInitialization::empty_recovery() + let batch_fee_input = *self.fee_input.0.lock().unwrap(); + StorageInitialization::Recovery { + logs: vec![], + factory_deps: HashMap::new(), + batch_fee_input, + } } fn transaction_executor(&self) -> MockOneshotExecutor { @@ -433,6 +438,7 @@ impl HttpTest for SendRawTransactionTest { StorageInitialization::Recovery { logs, factory_deps: HashMap::default(), + batch_fee_input: BatchFeeInput::pubdata_independent(100, 100, 100), } } else { StorageInitialization::genesis() @@ -808,15 +814,28 @@ async fn trace_call_basics() { test_http_server(TraceCallTest::default()).await; } -#[derive(Debug, Default)] +#[derive(Debug)] struct TraceCallTestAfterSnapshotRecovery { fee_input: ExpectedFeeInput, } +impl TraceCallTestAfterSnapshotRecovery { + fn new() -> Self { + let fee_input = ExpectedFeeInput::default(); + fee_input.expect_default(TraceCallTest::FEE_SCALE); + Self { fee_input } + } +} + #[async_trait] impl HttpTest for TraceCallTestAfterSnapshotRecovery { fn storage_initialization(&self) -> StorageInitialization { - StorageInitialization::empty_recovery() + let batch_fee_input = *self.fee_input.0.lock().unwrap(); + StorageInitialization::Recovery { + logs: vec![], + factory_deps: HashMap::new(), + batch_fee_input, + } } fn transaction_executor(&self) -> MockOneshotExecutor { @@ -829,7 +848,6 @@ impl HttpTest for TraceCallTestAfterSnapshotRecovery { client: &DynClient, _pool: &ConnectionPool, ) -> anyhow::Result<()> { - self.fee_input.expect_default(TraceCallTest::FEE_SCALE); let call_request = CallTest::call_request(b"pending"); let call_result = client .trace_call(call_request.clone(), None, None) @@ -872,7 +890,7 @@ impl HttpTest for TraceCallTestAfterSnapshotRecovery { #[tokio::test] async fn trace_call_after_snapshot_recovery() { - test_http_server(TraceCallTestAfterSnapshotRecovery::default()).await; + test_http_server(TraceCallTestAfterSnapshotRecovery::new()).await; } #[derive(Debug)] diff --git a/core/node/genesis/src/lib.rs b/core/node/genesis/src/lib.rs index 3e4c0ee30b94..5ca7c36917f0 100644 --- a/core/node/genesis/src/lib.rs +++ b/core/node/genesis/src/lib.rs @@ -419,7 +419,7 @@ pub async fn create_genesis_l1_batch( .await?; transaction .blocks_dal() - .insert_l1_batch(genesis_l1_batch_header.to_unsealed_header(batch_fee_input)) + .insert_l1_batch(genesis_l1_batch_header.to_unsealed_header()) .await?; transaction .blocks_dal() From 71593009361bd9327ecdf2e36c52c96e8b95b5e6 Mon Sep 17 00:00:00 2001 From: Daniyar Itegulov Date: Wed, 11 Dec 2024 22:37:56 +1100 Subject: [PATCH 13/19] revamp the logic from ground up and align tests --- Cargo.lock | 2 + ...e235deae9a0c54b9713207d53918eb4973600.json | 62 ++++++++++ ...fdf7e127e38424c7f89f41f2bd30d5d30c938.json | 32 ----- core/lib/dal/src/blocks_dal.rs | 78 ++++++------ core/lib/dal/src/models/storage_block.rs | 35 +++++- core/lib/types/src/block.rs | 11 ++ core/node/api_server/src/web3/tests/mod.rs | 37 +++--- .../api_server/src/web3/tests/snapshots.rs | 2 +- core/node/api_server/src/web3/tests/vm.rs | 116 ++++++++++++------ core/node/fee_model/Cargo.toml | 2 + core/node/fee_model/src/lib.rs | 86 ++++++------- 11 files changed, 280 insertions(+), 183 deletions(-) create mode 100644 core/lib/dal/.sqlx/query-24aca24f8811d87f5ff54757903e235deae9a0c54b9713207d53918eb4973600.json delete mode 100644 core/lib/dal/.sqlx/query-dea948be4884bd61e9de2921a02fdf7e127e38424c7f89f41f2bd30d5d30c938.json diff --git a/Cargo.lock b/Cargo.lock index 6e8b76c964c0..99e56d6555e6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -12242,6 +12242,8 @@ dependencies = [ "zksync_config", "zksync_dal", "zksync_eth_client", + "zksync_node_genesis", + "zksync_node_test_utils", "zksync_types", "zksync_web3_decl", ] diff --git a/core/lib/dal/.sqlx/query-24aca24f8811d87f5ff54757903e235deae9a0c54b9713207d53918eb4973600.json b/core/lib/dal/.sqlx/query-24aca24f8811d87f5ff54757903e235deae9a0c54b9713207d53918eb4973600.json new file mode 100644 index 000000000000..b25eff8b4f55 --- /dev/null +++ b/core/lib/dal/.sqlx/query-24aca24f8811d87f5ff54757903e235deae9a0c54b9713207d53918eb4973600.json @@ -0,0 +1,62 @@ +{ + "db_name": "PostgreSQL", + "query": "\n SELECT\n number,\n is_sealed,\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 ORDER BY\n number DESC\n LIMIT\n 1\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "number", + "type_info": "Int8" + }, + { + "ordinal": 1, + "name": "is_sealed", + "type_info": "Bool" + }, + { + "ordinal": 2, + "name": "timestamp", + "type_info": "Int8" + }, + { + "ordinal": 3, + "name": "protocol_version", + "type_info": "Int4" + }, + { + "ordinal": 4, + "name": "fee_address", + "type_info": "Bytea" + }, + { + "ordinal": 5, + "name": "l1_gas_price", + "type_info": "Int8" + }, + { + "ordinal": 6, + "name": "l2_fair_gas_price", + "type_info": "Int8" + }, + { + "ordinal": 7, + "name": "fair_pubdata_price", + "type_info": "Int8" + } + ], + "parameters": { + "Left": [] + }, + "nullable": [ + false, + false, + false, + true, + false, + false, + false, + false + ] + }, + "hash": "24aca24f8811d87f5ff54757903e235deae9a0c54b9713207d53918eb4973600" +} diff --git a/core/lib/dal/.sqlx/query-dea948be4884bd61e9de2921a02fdf7e127e38424c7f89f41f2bd30d5d30c938.json b/core/lib/dal/.sqlx/query-dea948be4884bd61e9de2921a02fdf7e127e38424c7f89f41f2bd30d5d30c938.json deleted file mode 100644 index 24916f6fcd86..000000000000 --- a/core/lib/dal/.sqlx/query-dea948be4884bd61e9de2921a02fdf7e127e38424c7f89f41f2bd30d5d30c938.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "\n SELECT\n l1_gas_price,\n l2_fair_gas_price,\n fair_pubdata_price\n FROM\n l1_batches\n WHERE\n number > 0\n ORDER BY\n number\n LIMIT\n 1\n ", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "l1_gas_price", - "type_info": "Int8" - }, - { - "ordinal": 1, - "name": "l2_fair_gas_price", - "type_info": "Int8" - }, - { - "ordinal": 2, - "name": "fair_pubdata_price", - "type_info": "Int8" - } - ], - "parameters": { - "Left": [] - }, - "nullable": [ - false, - false, - false - ] - }, - "hash": "dea948be4884bd61e9de2921a02fdf7e127e38424c7f89f41f2bd30d5d30c938" -} diff --git a/core/lib/dal/src/blocks_dal.rs b/core/lib/dal/src/blocks_dal.rs index 0ca58420b79f..4992176ef688 100644 --- a/core/lib/dal/src/blocks_dal.rs +++ b/core/lib/dal/src/blocks_dal.rs @@ -16,11 +16,10 @@ use zksync_db_connection::{ use zksync_types::{ aggregated_operations::AggregatedActionType, block::{ - L1BatchHeader, L1BatchStatistics, L1BatchTreeData, L2BlockHeader, StorageOracleInfo, - UnsealedL1BatchHeader, + CommonL1BatchHeader, L1BatchHeader, L1BatchStatistics, L1BatchTreeData, L2BlockHeader, + StorageOracleInfo, UnsealedL1BatchHeader, }, commitment::{L1BatchCommitmentArtifacts, L1BatchWithMetadata}, - fee_model::BatchFeeInput, l2_to_l1_log::{BatchAndChainMerklePath, UserL2ToL1Log}, writes::TreeWrite, Address, Bloom, L1BatchNumber, L2BlockNumber, ProtocolVersionId, SLChainId, H256, U256, @@ -32,7 +31,8 @@ use crate::{ models::{ parse_protocol_version, storage_block::{ - StorageL1Batch, StorageL1BatchHeader, StorageL2BlockHeader, UnsealedStorageL1Batch, + CommonStorageL1BatchHeader, StorageL1Batch, StorageL1BatchHeader, StorageL2BlockHeader, + UnsealedStorageL1Batch, }, storage_event::StorageL2ToL1Log, storage_oracle_info::DbStorageOracleInfo, @@ -103,6 +103,7 @@ impl BlocksDal<'_, '_> { Ok(count == 0) } + /// Returns the number of the last sealed L1 batch present in the DB, or `None` if there are no L1 batches. pub async fn get_sealed_l1_batch_number(&mut self) -> DalResult> { let row = sqlx::query!( r#" @@ -122,6 +123,39 @@ impl BlocksDal<'_, '_> { Ok(row.number.map(|num| L1BatchNumber(num as u32))) } + /// Returns latest L1 batch's header (could be unsealed). The header contains fields that are + /// common for both unsealed and sealed batches. Returns `None` if there are no L1 batches. + pub async fn get_latest_l1_batch_header(&mut self) -> DalResult> { + let Some(header) = sqlx::query_as!( + CommonStorageL1BatchHeader, + r#" + SELECT + number, + is_sealed, + timestamp, + protocol_version, + fee_address, + l1_gas_price, + l2_fair_gas_price, + fair_pubdata_price + FROM + l1_batches + ORDER BY + number DESC + LIMIT + 1 + "#, + ) + .instrument("get_latest_l1_batch_header") + .fetch_optional(self.storage) + .await? + else { + return Ok(None); + }; + + Ok(Some(header.into())) + } + pub async fn get_sealed_l2_block_number(&mut self) -> DalResult> { let row = sqlx::query!( r#" @@ -918,42 +952,6 @@ impl BlocksDal<'_, '_> { Ok(()) } - /// Returns fee input as of the latest non-genesis L1 batch present in DB, where latest means: - /// * Current unsealed L1 batch if it exists - /// * Last sealed L1 batch if it does not (excluding genesis as it does not have valid fee input) - /// - /// `None` if the only batch in DB is genesis or if there are no batches at all. - pub async fn get_latest_l1_batch_fee_input(&mut self) -> DalResult> { - let row = sqlx::query!( - r#" - SELECT - l1_gas_price, - l2_fair_gas_price, - fair_pubdata_price - FROM - l1_batches - WHERE - number > 0 - ORDER BY - number - LIMIT - 1 - "# - ) - .instrument("get_latest_l1_batch_fee_input") - .fetch_optional(self.storage) - .await?; - - let Some(row) = row else { - return Ok(None); - }; - Ok(Some(BatchFeeInput::pubdata_independent( - row.l1_gas_price as u64, - row.l2_fair_gas_price as u64, - row.fair_pubdata_price as u64, - ))) - } - pub async fn get_last_sealed_l2_block_header(&mut self) -> DalResult> { let header = sqlx::query_as!( StorageL2BlockHeader, diff --git a/core/lib/dal/src/models/storage_block.rs b/core/lib/dal/src/models/storage_block.rs index 220b6fd24290..3fb0b2808566 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, UnsealedL1BatchHeader}, + block::{CommonL1BatchHeader, L1BatchHeader, L2BlockHeader, UnsealedL1BatchHeader}, commitment::{L1BatchCommitmentMode, L1BatchMetaParameters, L1BatchMetadata, PubdataParams}, fee_model::BatchFeeInput, l2_to_l1_log::{L2ToL1Log, SystemL2ToL1Log, UserL2ToL1Log}, @@ -333,6 +333,39 @@ impl From for UnsealedL1BatchHeader { } } +/// Partial projection of the columns common to both [`L1BatchHeader`] and [`UnsealedL1BatchHeader`]. +pub(crate) struct CommonStorageL1BatchHeader { + pub number: i64, + pub is_sealed: bool, + 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 CommonL1BatchHeader { + fn from(batch: CommonStorageL1BatchHeader) -> Self { + let protocol_version: Option = batch + .protocol_version + .map(|v| (v as u16).try_into().unwrap()); + Self { + number: L1BatchNumber(batch.number as u32), + is_sealed: batch.is_sealed, + 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 98276b5e5dda..4ae665656ee1 100644 --- a/core/lib/types/src/block.rs +++ b/core/lib/types/src/block.rs @@ -78,6 +78,7 @@ impl L1BatchHeader { } } +/// Holder for the metadata that is relevant for unsealed batches. #[derive(Debug, Clone, PartialEq)] pub struct UnsealedL1BatchHeader { pub number: L1BatchNumber, @@ -87,6 +88,16 @@ pub struct UnsealedL1BatchHeader { pub fee_input: BatchFeeInput, } +/// Holder for the metadata that is relevant for both sealed and unsealed batches. +pub struct CommonL1BatchHeader { + pub number: L1BatchNumber, + pub is_sealed: bool, + 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/api_server/src/web3/tests/mod.rs b/core/node/api_server/src/web3/tests/mod.rs index 55e56f0d7863..0481254155b3 100644 --- a/core/node/api_server/src/web3/tests/mod.rs +++ b/core/node/api_server/src/web3/tests/mod.rs @@ -32,7 +32,7 @@ use zksync_system_constants::{ }; use zksync_types::{ api, - block::{pack_block_info, L2BlockHasher, L2BlockHeader}, + block::{pack_block_info, L2BlockHasher, L2BlockHeader, UnsealedL1BatchHeader}, bytecode::{ testonly::{PROCESSED_EVM_BYTECODE, RAW_EVM_BYTECODE}, BytecodeHash, @@ -175,7 +175,6 @@ enum StorageInitialization { Recovery { logs: Vec, factory_deps: HashMap>, - batch_fee_input: BatchFeeInput, }, } @@ -197,7 +196,6 @@ impl StorageInitialization { Self::Recovery { logs: vec![], factory_deps: HashMap::new(), - batch_fee_input: BatchFeeInput::pubdata_independent(0, 0, 0), } } @@ -237,7 +235,6 @@ impl StorageInitialization { Self::Recovery { mut logs, factory_deps, - batch_fee_input, } => { let l2_block_info_key = StorageKey::new( AccountTreeId::new(SYSTEM_CONTEXT_ADDRESS), @@ -266,12 +263,7 @@ impl StorageInitialization { // Insert the next L1 batch in the storage so that the API server doesn't hang up. store_l2_block(storage, Self::SNAPSHOT_RECOVERY_BLOCK + 1, &[]).await?; - seal_l1_batch( - storage, - Self::SNAPSHOT_RECOVERY_BATCH + 1, - Some(batch_fee_input), - ) - .await?; + seal_l1_batch(storage, Self::SNAPSHOT_RECOVERY_BATCH + 1).await?; } } Ok(()) @@ -405,15 +397,23 @@ async fn store_custom_l2_block( Ok(()) } +async fn open_l1_batch( + storage: &mut Connection<'_, Core>, + number: L1BatchNumber, + batch_fee_input: BatchFeeInput, +) -> anyhow::Result { + let mut header = create_l1_batch(number.0); + header.batch_fee_input = batch_fee_input; + let header = header.to_unsealed_header(); + storage.blocks_dal().insert_l1_batch(header.clone()).await?; + Ok(header) +} + async fn seal_l1_batch( storage: &mut Connection<'_, Core>, number: L1BatchNumber, - batch_fee_input: Option, ) -> anyhow::Result<()> { - let mut header = create_l1_batch(number.0); - if let Some(batch_fee_input) = batch_fee_input { - header.batch_fee_input = batch_fee_input; - } + let header = create_l1_batch(number.0); storage.blocks_dal().insert_mock_l1_batch(&header).await?; storage .blocks_dal() @@ -699,11 +699,7 @@ impl HttpTest for StorageAccessWithSnapshotRecovery { ), ]; let factory_deps = [(code_hash, b"code".to_vec())].into(); - StorageInitialization::Recovery { - logs, - factory_deps, - batch_fee_input: BatchFeeInput::pubdata_independent(0, 0, 0), - } + StorageInitialization::Recovery { logs, factory_deps } } async fn test( @@ -854,7 +850,6 @@ impl HttpTest for TransactionCountAfterSnapshotRecoveryTest { StorageInitialization::Recovery { logs: vec![nonce_log], factory_deps: HashMap::new(), - batch_fee_input: BatchFeeInput::pubdata_independent(0, 0, 0), } } diff --git a/core/node/api_server/src/web3/tests/snapshots.rs b/core/node/api_server/src/web3/tests/snapshots.rs index c54cdc840b1e..46261c8c6fb7 100644 --- a/core/node/api_server/src/web3/tests/snapshots.rs +++ b/core/node/api_server/src/web3/tests/snapshots.rs @@ -40,7 +40,7 @@ impl HttpTest for SnapshotBasicsTest { &[execute_l2_transaction(create_l2_transaction(1, 2))], ) .await?; - seal_l1_batch(&mut storage, L1BatchNumber(1), None).await?; + seal_l1_batch(&mut storage, L1BatchNumber(1)).await?; storage .snapshots_dal() .add_snapshot( diff --git a/core/node/api_server/src/web3/tests/vm.rs b/core/node/api_server/src/web3/tests/vm.rs index fcb7a9228c48..62a2ecaed42d 100644 --- a/core/node/api_server/src/web3/tests/vm.rs +++ b/core/node/api_server/src/web3/tests/vm.rs @@ -212,20 +212,44 @@ impl HttpTest for CallTest { panic!("Unexpected error: {error:?}"); } - // Check that the method handler fetches fee inputs for recent blocks. To do that, we create a new block - // with a large fee input; it should be loaded by `ApiFeeInputProvider` and override the input provided by the wrapped mock provider. - let mut block_header = create_l2_block(2); - block_header.batch_fee_input = scaled_sensible_fee_input(2.5); - store_custom_l2_block(&mut connection, &block_header, &[]).await?; + // Check that the method handler fetches fee input from the open batch. To do that, we open a new batch + // with a large fee input; it should be loaded by `ApiFeeInputProvider` and used instead of the input + // provided by the wrapped mock provider. + let batch_header = open_l1_batch( + &mut connection, + L1BatchNumber(1), + scaled_sensible_fee_input(3.0), + ) + .await?; // Fee input is not scaled further as per `ApiFeeInputProvider` implementation - self.fee_input.expect_custom(block_header.batch_fee_input); - let call_request = Self::call_request(b"block=3"); - let call_result = client.call(call_request, None, None).await?; + self.fee_input.expect_custom(batch_header.fee_input); + let call_request = Self::call_request(b"block=2"); + let call_result = client.call(call_request.clone(), None, None).await?; + assert_eq!(call_result.0, b"output"); + let call_result = client + .call( + call_request, + Some(api::BlockIdVariant::BlockNumber(api::BlockNumber::Pending)), + None, + ) + .await?; + assert_eq!(call_result.0, b"output"); + + // Logic here is arguable, but we consider "latest" requests to be interested in the newly + // open batch's fee input even if the latest block was sealed in the previous batch. + let call_request = Self::call_request(b"block=1"); + let call_result = client + .call( + call_request.clone(), + Some(api::BlockIdVariant::BlockNumber(api::BlockNumber::Latest)), + None, + ) + .await?; assert_eq!(call_result.0, b"output"); let call_request_without_target = CallRequest { to: None, - ..Self::call_request(b"block=3") + ..Self::call_request(b"block=2") }; let err = client .call(call_request_without_target, None, None) @@ -325,12 +349,7 @@ struct CallTestAfterSnapshotRecovery { #[async_trait] impl HttpTest for CallTestAfterSnapshotRecovery { fn storage_initialization(&self) -> StorageInitialization { - let batch_fee_input = *self.fee_input.0.lock().unwrap(); - StorageInitialization::Recovery { - logs: vec![], - factory_deps: HashMap::new(), - batch_fee_input, - } + StorageInitialization::empty_recovery() } fn transaction_executor(&self) -> MockOneshotExecutor { @@ -438,7 +457,6 @@ impl HttpTest for SendRawTransactionTest { StorageInitialization::Recovery { logs, factory_deps: HashMap::default(), - batch_fee_input: BatchFeeInput::pubdata_independent(100, 100, 100), } } else { StorageInitialization::genesis() @@ -734,8 +752,11 @@ impl HttpTest for TraceCallTest { pool: &ConnectionPool, ) -> anyhow::Result<()> { // Store an additional L2 block because L2 block #0 has some special processing making it work incorrectly. + // First half of the test asserts API server's behavior when there is no open batch. In other words, + // when `ApiFeeInputProvider` is forced to fetch fee params from the main node. let mut connection = pool.connection().await?; store_l2_block(&mut connection, L2BlockNumber(1), &[]).await?; + seal_l1_batch(&mut connection, L1BatchNumber(1)).await?; self.fee_input.expect_default(Self::FEE_SCALE); let call_request = CallTest::call_request(b"pending"); @@ -781,20 +802,44 @@ impl HttpTest for TraceCallTest { panic!("Unexpected error: {error:?}"); } - // Check that the method handler fetches fee inputs for recent blocks. To do that, we create a new block - // with a large fee input; it should be loaded by `ApiFeeInputProvider` and override the input provided by the wrapped mock provider. - let mut block_header = create_l2_block(2); - block_header.batch_fee_input = scaled_sensible_fee_input(3.0); - store_custom_l2_block(&mut connection, &block_header, &[]).await?; + // Check that the method handler fetches fee input from the open batch. To do that, we open a new batch + // with a large fee input; it should be loaded by `ApiFeeInputProvider` and used instead of the input + // provided by the wrapped mock provider. + let batch_header = open_l1_batch( + &mut connection, + L1BatchNumber(2), + scaled_sensible_fee_input(3.0), + ) + .await?; // Fee input is not scaled further as per `ApiFeeInputProvider` implementation - self.fee_input.expect_custom(block_header.batch_fee_input); - let call_request = CallTest::call_request(b"block=3"); + self.fee_input.expect_custom(batch_header.fee_input); + let call_request = CallTest::call_request(b"block=2"); let call_result = client.trace_call(call_request.clone(), None, None).await?; Self::assert_debug_call(&call_request, &call_result.unwrap_default()); + let call_result = client + .trace_call( + call_request.clone(), + Some(api::BlockId::Number(api::BlockNumber::Pending)), + None, + ) + .await?; + Self::assert_debug_call(&call_request, &call_result.unwrap_default()); + + // Logic here is arguable, but we consider "latest" requests to be interested in the newly + // open batch's fee input even if the latest block was sealed in the previous batch. + let call_request = CallTest::call_request(b"block=1"); + let call_result = client + .trace_call( + call_request.clone(), + Some(api::BlockId::Number(api::BlockNumber::Latest)), + None, + ) + .await?; + Self::assert_debug_call(&call_request, &call_result.unwrap_default()); let call_request_without_target = CallRequest { to: None, - ..CallTest::call_request(b"block=3") + ..CallTest::call_request(b"block=2") }; let err = client .call(call_request_without_target, None, None) @@ -811,28 +856,15 @@ async fn trace_call_basics() { test_http_server(TraceCallTest::default()).await; } -#[derive(Debug)] +#[derive(Debug, Default)] struct TraceCallTestAfterSnapshotRecovery { fee_input: ExpectedFeeInput, } -impl TraceCallTestAfterSnapshotRecovery { - fn new() -> Self { - let fee_input = ExpectedFeeInput::default(); - fee_input.expect_default(TraceCallTest::FEE_SCALE); - Self { fee_input } - } -} - #[async_trait] impl HttpTest for TraceCallTestAfterSnapshotRecovery { fn storage_initialization(&self) -> StorageInitialization { - let batch_fee_input = *self.fee_input.0.lock().unwrap(); - StorageInitialization::Recovery { - logs: vec![], - factory_deps: HashMap::new(), - batch_fee_input, - } + StorageInitialization::empty_recovery() } fn transaction_executor(&self) -> MockOneshotExecutor { @@ -845,6 +877,7 @@ impl HttpTest for TraceCallTestAfterSnapshotRecovery { client: &DynClient, _pool: &ConnectionPool, ) -> anyhow::Result<()> { + self.fee_input.expect_default(TraceCallTest::FEE_SCALE); let call_request = CallTest::call_request(b"pending"); let call_result = client .trace_call(call_request.clone(), None, None) @@ -887,7 +920,7 @@ impl HttpTest for TraceCallTestAfterSnapshotRecovery { #[tokio::test] async fn trace_call_after_snapshot_recovery() { - test_http_server(TraceCallTestAfterSnapshotRecovery::new()).await; + test_http_server(TraceCallTestAfterSnapshotRecovery::default()).await; } #[derive(Debug)] @@ -915,12 +948,15 @@ impl HttpTest for TraceCallTestWithEvmEmulator { pool: &ConnectionPool, ) -> anyhow::Result<()> { // Store an additional L2 block because L2 block #0 has some special processing making it work incorrectly. + // And make sure there is no open batch so that `ApiFeeInputProvider` is forced to fetch fee params from + // the main node. let mut connection = pool.connection().await?; let block_header = L2BlockHeader { base_system_contracts_hashes: genesis_contract_hashes(&mut connection).await?, ..create_l2_block(1) }; store_custom_l2_block(&mut connection, &block_header, &[]).await?; + seal_l1_batch(&mut connection, L1BatchNumber(1)).await?; client .trace_call(CallTest::call_request(&[]), None, None) diff --git a/core/node/fee_model/Cargo.toml b/core/node/fee_model/Cargo.toml index a84a7c5c2173..5b40164a029f 100644 --- a/core/node/fee_model/Cargo.toml +++ b/core/node/fee_model/Cargo.toml @@ -25,3 +25,5 @@ tracing.workspace = true [dev-dependencies] test-casing.workspace = true +zksync_node_test_utils.workspace = true +zksync_node_genesis.workspace = true diff --git a/core/node/fee_model/src/lib.rs b/core/node/fee_model/src/lib.rs index 309c32b02e30..a66d05f7cb2e 100644 --- a/core/node/fee_model/src/lib.rs +++ b/core/node/fee_model/src/lib.rs @@ -116,26 +116,30 @@ impl BatchFeeModelInputProvider for ApiFeeInputProvider { .connection_pool .connection_tagged("api_fee_input_provider") .await?; - let batch_fee_input = conn.blocks_dal().get_latest_l1_batch_fee_input().await?; - if let Some(batch_fee_input) = batch_fee_input { - Ok(batch_fee_input) - } else { - // This method is not supposed to be used in components with no batches; API server - // always waits until it has at least one L1 batch present. - tracing::info!("No batch fee input available, presuming this is the first batch ever"); - let inner_input = self - .inner - .get_batch_fee_input_scaled( - l1_gas_price_scale_factor, - l1_pubdata_price_scale_factor, - ) - .await - .context("cannot get batch fee input from base provider")?; - let last_l2_block_params = conn.blocks_dal().get_last_sealed_l2_block_header().await?; - Ok(last_l2_block_params - .map(|header| inner_input.stricter(header.batch_fee_input)) - .unwrap_or(inner_input)) + let latest_batch_header = conn + .blocks_dal() + .get_latest_l1_batch_header() + .await? + .context("no batches were found in the DB")?; + + if !latest_batch_header.is_sealed { + tracing::trace!( + latest_batch_number = %latest_batch_header.number, + "Found an open batch; reporting its fee input" + ); + return Ok(latest_batch_header.fee_input); } + + tracing::trace!( + latest_batch_number = %latest_batch_header.number, + "No open batch found; fetching from base provider" + ); + let inner_input = self + .inner + .get_batch_fee_input_scaled(l1_gas_price_scale_factor, l1_pubdata_price_scale_factor) + .await + .context("cannot get batch fee input from base provider")?; + Ok(inner_input) } /// Returns the fee model parameters. @@ -169,12 +173,13 @@ mod tests { use l1_gas_price::GasAdjusterClient; use zksync_config::GasAdjusterConfig; use zksync_eth_client::{clients::MockSettlementLayer, BaseFees}; + use zksync_node_genesis::{insert_genesis_batch, GenesisParams}; + use zksync_node_test_utils::create_l1_batch; use zksync_types::{ - block::{L1BatchHeader, UnsealedL1BatchHeader}, commitment::L1BatchCommitmentMode, fee_model::{BaseTokenConversionRatio, FeeModelConfigV2}, pubdata_da::PubdataSendingMode, - L1BatchNumber, U256, + U256, }; use super::*; @@ -395,40 +400,25 @@ mod tests { let pool = ConnectionPool::::test_pool().await; let mut conn = pool.connection().await.unwrap(); - let l1_batch_header = L1BatchHeader { - number: L1BatchNumber(1), - timestamp: 1, - l1_tx_count: 0, - l2_tx_count: 0, - priority_ops_onchain_data: vec![], - l2_to_l1_logs: vec![], - l2_to_l1_messages: vec![], - bloom: Default::default(), - used_contract_hashes: vec![], - base_system_contracts_hashes: Default::default(), - system_logs: vec![], - protocol_version: None, - pubdata_input: None, - fee_address: Default::default(), - batch_fee_input: sealed_batch_fee_input, - }; + insert_genesis_batch(&mut conn, &GenesisParams::mock()) + .await + .unwrap(); + + let mut l1_batch_header = create_l1_batch(1); + l1_batch_header.batch_fee_input = sealed_batch_fee_input; conn.blocks_dal() .insert_mock_l1_batch(&l1_batch_header) .await .unwrap(); + let mut l1_batch_header = create_l1_batch(2); + l1_batch_header.batch_fee_input = unsealed_batch_fee_input; conn.blocks_dal() - .insert_l1_batch(UnsealedL1BatchHeader { - number: L1BatchNumber(2), - timestamp: 2, - protocol_version: None, - fee_address: Default::default(), - fee_input: unsealed_batch_fee_input, - }) + .insert_l1_batch(l1_batch_header.to_unsealed_header()) .await .unwrap(); - let provider = - ApiFeeInputProvider::new(Arc::new(MockBatchFeeParamsProvider::default()), pool); - let fee_input = provider.get_batch_fee_input_scaled(1.0, 1.0).await.unwrap(); + let provider: &dyn BatchFeeModelInputProvider = + &ApiFeeInputProvider::new(Arc::new(MockBatchFeeParamsProvider::default()), pool); + let fee_input = provider.get_batch_fee_input().await.unwrap(); assert_eq!(fee_input, unsealed_batch_fee_input); } } From cfd0f76433f7592863a1b0b4aba4faa320326c1f Mon Sep 17 00:00:00 2001 From: Daniyar Itegulov Date: Thu, 12 Dec 2024 15:39:56 +1100 Subject: [PATCH 14/19] fix integration tests --- core/tests/ts-integration/src/helpers.ts | 39 ++++++++++++++++++-- core/tests/ts-integration/tests/fees.test.ts | 3 ++ 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/core/tests/ts-integration/src/helpers.ts b/core/tests/ts-integration/src/helpers.ts index 8e31c1a691ff..0b217c832a97 100644 --- a/core/tests/ts-integration/src/helpers.ts +++ b/core/tests/ts-integration/src/helpers.ts @@ -3,6 +3,7 @@ import * as zksync from 'zksync-ethers'; import * as ethers from 'ethers'; import * as hre from 'hardhat'; import { ZkSyncArtifact } from '@matterlabs/hardhat-zksync-solc/dist/src/types'; +import { TransactionReceipt } from 'zksync-ethers/build/types'; export const SYSTEM_CONTEXT_ADDRESS = '0x000000000000000000000000000000000000800b'; @@ -71,13 +72,43 @@ export async function anyTransaction(wallet: zksync.Wallet): Promise { - // Send a dummy transaction and wait until the new L1 batch is created. - const oldReceipt = await anyTransaction(wallet); + const MAX_ATTEMPTS = 3; + + let txResponse = null; + let txReceipt = null; + for (let i = 0; i < MAX_ATTEMPTS; i++) { + // Send a dummy transaction and wait for it to execute. We override `maxFeePerGas` as the default ethers behavior + // is to fetch `maxFeePerGas` from the latest sealed block and double it which is not enough for scenarios with + // extreme gas price fluctuations. + let gasPrice = await wallet.provider.getGasPrice(); + if (!txResponse || txResponse.maxFeePerGas != gasPrice) { + txResponse = await wallet.transfer({ + to: wallet.address, + amount: 0, + overrides: { maxFeePerGas: gasPrice, maxPriorityFeePerGas: 0 } + }); + } else { + console.log('Gas price has not changed, waiting longer'); + } + txReceipt = await Promise.race([ + txResponse.wait().then((receipt) => receipt as TransactionReceipt | null), + new Promise((resolve) => setTimeout(() => resolve(null), 3000)) + ]); + if (txReceipt) { + // Transaction got executed, so we can safely assume it will be sealed in the next batch + break; + } else { + console.log(`Transaction timed out (attempt ${i + 1}/${MAX_ATTEMPTS})`); + } + } + if (!txReceipt) { + throw new Error('Failed to force an L1 batch to seal'); + } // Invariant: even with 1 transaction, l1 batch must be eventually sealed, so this loop must exit. - while (!(await wallet.provider.getTransactionReceipt(oldReceipt.hash))?.l1BatchNumber) { + while (!(await wallet.provider.getTransactionReceipt(txReceipt.hash))?.l1BatchNumber) { await zksync.utils.sleep(wallet.provider.pollingInterval); } - return (await wallet.provider.getTransactionReceipt(oldReceipt.hash))!; + return (await wallet.provider.getTransactionReceipt(txReceipt.hash))!; } /** diff --git a/core/tests/ts-integration/tests/fees.test.ts b/core/tests/ts-integration/tests/fees.test.ts index fc156e03f16d..76ce72655956 100644 --- a/core/tests/ts-integration/tests/fees.test.ts +++ b/core/tests/ts-integration/tests/fees.test.ts @@ -362,6 +362,9 @@ testFees('Test fees', function () { newPubdataPrice: requiredPubdataPrice }); + // Wait for current batch to close so gas price is updated with the new config set above + await waitForNewL1Batch(alice); + const l1Messenger = new ethers.Contract(zksync.utils.L1_MESSENGER_ADDRESS, zksync.utils.L1_MESSENGER, alice); // Firstly, let's test a successful transaction. From 2f00ddbc3d10bbfd513d72b92f8c870c75519686 Mon Sep 17 00:00:00 2001 From: Daniyar Itegulov Date: Tue, 7 Jan 2025 18:44:54 +1100 Subject: [PATCH 15/19] clarify fetch source comments --- core/node/api_server/src/web3/tests/vm.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/node/api_server/src/web3/tests/vm.rs b/core/node/api_server/src/web3/tests/vm.rs index 62a2ecaed42d..76c49f7ad6db 100644 --- a/core/node/api_server/src/web3/tests/vm.rs +++ b/core/node/api_server/src/web3/tests/vm.rs @@ -753,7 +753,7 @@ impl HttpTest for TraceCallTest { ) -> anyhow::Result<()> { // Store an additional L2 block because L2 block #0 has some special processing making it work incorrectly. // First half of the test asserts API server's behavior when there is no open batch. In other words, - // when `ApiFeeInputProvider` is forced to fetch fee params from the main node. + // when `ApiFeeInputProvider` is forced to fetch fee params from the main fee provider. let mut connection = pool.connection().await?; store_l2_block(&mut connection, L2BlockNumber(1), &[]).await?; seal_l1_batch(&mut connection, L1BatchNumber(1)).await?; @@ -949,7 +949,7 @@ impl HttpTest for TraceCallTestWithEvmEmulator { ) -> anyhow::Result<()> { // Store an additional L2 block because L2 block #0 has some special processing making it work incorrectly. // And make sure there is no open batch so that `ApiFeeInputProvider` is forced to fetch fee params from - // the main node. + // the main fee provider. let mut connection = pool.connection().await?; let block_header = L2BlockHeader { base_system_contracts_hashes: genesis_contract_hashes(&mut connection).await?, From 0375ff7a3c26aed2d1e78959737d72156c601ce6 Mon Sep 17 00:00:00 2001 From: Daniyar Itegulov Date: Thu, 9 Jan 2025 23:12:32 +1100 Subject: [PATCH 16/19] reuse nonce when replacing tx --- core/tests/ts-integration/src/helpers.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/tests/ts-integration/src/helpers.ts b/core/tests/ts-integration/src/helpers.ts index 0bdd037715e4..2603bd121e47 100644 --- a/core/tests/ts-integration/src/helpers.ts +++ b/core/tests/ts-integration/src/helpers.ts @@ -76,6 +76,7 @@ export async function waitForNewL1Batch(wallet: zksync.Wallet): Promise Date: Fri, 10 Jan 2025 00:21:37 +1100 Subject: [PATCH 17/19] only replace tx when gas price goes up --- core/tests/ts-integration/src/helpers.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/tests/ts-integration/src/helpers.ts b/core/tests/ts-integration/src/helpers.ts index 2603bd121e47..d81a1e6ceb71 100644 --- a/core/tests/ts-integration/src/helpers.ts +++ b/core/tests/ts-integration/src/helpers.ts @@ -82,14 +82,14 @@ export async function waitForNewL1Batch(wallet: zksync.Wallet): Promise receipt as TransactionReceipt | null), From a3081dcb6d56b61d8478533813cb0656e60b5e7b Mon Sep 17 00:00:00 2001 From: Daniyar Itegulov Date: Fri, 10 Jan 2025 12:47:41 +1100 Subject: [PATCH 18/19] replace ad-hoc timeout logic with base ethers --- core/tests/ts-integration/src/helpers.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/core/tests/ts-integration/src/helpers.ts b/core/tests/ts-integration/src/helpers.ts index d81a1e6ceb71..34f6cdfa89c6 100644 --- a/core/tests/ts-integration/src/helpers.ts +++ b/core/tests/ts-integration/src/helpers.ts @@ -3,7 +3,7 @@ import * as zksync from 'zksync-ethers'; import * as ethers from 'ethers'; import * as hre from 'hardhat'; import { ZkSyncArtifact } from '@matterlabs/hardhat-zksync-solc/dist/src/types'; -import { TransactionReceipt } from 'zksync-ethers/build/types'; +import { TimeoutError } from 'ethers/src.ts/utils/errors'; export const SYSTEM_CONTEXT_ADDRESS = '0x000000000000000000000000000000000000800b'; @@ -91,10 +91,7 @@ export async function waitForNewL1Batch(wallet: zksync.Wallet): Promise receipt as TransactionReceipt | null), - new Promise((resolve) => setTimeout(() => resolve(null), 3000)) - ]); + txReceipt = await wallet.provider.waitForTransaction(txResponse.hash, 1, 3000).catch((_: TimeoutError) => null); if (txReceipt) { // Transaction got executed, so we can safely assume it will be sealed in the next batch break; From ac5572247a992119b6a4ff2bbfe51a6299de0c13 Mon Sep 17 00:00:00 2001 From: Daniyar Itegulov Date: Fri, 10 Jan 2025 20:38:25 +1100 Subject: [PATCH 19/19] account for gas estimation difference during spikes --- core/tests/ts-integration/src/helpers.ts | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/core/tests/ts-integration/src/helpers.ts b/core/tests/ts-integration/src/helpers.ts index 34f6cdfa89c6..d1d84d54a545 100644 --- a/core/tests/ts-integration/src/helpers.ts +++ b/core/tests/ts-integration/src/helpers.ts @@ -3,7 +3,7 @@ import * as zksync from 'zksync-ethers'; import * as ethers from 'ethers'; import * as hre from 'hardhat'; import { ZkSyncArtifact } from '@matterlabs/hardhat-zksync-solc/dist/src/types'; -import { TimeoutError } from 'ethers/src.ts/utils/errors'; +import { TransactionReceipt } from 'ethers'; export const SYSTEM_CONTEXT_ADDRESS = '0x000000000000000000000000000000000000800b'; @@ -75,7 +75,7 @@ export async function waitForNewL1Batch(wallet: zksync.Wallet): Promise null); + txReceipt = await wallet.provider.waitForTransaction(txResponse.hash, 1, 3000).catch((e) => { + if (ethers.isError(e, 'TIMEOUT')) { + console.log(`Transaction timed out, potentially gas price went up (attempt ${i + 1}/${MAX_ATTEMPTS})`); + return null; + } else if (ethers.isError(e, 'UNKNOWN_ERROR') && e.message.match(/Not enough gas/)) { + console.log( + `Transaction did not have enough gas, likely gas price went up (attempt ${i + 1}/${MAX_ATTEMPTS})` + ); + return null; + } else { + return Promise.reject(e); + } + }); if (txReceipt) { // Transaction got executed, so we can safely assume it will be sealed in the next batch break; - } else { - console.log(`Transaction timed out (attempt ${i + 1}/${MAX_ATTEMPTS})`); } } if (!txReceipt) {