From a8d6ff73a78555d876e2da5cb23cdcd892cd8832 Mon Sep 17 00:00:00 2001 From: ilitteri Date: Thu, 22 Feb 2024 10:56:22 -0300 Subject: [PATCH 1/6] Use the native type for Validium mode instead of solpp --- l1-contracts/contracts/zksync/facets/Executor.sol | 13 +++++-------- l1-contracts/hardhat.config.ts | 1 - 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/l1-contracts/contracts/zksync/facets/Executor.sol b/l1-contracts/contracts/zksync/facets/Executor.sol index 87d1371ee..fd8020c61 100644 --- a/l1-contracts/contracts/zksync/facets/Executor.sol +++ b/l1-contracts/contracts/zksync/facets/Executor.sol @@ -24,8 +24,6 @@ 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 @@ -125,9 +123,10 @@ contract ExecutorFacet is Base, IExecutor { // See SystemLogKey enum in Constants.sol for ordering. uint256 processedLogs; - // #if VALIDIUM_MODE == false - bytes32 providedL2ToL1PubdataHash = keccak256(_newBatch.totalL2ToL1Pubdata); - // #endif + bytes32 providedL2ToL1PubdataHash; + if (feeParams.pubdataPricingMode == PubdataPricingMode.Rollup) { + providedL2ToL1PubdataHash = keccak256(_newBatch.totalL2ToL1Pubdata); + } // linear traversal of the logs for (uint256 i = 0; i < emittedL2Logs.length; i = i.uncheckedAdd(L2_TO_L1_LOG_SERIALIZE_SIZE)) { @@ -144,11 +143,9 @@ contract ExecutorFacet is Base, IExecutor { if (logKey == uint256(SystemLogKey.L2_TO_L1_LOGS_TREE_ROOT_KEY)) { 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 + } else if (logKey == uint256(SystemLogKey.TOTAL_L2_TO_L1_PUBDATA_KEY) && feeParams.pubdataPricingMode == PubdataPricingMode.Rollup) { 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; diff --git a/l1-contracts/hardhat.config.ts b/l1-contracts/hardhat.config.ts index 2839950a4..a89ea4e69 100644 --- a/l1-contracts/hardhat.config.ts +++ b/l1-contracts/hardhat.config.ts @@ -93,7 +93,6 @@ export default { return { ...systemParams, ...defs, - VALIDIUM_MODE: process.env.VALIDIUM_MODE == "true", }; })(), }, From 6b912fb7b86949050483f12f285c2f2d756b10c8 Mon Sep 17 00:00:00 2001 From: ilitteri Date: Thu, 22 Feb 2024 11:00:20 -0300 Subject: [PATCH 2/6] Add import --- l1-contracts/contracts/zksync/facets/Executor.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/l1-contracts/contracts/zksync/facets/Executor.sol b/l1-contracts/contracts/zksync/facets/Executor.sol index fd8020c61..38a271f75 100644 --- a/l1-contracts/contracts/zksync/facets/Executor.sol +++ b/l1-contracts/contracts/zksync/facets/Executor.sol @@ -8,7 +8,7 @@ import {IExecutor, L2_LOG_ADDRESS_OFFSET, L2_LOG_KEY_OFFSET, L2_LOG_VALUE_OFFSET import {PriorityQueue, PriorityOperation} from "../libraries/PriorityQueue.sol"; import {UncheckedMath} from "../../common/libraries/UncheckedMath.sol"; import {UnsafeBytes} from "../../common/libraries/UnsafeBytes.sol"; -import {VerifierParams} from "../Storage.sol"; +import {VerifierParams, PubdataPricingMode} from "../Storage.sol"; import {L2_BOOTLOADER_ADDRESS, L2_TO_L1_MESSENGER_SYSTEM_CONTRACT_ADDR, L2_SYSTEM_CONTEXT_SYSTEM_CONTRACT_ADDR} from "../../common/L2ContractAddresses.sol"; // While formally the following import is not used, it is needed to inherit documentation from it From b41d0335054d1d12922d92e64ec4514f89ce986a Mon Sep 17 00:00:00 2001 From: ilitteri Date: Thu, 22 Feb 2024 11:05:35 -0300 Subject: [PATCH 3/6] Fix, as the state is used we needed to change the function from pure to view --- l1-contracts/contracts/zksync/facets/Executor.sol | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/l1-contracts/contracts/zksync/facets/Executor.sol b/l1-contracts/contracts/zksync/facets/Executor.sol index 38a271f75..29cf9d846 100644 --- a/l1-contracts/contracts/zksync/facets/Executor.sol +++ b/l1-contracts/contracts/zksync/facets/Executor.sol @@ -106,7 +106,7 @@ contract ExecutorFacet is Base, IExecutor { bytes32 _expectedSystemContractUpgradeTxHash ) internal - pure + view returns ( uint256 numberOfLayer1Txs, bytes32 chainedPriorityTxsHash, @@ -124,7 +124,7 @@ contract ExecutorFacet is Base, IExecutor { uint256 processedLogs; bytes32 providedL2ToL1PubdataHash; - if (feeParams.pubdataPricingMode == PubdataPricingMode.Rollup) { + if (s.feeParams.pubdataPricingMode == PubdataPricingMode.Rollup) { providedL2ToL1PubdataHash = keccak256(_newBatch.totalL2ToL1Pubdata); } @@ -143,7 +143,7 @@ contract ExecutorFacet is Base, IExecutor { if (logKey == uint256(SystemLogKey.L2_TO_L1_LOGS_TREE_ROOT_KEY)) { require(logSender == L2_TO_L1_MESSENGER_SYSTEM_CONTRACT_ADDR, "lm"); l2LogsTreeRoot = logValue; - } else if (logKey == uint256(SystemLogKey.TOTAL_L2_TO_L1_PUBDATA_KEY) && feeParams.pubdataPricingMode == PubdataPricingMode.Rollup) { + } else if (logKey == uint256(SystemLogKey.TOTAL_L2_TO_L1_PUBDATA_KEY) && s.feeParams.pubdataPricingMode == PubdataPricingMode.Rollup) { require(logSender == L2_TO_L1_MESSENGER_SYSTEM_CONTRACT_ADDR, "ln"); require(providedL2ToL1PubdataHash == logValue, "wp"); } else if (logKey == uint256(SystemLogKey.STATE_DIFF_HASH_KEY)) { From 9ab2f16841b04e1f35d1646352b99a61a2a741c4 Mon Sep 17 00:00:00 2001 From: ilitteri Date: Thu, 22 Feb 2024 11:06:01 -0300 Subject: [PATCH 4/6] Update functions marker --- .../contracts/dev-contracts/test/ExecutorProvingTest.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/l1-contracts/contracts/dev-contracts/test/ExecutorProvingTest.sol b/l1-contracts/contracts/dev-contracts/test/ExecutorProvingTest.sol index efcfa9678..a6a69c210 100644 --- a/l1-contracts/contracts/dev-contracts/test/ExecutorProvingTest.sol +++ b/l1-contracts/contracts/dev-contracts/test/ExecutorProvingTest.sol @@ -24,7 +24,7 @@ contract ExecutorProvingTest is ExecutorFacet { bytes32 _expectedSystemContractUpgradeTxHash ) external - pure + view returns ( uint256 numberOfLayer1Txs, bytes32 chainedPriorityTxsHash, From 5f326fcd39db1c2dedcec56e5e0c66d43b3ee6c7 Mon Sep 17 00:00:00 2001 From: ilitteri Date: Thu, 22 Feb 2024 11:29:39 -0300 Subject: [PATCH 5/6] fmt --- l1-contracts/contracts/zksync/facets/Executor.sol | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/l1-contracts/contracts/zksync/facets/Executor.sol b/l1-contracts/contracts/zksync/facets/Executor.sol index 29cf9d846..91ce2fb36 100644 --- a/l1-contracts/contracts/zksync/facets/Executor.sol +++ b/l1-contracts/contracts/zksync/facets/Executor.sol @@ -143,7 +143,10 @@ contract ExecutorFacet is Base, IExecutor { if (logKey == uint256(SystemLogKey.L2_TO_L1_LOGS_TREE_ROOT_KEY)) { require(logSender == L2_TO_L1_MESSENGER_SYSTEM_CONTRACT_ADDR, "lm"); l2LogsTreeRoot = logValue; - } else if (logKey == uint256(SystemLogKey.TOTAL_L2_TO_L1_PUBDATA_KEY) && s.feeParams.pubdataPricingMode == PubdataPricingMode.Rollup) { + } else if ( + logKey == uint256(SystemLogKey.TOTAL_L2_TO_L1_PUBDATA_KEY) && + s.feeParams.pubdataPricingMode == PubdataPricingMode.Rollup + ) { require(logSender == L2_TO_L1_MESSENGER_SYSTEM_CONTRACT_ADDR, "ln"); require(providedL2ToL1PubdataHash == logValue, "wp"); } else if (logKey == uint256(SystemLogKey.STATE_DIFF_HASH_KEY)) { From 9e1059ab9bc20d7e97a26757ac426513a1649e1e Mon Sep 17 00:00:00 2001 From: ilitteri Date: Thu, 22 Feb 2024 13:43:28 -0300 Subject: [PATCH 6/6] Fix if --- l1-contracts/contracts/zksync/facets/Executor.sol | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/l1-contracts/contracts/zksync/facets/Executor.sol b/l1-contracts/contracts/zksync/facets/Executor.sol index 91ce2fb36..dfd73cd6a 100644 --- a/l1-contracts/contracts/zksync/facets/Executor.sol +++ b/l1-contracts/contracts/zksync/facets/Executor.sol @@ -143,12 +143,11 @@ contract ExecutorFacet is Base, IExecutor { if (logKey == uint256(SystemLogKey.L2_TO_L1_LOGS_TREE_ROOT_KEY)) { require(logSender == L2_TO_L1_MESSENGER_SYSTEM_CONTRACT_ADDR, "lm"); l2LogsTreeRoot = logValue; - } else if ( - logKey == uint256(SystemLogKey.TOTAL_L2_TO_L1_PUBDATA_KEY) && - s.feeParams.pubdataPricingMode == PubdataPricingMode.Rollup - ) { - require(logSender == L2_TO_L1_MESSENGER_SYSTEM_CONTRACT_ADDR, "ln"); - require(providedL2ToL1PubdataHash == logValue, "wp"); + } else if (logKey == uint256(SystemLogKey.TOTAL_L2_TO_L1_PUBDATA_KEY)) { + if (s.feeParams.pubdataPricingMode == PubdataPricingMode.Rollup) { + require(logSender == L2_TO_L1_MESSENGER_SYSTEM_CONTRACT_ADDR, "ln"); + require(providedL2ToL1PubdataHash == logValue, "wp"); + } } else if (logKey == uint256(SystemLogKey.STATE_DIFF_HASH_KEY)) { require(logSender == L2_TO_L1_MESSENGER_SYSTEM_CONTRACT_ADDR, "lb"); stateDiffHash = logValue;