Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(protocol): Remove verifier address from protocol upgrade #1443

Merged
merged 2 commits into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE protocol_versions
ALTER COLUMN verifier_address SET NOT NULL;
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE protocol_versions
ALTER COLUMN verifier_address DROP NOT NULL;
6 changes: 3 additions & 3 deletions core/lib/dal/src/models/storage_protocol_version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use zksync_contracts::BaseSystemContractsHashes;
use zksync_types::{
api,
protocol_version::{self, L1VerifierConfig, ProtocolUpgradeTx, VerifierParams},
Address, H256,
H256,
};

#[derive(sqlx::FromRow)]
Expand All @@ -18,7 +18,8 @@ pub struct StorageProtocolVersion {
pub recursion_circuits_set_vks_hash: Vec<u8>,
pub bootloader_code_hash: Vec<u8>,
pub default_account_code_hash: Vec<u8>,
pub verifier_address: Vec<u8>,
// deprecated
pub verifier_address: Option<Vec<u8>>,
pub created_at: NaiveDateTime,
pub upgrade_tx_hash: Option<Vec<u8>>,
}
Expand Down Expand Up @@ -50,7 +51,6 @@ pub(crate) fn protocol_version_from_storage(
bootloader: H256::from_slice(&storage_version.bootloader_code_hash),
default_aa: H256::from_slice(&storage_version.default_account_code_hash),
},
verifier_address: Address::from_slice(&storage_version.verifier_address),
tx,
}
}
Expand Down
8 changes: 2 additions & 6 deletions core/lib/dal/src/protocol_versions_dal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use anyhow::Context as _;
use zksync_contracts::{BaseSystemContracts, BaseSystemContractsHashes};
use zksync_types::{
protocol_version::{L1VerifierConfig, ProtocolUpgradeTx, ProtocolVersion, VerifierParams},
Address, ProtocolVersionId, H256,
ProtocolVersionId, H256,
};

use crate::{
Expand All @@ -24,7 +24,6 @@ impl ProtocolVersionsDal<'_, '_> {
timestamp: u64,
l1_verifier_config: L1VerifierConfig,
base_system_contracts_hashes: BaseSystemContractsHashes,
verifier_address: Address,
tx_hash: Option<H256>,
) {
sqlx::query!(
Expand All @@ -39,12 +38,11 @@ impl ProtocolVersionsDal<'_, '_> {
recursion_circuits_set_vks_hash,
bootloader_code_hash,
default_account_code_hash,
verifier_address,
upgrade_tx_hash,
created_at
)
VALUES
($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, NOW())
($1, $2, $3, $4, $5, $6, $7, $8, $9, NOW())
"#,
id as i32,
timestamp as i64,
Expand All @@ -65,7 +63,6 @@ impl ProtocolVersionsDal<'_, '_> {
.as_bytes(),
base_system_contracts_hashes.bootloader.as_bytes(),
base_system_contracts_hashes.default_aa.as_bytes(),
verifier_address.as_bytes(),
tx_hash.as_ref().map(H256::as_bytes),
)
.execute(self.storage.conn())
Expand All @@ -91,7 +88,6 @@ impl ProtocolVersionsDal<'_, '_> {
version.timestamp,
version.l1_verifier_config,
version.base_system_contracts_hashes,
version.verifier_address,
tx_hash,
)
.await;
Expand Down
3 changes: 0 additions & 3 deletions core/lib/types/src/protocol_version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -688,8 +688,6 @@ pub struct ProtocolVersion {
pub l1_verifier_config: L1VerifierConfig,
/// Hashes of base system contracts (bootloader and default account)
pub base_system_contracts_hashes: BaseSystemContractsHashes,
/// Verifier contract address on L1
pub verifier_address: Address,
/// L2 Upgrade transaction.
pub tx: Option<ProtocolUpgradeTx>,
}
Expand Down Expand Up @@ -719,7 +717,6 @@ impl ProtocolVersion {
.default_account_code_hash
.unwrap_or(self.base_system_contracts_hashes.default_aa),
},
verifier_address: upgrade.verifier_address.unwrap_or(self.verifier_address),
tx: upgrade.tx,
}
}
Expand Down
8 changes: 0 additions & 8 deletions core/lib/zksync_core/src/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ pub struct GenesisParams {
pub protocol_version: ProtocolVersionId,
pub base_system_contracts: BaseSystemContracts,
pub system_contracts: Vec<DeployedContract>,
pub first_verifier_address: Address,
pub first_l1_verifier_config: L1VerifierConfig,
}

Expand All @@ -53,7 +52,6 @@ impl GenesisParams {
base_system_contracts: BaseSystemContracts::load_from_disk(),
system_contracts: get_system_smart_contracts(),
first_l1_verifier_config: L1VerifierConfig::default(),
first_verifier_address: Address::zero(),
}
}
}
Expand Down Expand Up @@ -82,7 +80,6 @@ pub async fn ensure_genesis_state(
protocol_version,
base_system_contracts,
system_contracts,
first_verifier_address,
first_l1_verifier_config,
} = genesis_params;

