// SPDX-License-Identifier: MIT pragma solidity ^0.8.26; /// @dev Arbitrum Nitro precompile. On an Orbit chain, `block.number` returns the PARENT chain block, /// `ArbSys(0x64).arbBlockNumber()` returns the L2 block. interface IArbSys { function arbBlockNumber() external view returns (uint256); } /// @title ChainBlock /// @notice Single source of the protocol block number. Every "block" in the KIBBLE docs (eras, power per block, /// TWAP window, preorder end, empty block) is an Elysium L2 block. /// @dev Elysium (99901) and Elysium testnet (99801) are Arbitrum Orbit chains: `block.number` there is the /// HyperEVM (parent) block number, so we read ArbSys. Any other chain (local forge tests) uses `block.number`. /// Raw `block.number` must not be used anywhere else in the protocol. library ChainBlock { address internal constant ARB_SYS = address(100); uint256 internal constant ELYSIUM = 99901; uint256 internal constant ELYSIUM_TESTNET = 99801; function number() internal view returns (uint256) { if (block.chainid == ELYSIUM || block.chainid == ELYSIUM_TESTNET) { return IArbSys(ARB_SYS).arbBlockNumber(); } return block.number; } }