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

feat: Validium mode #14

Closed
Closed
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
6 changes: 6 additions & 0 deletions l1-contracts/contracts/zksync/facets/Executor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -123,7 +125,9 @@ 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

// linear traversal of the logs
for (uint256 i = 0; i < emittedL2Logs.length; i = i.uncheckedAdd(L2_TO_L1_LOG_SERIALIZE_SIZE)) {
Expand All @@ -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;
Expand Down
1 change: 1 addition & 0 deletions l1-contracts/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export default {
return {
...systemParams,
...defs,
VALIDIUM_MODE: process.env.VALIDIUM_MODE == "true",
};
})(),
},
Expand Down
5 changes: 4 additions & 1 deletion l1-contracts/src.ts/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading