Skip to content

Commit

Permalink
Add time window asserter
Browse files Browse the repository at this point in the history
  • Loading branch information
ischasny committed Oct 29, 2024
1 parent 84d5e37 commit 72a3e8e
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
21 changes: 21 additions & 0 deletions l1-contracts/deploy-scripts/DeployL2Contracts.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ contract DeployL2Script is Script {
address consensusRegistryProxy;
address multicall3;
address forceDeployUpgraderAddress;
address timestampAsserter;
}

struct ContractsBytecodes {
Expand All @@ -45,6 +46,7 @@ contract DeployL2Script is Script {
bytes consensusRegistryProxyBytecode;
bytes multicall3Bytecode;
bytes forceDeployUpgrader;
bytes timestampAsserterBytecode;
}

function run() public {
Expand All @@ -67,6 +69,7 @@ contract DeployL2Script is Script {
deployConsensusRegistry();
deployConsensusRegistryProxy();
deployMulticall3();
deployTimestampAsserter();

saveOutput();
}
Expand Down Expand Up @@ -157,6 +160,10 @@ contract DeployL2Script is Script {
contracts.forceDeployUpgrader = Utils.readFoundryBytecode(
"/../l2-contracts/zkout/ForceDeployUpgrader.sol/ForceDeployUpgrader.json"
);

contracts.timestampAsserterBytecode = Utils.readFoundryBytecode(
"/../l2-contracts/zkout/TimestampAsserter.sol/TimestampAsserter.json"
);
}

function initializeConfig() internal {
Expand All @@ -178,6 +185,7 @@ contract DeployL2Script is Script {
vm.serializeAddress("root", "consensus_registry_implementation", config.consensusRegistryImplementation);
vm.serializeAddress("root", "consensus_registry_proxy", config.consensusRegistryProxy);
vm.serializeAddress("root", "multicall3", config.multicall3);
vm.serializeAddress("root", "timestamp_asserter", config.timestampAsserter);
string memory toml = vm.serializeAddress("root", "l2_default_upgrader", config.forceDeployUpgraderAddress);
string memory root = vm.projectRoot();
string memory path = string.concat(root, "/script-out/output-deploy-l2-contracts.toml");
Expand Down Expand Up @@ -295,6 +303,19 @@ contract DeployL2Script is Script {
});
}

function deployTimestampAsserter() internal {
config.timestampAsserter = Utils.deployThroughL1({
bytecode: contracts.timestampAsserterBytecode,
constructorargs: hex"",
create2salt: "",
l2GasLimit: Utils.MAX_PRIORITY_TX_GAS,
factoryDeps: new bytes[](0),
chainId: config.chainId,
bridgehubAddress: config.bridgehubAddress,
l1SharedBridgeProxy: config.l1SharedBridgeProxy
});
}

// Deploy a transparent upgradable proxy for the already deployed consensus registry
// implementation and save its address into the config.
function deployConsensusRegistryProxy() internal {
Expand Down
12 changes: 12 additions & 0 deletions l2-contracts/contracts/dev-contracts/TimestampAsserter.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.24;

interface ITimestampAsserter {
function assertTimestampInRange(uint256 start, uint256 end) external view;
}

contract TimestampAsserter is ITimestampAsserter {
function assertTimestampInRange(uint256 start, uint256 end) public view {
require(start < block.timestamp && end > block.timestamp, "Timestamp is out of range");
}
}

0 comments on commit 72a3e8e

Please sign in to comment.