Skip to content

Commit

Permalink
Merge pull request #159 from OffchainLabs/verify-arbblockhash-pending…
Browse files Browse the repository at this point in the history
…block
  • Loading branch information
gzeoneth committed Mar 18, 2024
2 parents b3df270 + 1cab72f commit 4281aa0
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/mocks/PendingBlkTimeAndNrAdvanceCheck.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,21 @@ import "../precompiles/ArbSys.sol";
contract PendingBlkTimeAndNrAdvanceCheck {
uint256 immutable deployedAt;
uint256 immutable deployedAtBlock;
ArbSys constant ARB_SYS = ArbSys(address(100));

constructor() {
deployedAt = block.timestamp;
deployedAtBlock = ArbSys(address(100)).arbBlockNumber();
deployedAtBlock = ARB_SYS.arbBlockNumber();
}

function isAdvancing() external {
require(block.timestamp > deployedAt, "Time didn't advance");
require(ArbSys(address(100)).arbBlockNumber() > deployedAtBlock, "Block 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");
}
}

0 comments on commit 4281aa0

Please sign in to comment.