diff --git a/core/bin/zksync_server/src/node_builder.rs b/core/bin/zksync_server/src/node_builder.rs
index 7c4503876e9d..e713db65c77f 100644
--- a/core/bin/zksync_server/src/node_builder.rs
+++ b/core/bin/zksync_server/src/node_builder.rs
@@ -434,6 +434,11 @@ impl MainNodeBuilder {
self.contracts_config.clone(),
self.genesis_config.l2_chain_id,
self.genesis_config.l1_batch_commit_data_generator_mode,
+ self.configs
+ .eth
+ .as_ref()
+ .and_then(|x| Some(x.gas_adjuster?.settlement_mode))
+ .unwrap_or(SettlementMode::SettlesToL1),
));
Ok(self)
diff --git a/core/lib/dal/.sqlx/query-0fede71ed258790cf70d6d6a32dcf9654c06dfef57863281601c947830ad448a.json b/core/lib/dal/.sqlx/query-0fede71ed258790cf70d6d6a32dcf9654c06dfef57863281601c947830ad448a.json
index cdf425de713b..6a3174958db8 100644
--- a/core/lib/dal/.sqlx/query-0fede71ed258790cf70d6d6a32dcf9654c06dfef57863281601c947830ad448a.json
+++ b/core/lib/dal/.sqlx/query-0fede71ed258790cf70d6d6a32dcf9654c06dfef57863281601c947830ad448a.json
@@ -77,6 +77,11 @@
"ordinal": 14,
"name": "is_gateway",
"type_info": "Bool"
+ },
+ {
+ "ordinal": 15,
+ "name": "chain_id",
+ "type_info": "Int8"
}
],
"parameters": {
@@ -106,7 +111,8 @@
false,
true,
true,
- false
+ false,
+ true
]
},
"hash": "0fede71ed258790cf70d6d6a32dcf9654c06dfef57863281601c947830ad448a"
diff --git a/core/lib/dal/.sqlx/query-254d17b5402c123cca0edd6fcdc98012b034605dfb4c48379844085b71e9e381.json b/core/lib/dal/.sqlx/query-254d17b5402c123cca0edd6fcdc98012b034605dfb4c48379844085b71e9e381.json
deleted file mode 100644
index 8734598cc6f6..000000000000
--- a/core/lib/dal/.sqlx/query-254d17b5402c123cca0edd6fcdc98012b034605dfb4c48379844085b71e9e381.json
+++ /dev/null
@@ -1,22 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "SELECT nonce FROM eth_txs WHERE from_addr = $1::bytea ORDER BY id DESC LIMIT 1",
- "describe": {
- "columns": [
- {
- "ordinal": 0,
- "name": "nonce",
- "type_info": "Int8"
- }
- ],
- "parameters": {
- "Left": [
- "Bytea"
- ]
- },
- "nullable": [
- false
- ]
- },
- "hash": "254d17b5402c123cca0edd6fcdc98012b034605dfb4c48379844085b71e9e381"
-}
diff --git a/core/lib/dal/.sqlx/query-45372b701c23ce782695f11f846a75893ee5b1b94b6d0f25f1db5342888a2a30.json b/core/lib/dal/.sqlx/query-45372b701c23ce782695f11f846a75893ee5b1b94b6d0f25f1db5342888a2a30.json
new file mode 100644
index 000000000000..0567a415ac16
--- /dev/null
+++ b/core/lib/dal/.sqlx/query-45372b701c23ce782695f11f846a75893ee5b1b94b6d0f25f1db5342888a2a30.json
@@ -0,0 +1,15 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n UPDATE eth_txs\n SET\n chain_id = $1\n WHERE\n id = $2\n ",
+ "describe": {
+ "columns": [],
+ "parameters": {
+ "Left": [
+ "Int8",
+ "Int4"
+ ]
+ },
+ "nullable": []
+ },
+ "hash": "45372b701c23ce782695f11f846a75893ee5b1b94b6d0f25f1db5342888a2a30"
+}
diff --git a/core/lib/dal/.sqlx/query-4aeb7dcd79000540c03fb12c0608ab71005d70f13ed32172e47166f71b3aef80.json b/core/lib/dal/.sqlx/query-4aeb7dcd79000540c03fb12c0608ab71005d70f13ed32172e47166f71b3aef80.json
new file mode 100644
index 000000000000..feb8f29855e4
--- /dev/null
+++ b/core/lib/dal/.sqlx/query-4aeb7dcd79000540c03fb12c0608ab71005d70f13ed32172e47166f71b3aef80.json
@@ -0,0 +1,23 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n SELECT\n nonce\n FROM\n eth_txs\n WHERE\n from_addr IS NOT DISTINCT FROM $1 -- can't just use equality as NULL != NULL\\\n AND is_gateway = $2\n ORDER BY\n id DESC\n LIMIT\n 1\n ",
+ "describe": {
+ "columns": [
+ {
+ "ordinal": 0,
+ "name": "nonce",
+ "type_info": "Int8"
+ }
+ ],
+ "parameters": {
+ "Left": [
+ "Bytea",
+ "Bool"
+ ]
+ },
+ "nullable": [
+ false
+ ]
+ },
+ "hash": "4aeb7dcd79000540c03fb12c0608ab71005d70f13ed32172e47166f71b3aef80"
+}
diff --git a/core/lib/dal/.sqlx/query-6692ff6c0fbb2fc94f5cd2837a43ce80f9b2b27758651ccfc09df61a4ae8a363.json b/core/lib/dal/.sqlx/query-6692ff6c0fbb2fc94f5cd2837a43ce80f9b2b27758651ccfc09df61a4ae8a363.json
index 49578cd67bec..1a3c160cee1b 100644
--- a/core/lib/dal/.sqlx/query-6692ff6c0fbb2fc94f5cd2837a43ce80f9b2b27758651ccfc09df61a4ae8a363.json
+++ b/core/lib/dal/.sqlx/query-6692ff6c0fbb2fc94f5cd2837a43ce80f9b2b27758651ccfc09df61a4ae8a363.json
@@ -77,6 +77,11 @@
"ordinal": 14,
"name": "is_gateway",
"type_info": "Bool"
+ },
+ {
+ "ordinal": 15,
+ "name": "chain_id",
+ "type_info": "Int8"
}
],
"parameters": {
@@ -99,7 +104,8 @@
false,
true,
true,
- false
+ false,
+ true
]
},
"hash": "6692ff6c0fbb2fc94f5cd2837a43ce80f9b2b27758651ccfc09df61a4ae8a363"
diff --git a/core/lib/dal/.sqlx/query-93725851350146c6ec253a59af598fa893dbc9654d15753e4a538f021af67b60.json b/core/lib/dal/.sqlx/query-93725851350146c6ec253a59af598fa893dbc9654d15753e4a538f021af67b60.json
deleted file mode 100644
index 80788846fe69..000000000000
--- a/core/lib/dal/.sqlx/query-93725851350146c6ec253a59af598fa893dbc9654d15753e4a538f021af67b60.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "SELECT nonce FROM eth_txs WHERE from_addr IS NULL ORDER BY id DESC LIMIT 1",
- "describe": {
- "columns": [
- {
- "ordinal": 0,
- "name": "nonce",
- "type_info": "Int8"
- }
- ],
- "parameters": {
- "Left": []
- },
- "nullable": [
- false
- ]
- },
- "hash": "93725851350146c6ec253a59af598fa893dbc9654d15753e4a538f021af67b60"
-}
diff --git a/core/lib/dal/.sqlx/query-a71a87d91dcf0f624dbd64eb8828f65ff83204ebab2ea31847ae305a098823b0.json b/core/lib/dal/.sqlx/query-a71a87d91dcf0f624dbd64eb8828f65ff83204ebab2ea31847ae305a098823b0.json
index 28058b9e42a7..272f20e5268a 100644
--- a/core/lib/dal/.sqlx/query-a71a87d91dcf0f624dbd64eb8828f65ff83204ebab2ea31847ae305a098823b0.json
+++ b/core/lib/dal/.sqlx/query-a71a87d91dcf0f624dbd64eb8828f65ff83204ebab2ea31847ae305a098823b0.json
@@ -77,6 +77,11 @@
"ordinal": 14,
"name": "is_gateway",
"type_info": "Bool"
+ },
+ {
+ "ordinal": 15,
+ "name": "chain_id",
+ "type_info": "Int8"
}
],
"parameters": {
@@ -100,7 +105,8 @@
false,
true,
true,
- false
+ false,
+ true
]
},
"hash": "a71a87d91dcf0f624dbd64eb8828f65ff83204ebab2ea31847ae305a098823b0"
diff --git a/core/lib/dal/.sqlx/query-eab36591af61369e36e3dab79025ac6758a0a4e367f93a9bd48ec82c51e09755.json b/core/lib/dal/.sqlx/query-eab36591af61369e36e3dab79025ac6758a0a4e367f93a9bd48ec82c51e09755.json
index fb6ea1d2d3e5..b9783f771a7a 100644
--- a/core/lib/dal/.sqlx/query-eab36591af61369e36e3dab79025ac6758a0a4e367f93a9bd48ec82c51e09755.json
+++ b/core/lib/dal/.sqlx/query-eab36591af61369e36e3dab79025ac6758a0a4e367f93a9bd48ec82c51e09755.json
@@ -77,6 +77,11 @@
"ordinal": 14,
"name": "is_gateway",
"type_info": "Bool"
+ },
+ {
+ "ordinal": 15,
+ "name": "chain_id",
+ "type_info": "Int8"
}
],
"parameters": {
@@ -101,7 +106,8 @@
false,
true,
true,
- false
+ false,
+ true
]
},
"hash": "eab36591af61369e36e3dab79025ac6758a0a4e367f93a9bd48ec82c51e09755"
diff --git a/core/lib/dal/migrations/20240819150019_add_chain_id_to_eth_txs.down.sql b/core/lib/dal/migrations/20240819150019_add_chain_id_to_eth_txs.down.sql
new file mode 100644
index 000000000000..65fcdc9cfcdf
--- /dev/null
+++ b/core/lib/dal/migrations/20240819150019_add_chain_id_to_eth_txs.down.sql
@@ -0,0 +1 @@
+ALTER TABLE eth_txs DROP COLUMN chain_id;
diff --git a/core/lib/dal/migrations/20240819150019_add_chain_id_to_eth_txs.up.sql b/core/lib/dal/migrations/20240819150019_add_chain_id_to_eth_txs.up.sql
new file mode 100644
index 000000000000..bbcfe41a58c1
--- /dev/null
+++ b/core/lib/dal/migrations/20240819150019_add_chain_id_to_eth_txs.up.sql
@@ -0,0 +1 @@
+ALTER TABLE eth_txs ADD COLUMN chain_id BIGINT;
diff --git a/core/lib/dal/src/eth_sender_dal.rs b/core/lib/dal/src/eth_sender_dal.rs
index eb7e1cd642c1..c76547422d8f 100644
--- a/core/lib/dal/src/eth_sender_dal.rs
+++ b/core/lib/dal/src/eth_sender_dal.rs
@@ -404,6 +404,23 @@ impl EthSenderDal<'_, '_> {
Ok(())
}
+ pub async fn set_chain_id(&mut self, eth_tx_id: u32, chain_id: u64) -> anyhow::Result<()> {
+ sqlx::query!(
+ r#"
+ UPDATE eth_txs
+ SET
+ chain_id = $1
+ WHERE
+ id = $2
+ "#,
+ eth_tx_id as i32,
+ chain_id as i64,
+ )
+ .execute(self.storage.conn())
+ .await?;
+ Ok(())
+ }
+
pub async fn get_confirmed_tx_hash_by_eth_tx_id(
&mut self,
eth_tx_id: u32,
@@ -610,29 +627,29 @@ impl EthSenderDal<'_, '_> {
pub async fn get_next_nonce(
&mut self,
from_address: Option
,
+ is_gateway: bool,
) -> sqlx::Result