From 583cb674a2b942dda34e9f46edb5a9f5b696b90a Mon Sep 17 00:00:00 2001 From: Peter Straus <153843855+krauspt@users.noreply.github.com> Date: Wed, 17 Jan 2024 15:31:08 +0100 Subject: [PATCH 1/8] fix: outdated link to foundry config docs (#172) --- l1-contracts/foundry.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/l1-contracts/foundry.toml b/l1-contracts/foundry.toml index ecdc26a1a..fb84e825c 100644 --- a/l1-contracts/foundry.toml +++ b/l1-contracts/foundry.toml @@ -5,4 +5,4 @@ libs = ['node_modules', 'lib'] cache_path = 'cache-forge' test = 'test/foundry' -# See more config options https://github.com/foundry-rs/foundry/tree/master/config +# See more config options https://github.com/foundry-rs/foundry/tree/master/crates/config From 417393fb9b4c79aae7a94c4c7eee0b54bd5d1f39 Mon Sep 17 00:00:00 2001 From: ilitteri Date: Wed, 31 Jan 2024 17:51:44 -0300 Subject: [PATCH 2/8] Skip pubdata related logic in Validium mode --- l1-contracts/contracts/zksync/facets/Executor.sol | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/l1-contracts/contracts/zksync/facets/Executor.sol b/l1-contracts/contracts/zksync/facets/Executor.sol index b34183f60..39679edf9 100644 --- a/l1-contracts/contracts/zksync/facets/Executor.sol +++ b/l1-contracts/contracts/zksync/facets/Executor.sol @@ -24,6 +24,8 @@ contract ExecutorFacet is Base, IExecutor { /// @inheritdoc IBase string public constant override getName = "ExecutorFacet"; + bool constant VALIDIUM_MODE = $(VALIDIUM_MODE); + /// @dev Process one batch commit using the previous batch StoredBatchInfo /// @dev returns new batch StoredBatchInfo /// @notice Does not change storage @@ -123,7 +125,9 @@ contract ExecutorFacet is Base, IExecutor { // See SystemLogKey enum in Constants.sol for ordering. uint256 processedLogs; + // #if VALIDIUM_MODE == true bytes32 providedL2ToL1PubdataHash = keccak256(_newBatch.totalL2ToL1Pubdata); + // #endif // linear traversal of the logs for (uint256 i = 0; i < emittedL2Logs.length; i = i.uncheckedAdd(L2_TO_L1_LOG_SERIALIZE_SIZE)) { @@ -141,8 +145,10 @@ contract ExecutorFacet is Base, IExecutor { require(logSender == L2_TO_L1_MESSENGER_SYSTEM_CONTRACT_ADDR, "lm"); l2LogsTreeRoot = logValue; } else if (logKey == uint256(SystemLogKey.TOTAL_L2_TO_L1_PUBDATA_KEY)) { + // #if VALIDIUM_MODE == false require(logSender == L2_TO_L1_MESSENGER_SYSTEM_CONTRACT_ADDR, "ln"); require(providedL2ToL1PubdataHash == logValue, "wp"); + // #endif } else if (logKey == uint256(SystemLogKey.STATE_DIFF_HASH_KEY)) { require(logSender == L2_TO_L1_MESSENGER_SYSTEM_CONTRACT_ADDR, "lb"); stateDiffHash = logValue; From 48ff565f61f868a8729bddff57879bdc14a04bf6 Mon Sep 17 00:00:00 2001 From: ilitteri Date: Wed, 31 Jan 2024 17:52:03 -0300 Subject: [PATCH 3/8] Add VALIDIUM_MODE to SystemConfigs --- l1-contracts/hardhat.config.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/l1-contracts/hardhat.config.ts b/l1-contracts/hardhat.config.ts index a89ea4e69..1f2f8fb00 100644 --- a/l1-contracts/hardhat.config.ts +++ b/l1-contracts/hardhat.config.ts @@ -93,6 +93,7 @@ export default { return { ...systemParams, ...defs, + VALIDIUM_MODE: process.env.VALIDIUM_MODE === "true", }; })(), }, From bbb06cafdff91d00468a4f16e8843cca71fad60c Mon Sep 17 00:00:00 2001 From: ilitteri Date: Wed, 31 Jan 2024 17:52:21 -0300 Subject: [PATCH 4/8] Initialize pubdataPricingMode correctly --- l1-contracts/src.ts/deploy.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/l1-contracts/src.ts/deploy.ts b/l1-contracts/src.ts/deploy.ts index 1b94b30ff..96c849737 100644 --- a/l1-contracts/src.ts/deploy.ts +++ b/l1-contracts/src.ts/deploy.ts @@ -78,8 +78,11 @@ export class Deployer { const initialProtocolVersion = getNumberFromEnv("CONTRACTS_INITIAL_PROTOCOL_VERSION"); const DiamondInit = new Interface(hardhat.artifacts.readArtifactSync("DiamondInit").abi); + const validiumMode = process.env["VALIDIUM_MODE"] == "true"; + const pubdataPricingMode = validiumMode ? PubdataPricingMode.Validium : PubdataPricingMode.Rollup; + const feeParams = { - pubdataPricingMode: PubdataPricingMode.Rollup, + pubdataPricingMode, batchOverheadL1Gas: SYSTEM_CONFIG.priorityTxBatchOverheadL1Gas, maxPubdataPerBatch: SYSTEM_CONFIG.priorityTxPubdataPerBatch, priorityTxMaxPubdata: SYSTEM_CONFIG.priorityTxMaxPubdata, From 572328476a3726c1f6af79612e5324e5daa7f5fe Mon Sep 17 00:00:00 2001 From: ilitteri Date: Wed, 31 Jan 2024 18:14:39 -0300 Subject: [PATCH 5/8] Fix --- l1-contracts/contracts/zksync/facets/Executor.sol | 2 +- l1-contracts/hardhat.config.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/l1-contracts/contracts/zksync/facets/Executor.sol b/l1-contracts/contracts/zksync/facets/Executor.sol index 39679edf9..87d1371ee 100644 --- a/l1-contracts/contracts/zksync/facets/Executor.sol +++ b/l1-contracts/contracts/zksync/facets/Executor.sol @@ -125,7 +125,7 @@ contract ExecutorFacet is Base, IExecutor { // See SystemLogKey enum in Constants.sol for ordering. uint256 processedLogs; - // #if VALIDIUM_MODE == true + // #if VALIDIUM_MODE == false bytes32 providedL2ToL1PubdataHash = keccak256(_newBatch.totalL2ToL1Pubdata); // #endif diff --git a/l1-contracts/hardhat.config.ts b/l1-contracts/hardhat.config.ts index 1f2f8fb00..2839950a4 100644 --- a/l1-contracts/hardhat.config.ts +++ b/l1-contracts/hardhat.config.ts @@ -93,7 +93,7 @@ export default { return { ...systemParams, ...defs, - VALIDIUM_MODE: process.env.VALIDIUM_MODE === "true", + VALIDIUM_MODE: process.env.VALIDIUM_MODE == "true", }; })(), }, From df9ef59ff3b2658687576c4bde0c5de195c27145 Mon Sep 17 00:00:00 2001 From: ilitteri Date: Mon, 5 Feb 2024 19:03:05 -0300 Subject: [PATCH 6/8] Revert "Merge branch 'main' of github.com:lambdaclass/era-contracts into update_validium_mode_contracts" This reverts commit 8e020fa18b40721a70626a9c92d0b3c1ddc2927f, reversing changes made to 572328476a3726c1f6af79612e5324e5daa7f5fe. --- l1-contracts/foundry.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/l1-contracts/foundry.toml b/l1-contracts/foundry.toml index fb84e825c..ecdc26a1a 100644 --- a/l1-contracts/foundry.toml +++ b/l1-contracts/foundry.toml @@ -5,4 +5,4 @@ libs = ['node_modules', 'lib'] cache_path = 'cache-forge' test = 'test/foundry' -# See more config options https://github.com/foundry-rs/foundry/tree/master/crates/config +# See more config options https://github.com/foundry-rs/foundry/tree/master/config From 6efcd0a46587cee8a0928799517a23d00a6afd5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C3=ADas=20Onorato?= Date: Fri, 9 Feb 2024 16:56:40 -0300 Subject: [PATCH 7/8] sync submodule --- l1-contracts/lib/forge-std | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/l1-contracts/lib/forge-std b/l1-contracts/lib/forge-std index 705263c95..77876f8a5 160000 --- a/l1-contracts/lib/forge-std +++ b/l1-contracts/lib/forge-std @@ -1 +1 @@ -Subproject commit 705263c95892a906d7af65f0f73ce8a4a0c80b80 +Subproject commit 77876f8a5b44b770a935621bb331660c90ac928e From ceb214b7650c6102703a9b5569a4056fe97a3be4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C3=ADas=20Onorato?= Date: Fri, 9 Feb 2024 16:59:39 -0300 Subject: [PATCH 8/8] run zk fmt --- l1-contracts/contracts/zksync/facets/Executor.sol | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/l1-contracts/contracts/zksync/facets/Executor.sol b/l1-contracts/contracts/zksync/facets/Executor.sol index 87d1371ee..f349852d3 100644 --- a/l1-contracts/contracts/zksync/facets/Executor.sol +++ b/l1-contracts/contracts/zksync/facets/Executor.sol @@ -145,10 +145,10 @@ contract ExecutorFacet is Base, IExecutor { require(logSender == L2_TO_L1_MESSENGER_SYSTEM_CONTRACT_ADDR, "lm"); l2LogsTreeRoot = logValue; } else if (logKey == uint256(SystemLogKey.TOTAL_L2_TO_L1_PUBDATA_KEY)) { - // #if VALIDIUM_MODE == false + // #if VALIDIUM_MODE == false require(logSender == L2_TO_L1_MESSENGER_SYSTEM_CONTRACT_ADDR, "ln"); require(providedL2ToL1PubdataHash == logValue, "wp"); - // #endif + // #endif } else if (logKey == uint256(SystemLogKey.STATE_DIFF_HASH_KEY)) { require(logSender == L2_TO_L1_MESSENGER_SYSTEM_CONTRACT_ADDR, "lb"); stateDiffHash = logValue;