forked from OffchainLabs/nitro-contracts
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create PendingBlkTimeAndNrAdvanceCheck.sol
- Loading branch information
1 parent
1b07741
commit 9b25c1f
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright 2021-2022, Offchain Labs, Inc. | ||
// For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
|
||
pragma solidity ^0.8.0; | ||
|
||
import "../precompiles/ArbSys.sol"; | ||
|
||
contract PendingBlkTimeAndNrAdvanceCheck { | ||
uint256 immutable deployedAt; | ||
uint256 immutable deployedAtBlock; | ||
ArbSys constant ARB_SYS = ArbSys(address(100)); | ||
|
||
constructor() { | ||
deployedAt = block.timestamp; | ||
deployedAtBlock = ARB_SYS.arbBlockNumber(); | ||
} | ||
|
||
function isAdvancing() external { | ||
require(block.timestamp > deployedAt, "Time didn't advance"); | ||
require(ARB_SYS.arbBlockNumber() > deployedAtBlock, "Block didn't advance"); | ||
} | ||
|
||
function checkArbBlockHashReturnsLatest(bytes32 expected) external { | ||
bytes32 gotBlockHash = ARB_SYS.arbBlockHash(ARB_SYS.arbBlockNumber() - 1); | ||
require(gotBlockHash != bytes32(0), "ZERO_BLOCK_HASH"); | ||
require(gotBlockHash == expected, "WRONG_BLOCK_HASH"); | ||
} | ||
} |