diff --git a/contracts/inputs/IInputBox.sol b/contracts/inputs/IInputBox.sol index 245e7c4c..396c9962 100644 --- a/contracts/inputs/IInputBox.sol +++ b/contracts/inputs/IInputBox.sol @@ -53,4 +53,7 @@ interface IInputBox { address appContract, uint256 index ) external view returns (bytes32); + + /// @notice Get number of block in which contract was deployed + function getDeploymentBlockNumber() external view returns (uint256); } diff --git a/contracts/inputs/InputBox.sol b/contracts/inputs/InputBox.sol index a3fe3cc1..e170c4c0 100644 --- a/contracts/inputs/InputBox.sol +++ b/contracts/inputs/InputBox.sol @@ -8,9 +8,16 @@ import {CanonicalMachine} from "../common/CanonicalMachine.sol"; import {Inputs} from "../common/Inputs.sol"; contract InputBox is IInputBox { + /// @notice Deployment block number + uint256 immutable _deploymentBlockNumber; + /// @notice Mapping of application contract addresses to arrays of input hashes. mapping(address => bytes32[]) private _inputBoxes; + constructor() { + _deploymentBlockNumber = block.number; + } + /// @inheritdoc IInputBox function addInput( address appContract, @@ -65,4 +72,14 @@ contract InputBox is IInputBox { ) external view override returns (bytes32) { return _inputBoxes[appContract][index]; } + + /// @inheritdoc IInputBox + function getDeploymentBlockNumber() + external + view + override + returns (uint256) + { + return _deploymentBlockNumber; + } } diff --git a/test/inputs/InputBox.t.sol b/test/inputs/InputBox.t.sol index 4430bca8..4c56ffeb 100644 --- a/test/inputs/InputBox.t.sol +++ b/test/inputs/InputBox.t.sol @@ -18,6 +18,12 @@ contract InputBoxTest is Test { _inputBox = new InputBox(); } + function testDeploymentBlockNumber(uint256 blockNumber) public { + vm.roll(blockNumber); + _inputBox = new InputBox(); + assertEq(_inputBox.getDeploymentBlockNumber(), blockNumber); + } + function testNoInputs(address appContract) public view { assertEq(_inputBox.getNumberOfInputs(appContract), 0); }