Skip to content

Commit

Permalink
works with newer contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
StanislavBreadless committed Oct 23, 2024
1 parent b59dd1c commit d393c76
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 12 deletions.
2 changes: 1 addition & 1 deletion contracts
Submodule contracts updated 45 files
+7 −25 l1-contracts/contracts/bridge/L2WrappedBaseToken.sol
+19 −0 l1-contracts/contracts/bridge/interfaces/ILegacyBridgedStandardToken.sol
+12 −0 l1-contracts/contracts/common/L1ContractErrors.sol
+2 −1 l1-contracts/contracts/dev-contracts/test/AdminFacetTest.sol
+17 −6 l1-contracts/contracts/state-transition/ChainTypeManager.sol
+3 −0 l1-contracts/contracts/state-transition/IChainTypeManager.sol
+299 −0 l1-contracts/contracts/state-transition/chain-deps/GatewayCTMDeployer.sol
+2 −0 l1-contracts/contracts/state-transition/chain-deps/ZKChainStorage.sol
+26 −6 l1-contracts/contracts/state-transition/chain-deps/facets/Admin.sol
+8 −0 l1-contracts/contracts/state-transition/chain-interfaces/IAdmin.sol
+72 −0 l1-contracts/contracts/state-transition/data-availability/RollupDAManager.sol
+0 −1 l1-contracts/contracts/state-transition/l2-deps/IL2GenesisUpgrade.sol
+1 −2 l1-contracts/contracts/upgrades/GatewayHelper.sol
+121 −0 l1-contracts/contracts/upgrades/GovernanceUpgradeTimer.sol
+1 −2 l1-contracts/contracts/upgrades/L1GenesisUpgrade.sol
+39 −12 l1-contracts/deploy-scripts/DeployL1.s.sol
+23 −6 l1-contracts/deploy-scripts/DeployUtils.s.sol
+346 −0 l1-contracts/deploy-scripts/GatewayCTMDeployerHelper.sol
+111 −40 l1-contracts/deploy-scripts/GatewayCTMFromL1.s.sol
+9 −0 l1-contracts/deploy-scripts/L2ContractsBytecodesLib.sol
+6 −0 l1-contracts/deploy-scripts/Utils.sol
+0 −29 l1-contracts/deploy-scripts/upgrade/ChainUpgrade.s.sol
+65 −51 l1-contracts/deploy-scripts/upgrade/EcosystemUpgrade.s.sol
+6 −1 l1-contracts/deploy-scripts/upgrade/SystemContractsProcessing.s.sol
+0 −81 l1-contracts/script-config/artifacts/BeaconProxy.json
+0 −262 l1-contracts/script-config/artifacts/L2SharedBridge.json
+0 −86 l1-contracts/script-config/artifacts/TransparentUpgradeableProxy.json
+0 −2 l1-contracts/src.ts/deploy.ts
+1 −1 l1-contracts/test/foundry/l1/integration/l2-tests-in-l1-context/_SharedL2ContractDeployer.sol
+1 −1 l1-contracts/test/foundry/l1/integration/l2-tests-in-l1-context/_SharedL2ContractL1DeployerUtils.sol
+2 −1 l1-contracts/test/foundry/l1/unit/concrete/DiamondCut/UpgradeLogic.t.sol
+2 −1 l1-contracts/test/foundry/l1/unit/concrete/Executor/_Executor_Shared.t.sol
+2 −1 l1-contracts/test/foundry/l1/unit/concrete/state-transition/ChainTypeManager/_ChainTypeManager_Shared.t.sol
+2 −1 l1-contracts/test/foundry/l1/unit/concrete/state-transition/chain-deps/facets/Admin/_Admin_Shared.t.sol
+254 −0 l1-contracts/test/foundry/l2/unit/GatewayCTMDeployer/GatewayCTMDeployer.t.sol
+1 −1 system-contracts/SystemContractsHashes.json
+3 −0 system-contracts/contracts/Constants.sol
+38 −25 system-contracts/contracts/L2GatewayUpgrade.sol
+11 −2 system-contracts/contracts/L2GenesisUpgradeHelper.sol
+19 −0 system-contracts/contracts/SloadContract.sol
+3 −3 system-contracts/contracts/interfaces/IL2GenesisUpgrade.sol
+1 −1 system-contracts/contracts/interfaces/IL2SharedBridgeLegacy.sol
+67 −1 system-contracts/contracts/libraries/SystemContractHelper.sol
+9 −1 system-contracts/scripts/constants.ts
+0 −2 system-contracts/test/L2GenesisUpgrade.spec.ts
4 changes: 4 additions & 0 deletions core/lib/constants/src/contracts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ pub const L2_MESSAGE_ROOT_ADDRESS: Address = H160([
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x01, 0x00, 0x05,
]);
pub const SLOAD_CONTRACT_ADDRESS: Address = H160([
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x01, 0x00, 0x06,
]);