Expand All @@ -96,7 +93,6 @@ pub async fn ensure_genesis_state(
base_system_contracts,
system_contracts,
*first_l1_verifier_config,
*first_verifier_address,
)
.await?;
tracing::info!("chain_schema_genesis is complete");
Expand Down Expand Up @@ -295,14 +291,12 @@ pub(crate) async fn create_genesis_l1_batch(
base_system_contracts: &BaseSystemContracts,
system_contracts: &[DeployedContract],
l1_verifier_config: L1VerifierConfig,
verifier_address: Address,
) -> anyhow::Result<()> {
let version = ProtocolVersion {
id: protocol_version,
timestamp: 0,
l1_verifier_config,
base_system_contracts_hashes: base_system_contracts.hashes(),
verifier_address,
tx: None,
};

Expand Down Expand Up @@ -478,7 +472,6 @@ mod tests {
base_system_contracts: BaseSystemContracts::load_from_disk(),
system_contracts: get_system_smart_contracts(),
first_l1_verifier_config: L1VerifierConfig::default(),
first_verifier_address: Address::random(),
};
ensure_genesis_state(&mut conn, L2ChainId::from(270), &params)
.await
Expand Down Expand Up @@ -511,7 +504,6 @@ mod tests {
base_system_contracts: BaseSystemContracts::load_from_disk(),
system_contracts: get_system_smart_contracts(),
first_l1_verifier_config: L1VerifierConfig::default(),
first_verifier_address: Address::random(),
};
ensure_genesis_state(&mut conn, L2ChainId::max(), &params)
.await
Expand Down
1 change: 0 additions & 1 deletion core/lib/zksync_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ pub async fn genesis_init(
protocol_version: ProtocolVersionId::latest(),
base_system_contracts: BaseSystemContracts::load_from_disk(),
system_contracts: get_system_smart_contracts(),
first_verifier_address: contracts_config.verifier_addr,
first_l1_verifier_config,
},
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ impl Tester {
&BASE_SYSTEM_CONTRACTS,
&get_system_smart_contracts(),
Default::default(),
Default::default(),
)
.await
.unwrap();
Expand Down
1 change: 0 additions & 1 deletion core/lib/zksync_core/src/state_keeper/io/tests/tester.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ impl Tester {
&self.base_system_contracts,
&get_system_smart_contracts(),
L1VerifierConfig::default(),
Address::zero(),
)
.await
.unwrap();
Expand Down
2 changes: 0 additions & 2 deletions core/lib/zksync_core/src/sync_layer/external_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,6 @@ impl ExternalIO {
protocol_version.timestamp,
protocol_version.verification_keys_hashes,
protocol_version.base_system_contracts,
// Verifier is not used in the external node, so we can pass an empty
Default::default(),
protocol_version.l2_system_upgrade_tx_hash,
)
.await;
Expand Down
5 changes: 1 addition & 4 deletions core/lib/zksync_core/src/sync_layer/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ use zksync_contracts::{BaseSystemContracts, BaseSystemContractsHashes, SystemCon
use zksync_dal::StorageProcessor;
use zksync_types::{
block::DeployedContract, protocol_version::L1VerifierConfig,
system_contracts::get_system_smart_contracts, AccountTreeId, Address, L1BatchNumber, L2ChainId,
H256,
system_contracts::get_system_smart_contracts, AccountTreeId, L1BatchNumber, L2ChainId, H256,
};

use super::client::MainNodeClient;
Expand Down Expand Up @@ -87,14 +86,12 @@ async fn create_genesis_params(client: &dyn MainNodeClient) -> anyhow::Result<Ge

// Use default L1 verifier config and verifier address for genesis as they are not used by EN.
let first_l1_verifier_config = L1VerifierConfig::default();
let first_verifier_address = Address::default();
Ok(GenesisParams {
protocol_version,
base_system_contracts,
system_contracts,
first_validator,
first_l1_verifier_config,
first_verifier_address,
})
}

Expand Down
Loading