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: add timestamp asserter contract #843

Merged
merged 7 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
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 {
ischasny marked this conversation as resolved.
Show resolved Hide resolved
function assertTimestampInRange(uint256 start, uint256 end) external view;
}

contract TimestampAsserter is ITimestampAsserter {
ischasny marked this conversation as resolved.
Show resolved Hide resolved
ischasny marked this conversation as resolved.
Show resolved Hide resolved
function assertTimestampInRange(uint256 start, uint256 end) public view {
ischasny marked this conversation as resolved.
Show resolved Hide resolved
require(start < block.timestamp && end > block.timestamp, "Block timestamp is out of range");
ischasny marked this conversation as resolved.
Show resolved Hide resolved
}
}
Loading