pub const ERC20_TRANSFER_TOPIC: H256 = H256([
221, 242, 82, 173, 27, 226, 200, 155, 105, 194, 176, 104, 252, 55, 141, 170, 149, 43, 167, 241,
Expand Down
10 changes: 8 additions & 2 deletions core/lib/types/src/system_contracts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use zksync_system_constants::{
BOOTLOADER_UTILITIES_ADDRESS, CODE_ORACLE_ADDRESS, COMPRESSOR_ADDRESS, CREATE2_FACTORY_ADDRESS,
EVENT_WRITER_ADDRESS, L2_ASSET_ROUTER_ADDRESS, L2_BRIDGEHUB_ADDRESS,
L2_GENESIS_UPGRADE_ADDRESS, L2_MESSAGE_ROOT_ADDRESS, L2_NATIVE_TOKEN_VAULT_ADDRESS,
P256VERIFY_PRECOMPILE_ADDRESS, PUBDATA_CHUNK_PUBLISHER_ADDRESS,
P256VERIFY_PRECOMPILE_ADDRESS, PUBDATA_CHUNK_PUBLISHER_ADDRESS, SLOAD_CONTRACT_ADDRESS,
};

use crate::{
Expand All @@ -27,7 +27,7 @@ use crate::{
pub const TX_NONCE_INCREMENT: U256 = U256([1, 0, 0, 0]); // 1
pub const DEPLOYMENT_NONCE_INCREMENT: U256 = U256([0, 0, 1, 0]); // 2^128

static SYSTEM_CONTRACT_LIST: [(&str, &str, Address, ContractLanguage); 30] = [
static SYSTEM_CONTRACT_LIST: [(&str, &str, Address, ContractLanguage); 31] = [
(
"",
"AccountCodeStorage",
Expand Down Expand Up @@ -200,6 +200,12 @@ static SYSTEM_CONTRACT_LIST: [(&str, &str, Address, ContractLanguage); 30] = [
L2_NATIVE_TOKEN_VAULT_ADDRESS,
ContractLanguage::Sol,
),
(
"",
"SloadContract",
SLOAD_CONTRACT_ADDRESS,
ContractLanguage::Sol,
)
];

static SYSTEM_CONTRACTS: Lazy<Vec<DeployedContract>> = Lazy::new(|| {
Expand Down
8 changes: 4 additions & 4 deletions etc/env/file_based/genesis.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
genesis_root: 0x7c76ca2d9203e5df3cb8963c3ea27c94fd6c68219035319e820ac7837fd43769
genesis_rollup_leaf_index: 64
genesis_batch_commitment: 0xd0c7d79a9d7848984bf23633aef8cf26a22bf1e607edbeb7f7fbadf4cf1c06dd
genesis_root: 0xde1d0073915c62461b829cb8a9a344c1596a89b80ecca045700739df52221aae
genesis_rollup_leaf_index: 66
genesis_batch_commitment: 0xe633e4aa12aade852ccbc7b02caa47f81ad71bdee0f9461342bc713f58da7756
genesis_protocol_version: 25
default_aa_hash: 0x0100055d9982342d047fb5709665acedb5a5fa432ec105c907d60c878f95cd3e
default_aa_hash: 0x0100055d974eab9e54ec46d3aba418a5fe4d1d41ae6036d0c473835e28106376
bootloader_hash: 0x010008c79fe70427642db69b14314af076e5d54f1dada975b905bcbb5feb9f9e
l1_chain_id: 9
l2_chain_id: 270
Expand Down
1 change: 1 addition & 0 deletions etc/upgrades/1728066632-protocol-defense/new

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions etc/upgrades/1728066632-protocol-defense/old

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion zk_toolbox/crates/config/src/contracts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl ContractsConfig {
.deployed_addresses
.transparent_proxy_admin_addr;
self.ecosystem_contracts.l1_bytecodes_supplier_addr =
Some(deploy_l1_output.deployed_addresses.bytecodes_supplier);
Some(deploy_l1_output.deployed_addresses.state_transition.bytecodes_supplier_addr);
self.ecosystem_contracts.stm_deployment_tracker_proxy_addr = Some(
deploy_l1_output
.deployed_addresses
Expand All @@ -75,6 +75,9 @@ impl ContractsConfig {
.force_deployments_data
.clone(),
);
self.ecosystem_contracts.expected_rollup_l2_da_validator = Some(
deploy_l1_output.expected_rollup_l2_da_validator_addr
);
self.l1.default_upgrade_addr = deploy_l1_output
.deployed_addresses
.state_transition
Expand Down Expand Up @@ -195,6 +198,8 @@ pub struct ToolboxEcosystemContracts {
pub native_token_vault_addr: Option<Address>,
// `Option` to be able to parse configs from previous protocol version
pub l1_bytecodes_supplier_addr: Option<Address>,

pub expected_rollup_l2_da_validator: Option<Address>
}

impl ZkToolboxConfig for ToolboxEcosystemContracts {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub struct DeployL1Output {
pub owner_address: Address,
pub contracts_config: DeployL1ContractsConfigOutput,
pub deployed_addresses: DeployL1DeployedAddressesOutput,
pub expected_rollup_l2_da_validator_addr: Address,
}

#[derive(Debug, Deserialize, Serialize, Clone)]
Expand All @@ -34,8 +35,8 @@ pub struct DeployL1DeployedAddressesOutput {
pub state_transition: L1StateTransitionOutput,
pub rollup_l1_da_validator_addr: Address,
pub validium_l1_da_validator_addr: Address,
pub l1_rollup_da_manager: Address,
pub native_token_vault_addr: Address,
pub bytecodes_supplier: Address,
}

impl ZkToolboxConfig for DeployL1Output {}
Expand Down Expand Up @@ -79,6 +80,7 @@ pub struct L1StateTransitionOutput {
pub genesis_upgrade_addr: Address,
pub default_upgrade_addr: Address,
pub diamond_proxy_addr: Address,
pub bytecodes_supplier_addr: Address,
}

#[derive(Debug, Deserialize, Serialize, Clone)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ pub struct DeployGatewayCTMInput {
latest_protocol_version: U256,

force_deployments_data: String,

expected_rollup_l2_da_validator: Address,
}

impl ZkToolboxConfig for DeployGatewayCTMInput {}
Expand Down Expand Up @@ -111,6 +113,8 @@ impl DeployGatewayCTMInput {

latest_protocol_version: genesis_config.protocol_version.unwrap().pack(),

expected_rollup_l2_da_validator: contracts_config.ecosystem_contracts.expected_rollup_l2_da_validator.unwrap(),

force_deployments_data: contracts_config
.ecosystem_contracts
.force_deployments_data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ pub async fn run(args: GatewayUpgradeArgs, shell: &Shell) -> anyhow::Result<()>
// contracts_config.bridges.shared.l1_address = gateway_ecosystem_preparation_output.deployed_addresses.bridges.shared_bridge_proxy_addr;
}

fn encode_ntv_asset_id(l1_chain_id: U256, addr: Address) -> H256 {
pub fn encode_ntv_asset_id(l1_chain_id: U256, addr: Address) -> H256 {
let encoded_data = encode(&[
ethers::abi::Token::Uint(l1_chain_id),
ethers::abi::Token::Address(L2_NATIVE_TOKEN_VAULT_ADDRESS),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ use xshell::Shell;
use crate::{
commands::{
chain::{
args::init::configs::{InitConfigsArgs, InitConfigsArgsFinal},
genesis,
args::init::configs::{InitConfigsArgs, InitConfigsArgsFinal}, gateway_upgrade::encode_ntv_asset_id, genesis
},
portal::update_portal_config,
},
Expand Down Expand Up @@ -87,6 +86,10 @@ pub async fn init_configs(
contracts_config.l1.governance_addr = Address::zero();
contracts_config.l1.chain_admin_addr = Address::zero();
contracts_config.l1.base_token_addr = chain_config.base_token.address;
contracts_config.l1.base_token_asset_id = Some(encode_ntv_asset_id(
genesis_config.l1_chain_id.0.into(),
contracts_config.l1.base_token_addr,
));
contracts_config.save_with_base_path(shell, &chain_config.configs)?;

// Initialize secrets config
Expand Down

0 comments on commit d393c76

Please sign in to comment.