diff --git a/.github/scripts/gateway.sh b/.github/scripts/gateway.sh
new file mode 100755
index 00000000000..ed9e8a32dc8
--- /dev/null
+++ b/.github/scripts/gateway.sh
@@ -0,0 +1,50 @@
+sudo rm -rf ./volumes && zk_supervisor clean containers && zk_inception up -o false
+
+zk_inception ecosystem init --deploy-paymaster --deploy-erc20 \
+ --deploy-ecosystem --l1-rpc-url=http://localhost:8545 \
+ --server-db-url=postgres://postgres:notsecurepassword@localhost:5432 \
+ --server-db-name=zksync_server_localhost_era \
+ --prover-db-url=postgres://postgres:notsecurepassword@localhost:5432 \
+ --prover-db-name=zksync_prover_localhost_era \
+ --ignore-prerequisites --observability=false --skip-submodules-checkout \
+ --chain era \
+ # --skip-contract-compilation-override \
+
+zk_inception chain create \
+ --chain-name gateway \
+ --chain-id 505 \
+ --prover-mode no-proofs \
+ --wallet-creation localhost \
+ --l1-batch-commit-data-generator-mode rollup \
+ --base-token-address 0x0000000000000000000000000000000000000001 \
+ --base-token-price-nominator 1 \
+ --base-token-price-denominator 1 \
+ --set-as-default false \
+ --ignore-prerequisites --skip-submodules-checkout --skip-contract-compilation-override
+
+zk_inception chain init \
+ --deploy-paymaster \
+ --l1-rpc-url=http://localhost:8545 \
+ --server-db-url=postgres://postgres:notsecurepassword@localhost:5432 \
+ --server-db-name=zksync_server_localhost_gateway \
+ --prover-db-url=postgres://postgres:notsecurepassword@localhost:5432 \
+ --prover-db-name=zksync_prover_localhost_gateway \
+ --chain gateway --skip-submodules-checkout
+
+zk_inception chain convert-to-gateway --chain gateway --ignore-prerequisites
+
+zk_inception server --ignore-prerequisites --chain gateway &> ./gateway.log &
+
+sleep 20
+
+zk_inception chain migrate-to-gateway --chain era --gateway-chain-name gateway
+
+zk_inception chain migrate-from-gateway --chain era --gateway-chain-name gateway
+
+zk_inception chain migrate-to-gateway --chain era --gateway-chain-name gateway
+
+zk_inception server --ignore-prerequisites --chain era &> ./rollup.log &
+
+sleep 20
+
+zk_supervisor test integration --no-deps --ignore-prerequisites --chain era
diff --git a/.github/workflows/ci-core-reusable.yml b/.github/workflows/ci-core-reusable.yml
index ba6548dd143..fed26bbbb3b 100644
--- a/.github/workflows/ci-core-reusable.yml
+++ b/.github/workflows/ci-core-reusable.yml
@@ -313,6 +313,14 @@ jobs:
ci_run zk_inception chain migrate-to-gateway --chain era --gateway-chain-name gateway
ci_run zk_inception chain migrate-to-gateway --chain validium --gateway-chain-name gateway
ci_run zk_inception chain migrate-to-gateway --chain custom_token --gateway-chain-name gateway
+
+ - name: Migrate back era
+ run: |
+ ci_run zk_inception chain migrate-from-gateway --chain era --gateway-chain-name gateway
+
+ - name: Migrate to gateway again
+ run: |
+ ci_run zk_inception chain migrate-to-gateway --chain era --gateway-chain-name gateway
- name: Build test dependencies
run: |
diff --git a/contracts b/contracts
index c3030f58e6c..53b0283f82f 160000
--- a/contracts
+++ b/contracts
@@ -1 +1 @@
-Subproject commit c3030f58e6c13fb523cdc2fa5c095fa2f49c0666
+Subproject commit 53b0283f82f4262c973eb3faed56ee8f6cda47b9
diff --git a/core/lib/config/src/configs/contracts.rs b/core/lib/config/src/configs/contracts.rs
index 2a17f74265d..24f50243758 100644
--- a/core/lib/config/src/configs/contracts.rs
+++ b/core/lib/config/src/configs/contracts.rs
@@ -53,6 +53,8 @@ pub struct ContractsConfig {
pub l2_da_validator_addr: Option
,
pub chain_admin_addr: Option,
+
+ pub settlement_layer: Option,
}
impl ContractsConfig {
@@ -78,6 +80,7 @@ impl ContractsConfig {
user_facing_diamond_proxy_addr: Some(Address::repeat_byte(0x16)),
chain_admin_addr: Some(Address::repeat_byte(0x18)),
l2_da_validator_addr: Some(Address::repeat_byte(0x19)),
+ settlement_layer: Some(0),
}
}
}
diff --git a/core/lib/config/src/configs/gateway.rs b/core/lib/config/src/configs/gateway.rs
index bf2f362ae26..cc0cdcc1d6a 100644
--- a/core/lib/config/src/configs/gateway.rs
+++ b/core/lib/config/src/configs/gateway.rs
@@ -30,6 +30,7 @@ pub struct GatewayChainConfig {
pub diamond_proxy_addr: Address,
pub chain_admin_addr: Option,
pub governance_addr: Address,
+ pub settlement_layer: u64,
}
impl GatewayChainConfig {
@@ -37,6 +38,7 @@ impl GatewayChainConfig {
gateway_config: &GatewayConfig,
diamond_proxy_addr: Address,
chain_admin_addr: Address,
+ settlement_layer: u64,
) -> Self {
// FIXME: there is no "governnace" for a chain, only an admin, we
// need to figure out what we mean here
@@ -48,6 +50,7 @@ impl GatewayChainConfig {
diamond_proxy_addr,
chain_admin_addr: Some(chain_admin_addr),
governance_addr: chain_admin_addr,
+ settlement_layer,
}
}
}
@@ -64,6 +67,7 @@ impl From for GatewayChainConfig {
diamond_proxy_addr: value.diamond_proxy_addr,
chain_admin_addr: value.chain_admin_addr,
governance_addr: value.governance_addr,
+ settlement_layer: value.settlement_layer.unwrap(),
}
}
}
diff --git a/core/lib/config/src/testonly.rs b/core/lib/config/src/testonly.rs
index f16f5fa2375..0dca7335d1b 100644
--- a/core/lib/config/src/testonly.rs
+++ b/core/lib/config/src/testonly.rs
@@ -266,6 +266,7 @@ impl Distribution for EncodeDist {
l2_da_validator_addr: rng.gen(),
base_token_addr: self.sample_opt(|| rng.gen()),
chain_admin_addr: self.sample_opt(|| rng.gen()),
+ settlement_layer: self.sample_opt(|| rng.gen()),
}
}
}
diff --git a/core/lib/env_config/src/contracts.rs b/core/lib/env_config/src/contracts.rs
index b9ca4e88d07..a386adad1df 100644
--- a/core/lib/env_config/src/contracts.rs
+++ b/core/lib/env_config/src/contracts.rs
@@ -98,6 +98,7 @@ mod tests {
)),
chain_admin_addr: Some(addr("0xdd6fa5c14e7550b4caf2aa2818d24c69cbc347ff")),
l2_da_validator_addr: Some(addr("0xed6fa5c14e7550b4caf2aa2818d24c69cbc347ff")),
+ settlement_layer: Some(0),
}
}
@@ -129,6 +130,7 @@ CONTRACTS_USER_FACING_DIAMOND_PROXY_ADDR="0xF00B988a98Ca742e7958DeF9F7823b590871
CONTRACTS_L2_NATIVE_TOKEN_VAULT_PROXY_ADDR="0xfc073319977e314f251eae6ae6be76b0b3baeecf"
CONTRACTS_L2_DA_VALIDATOR_ADDR="0xed6fa5c14e7550b4caf2aa2818d24c69cbc347ff"
CONTRACTS_CHAIN_ADMIN_ADDR="0xdd6fa5c14e7550b4caf2aa2818d24c69cbc347ff"
+CONTRACTS_SETTLEMENT_LAYER="0"
"#;
lock.set_env(config);
diff --git a/core/lib/protobuf_config/src/contracts.rs b/core/lib/protobuf_config/src/contracts.rs
index f9670ead838..3141c7149ec 100644
--- a/core/lib/protobuf_config/src/contracts.rs
+++ b/core/lib/protobuf_config/src/contracts.rs
@@ -131,6 +131,7 @@ impl ProtoRepr for proto::Contracts {
.map(|x| parse_h160(x))
.transpose()
.context("chain_admin_addr")?,
+ settlement_layer: self.settlement_layer,
})
}
@@ -191,6 +192,7 @@ impl ProtoRepr for proto::Contracts {
user_facing_diamond_proxy: this
.user_facing_diamond_proxy_addr
.map(|a| format!("{:?}", a)),
+ settlement_layer: this.settlement_layer,
}
}
}
diff --git a/core/lib/protobuf_config/src/gateway.rs b/core/lib/protobuf_config/src/gateway.rs
index 3e536a9edb6..b0d4cec7d49 100644
--- a/core/lib/protobuf_config/src/gateway.rs
+++ b/core/lib/protobuf_config/src/gateway.rs
@@ -34,6 +34,7 @@ impl ProtoRepr for proto::GatewayChainConfig {
governance_addr: required(&self.governance_addr)
.and_then(|x| parse_h160(x))
.context("governance_addr")?,
+ settlement_layer: *required(&self.settlement_layer)?,
})
}
@@ -45,6 +46,7 @@ impl ProtoRepr for proto::GatewayChainConfig {
diamond_proxy_addr: Some(format!("{:?}", this.diamond_proxy_addr)),
chain_admin_addr: this.chain_admin_addr.map(|x| format!("{:?}", x)),
governance_addr: Some(format!("{:?}", this.governance_addr)),
+ settlement_layer: Some(this.settlement_layer),
}
}
}
diff --git a/core/lib/protobuf_config/src/proto/config/contracts.proto b/core/lib/protobuf_config/src/proto/config/contracts.proto
index 54dda78afe5..11fbdcacdce 100644
--- a/core/lib/protobuf_config/src/proto/config/contracts.proto
+++ b/core/lib/protobuf_config/src/proto/config/contracts.proto
@@ -43,4 +43,5 @@ message Contracts {
optional EcosystemContracts ecosystem_contracts = 4;
optional string user_facing_bridgehub = 5;
optional string user_facing_diamond_proxy = 6;
+ optional uint64 settlement_layer = 7;
}
diff --git a/core/lib/protobuf_config/src/proto/config/gateway.proto b/core/lib/protobuf_config/src/proto/config/gateway.proto
index f39e0ab506e..2acb53677b8 100644
--- a/core/lib/protobuf_config/src/proto/config/gateway.proto
+++ b/core/lib/protobuf_config/src/proto/config/gateway.proto
@@ -9,4 +9,5 @@ message GatewayChainConfig {
optional string diamond_proxy_addr = 4;
optional string chain_admin_addr = 5;
optional string governance_addr = 6;
+ optional uint64 settlement_layer = 7;
}
diff --git a/core/node/api_server/src/web3/namespaces/zks.rs b/core/node/api_server/src/web3/namespaces/zks.rs
index 0d64d26b478..34010785c52 100644
--- a/core/node/api_server/src/web3/namespaces/zks.rs
+++ b/core/node/api_server/src/web3/namespaces/zks.rs
@@ -939,7 +939,6 @@ impl ZksNamespace {
batch_number: L1BatchNumber,
) -> Result