From 71badc1921de793105455504ddf1573890cc20d9 Mon Sep 17 00:00:00 2001 From: Yuri Tkachenko Date: Thu, 10 Oct 2024 22:43:29 +0100 Subject: [PATCH] fix: typecheck --- lib/deploy.ts | 2 + ...AccountingOracle__MockForSanityChecker.sol | 52 +++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 test/0.8.9/contracts/AccountingOracle__MockForSanityChecker.sol diff --git a/lib/deploy.ts b/lib/deploy.ts index 2656258d6..d41603b63 100644 --- a/lib/deploy.ts +++ b/lib/deploy.ts @@ -1,6 +1,8 @@ import { ContractFactory, ContractTransactionReceipt } from "ethers"; import { ethers } from "hardhat"; +import { LidoLocator } from "typechain-types"; + import { addContractHelperFields, DeployedContract, getContractPath, loadContract, LoadedContract } from "lib/contract"; import { ConvertibleToString, cy, gr, log, yl } from "lib/log"; import { incrementGasUsed, Sk, updateObjectInState } from "lib/state-file"; diff --git a/test/0.8.9/contracts/AccountingOracle__MockForSanityChecker.sol b/test/0.8.9/contracts/AccountingOracle__MockForSanityChecker.sol new file mode 100644 index 000000000..e903c6dba --- /dev/null +++ b/test/0.8.9/contracts/AccountingOracle__MockForSanityChecker.sol @@ -0,0 +1,52 @@ +// SPDX-License-Identifier: UNLICENSED +// for testing purposes only +pragma solidity >=0.4.24 <0.9.0; + +import {AccountingOracle, ILido} from "contracts/0.8.9/oracle/AccountingOracle.sol"; + +interface ITimeProvider { + function getTime() external view returns (uint256); +} + +contract AccountingOracle__MockForSanityChecker { + address public immutable LIDO; + uint256 public immutable SECONDS_PER_SLOT; + uint256 public immutable GENESIS_TIME; + + uint256 internal _lastRefSlot; + + constructor(address lido, uint256 secondsPerSlot, uint256 genesisTime) { + LIDO = lido; + SECONDS_PER_SLOT = secondsPerSlot; + GENESIS_TIME = genesisTime; + } + + function submitReportData( + AccountingOracle.ReportData calldata data, + uint256 /* contractVersion */ + ) external { + require(data.refSlot >= _lastRefSlot, "refSlot less than _lastRefSlot"); + uint256 slotsElapsed = data.refSlot - _lastRefSlot; + _lastRefSlot = data.refSlot; + + ILido(LIDO).handleOracleReport( + data.refSlot * SECONDS_PER_SLOT, + slotsElapsed * SECONDS_PER_SLOT, + data.numValidators, + data.clBalanceGwei * 1e9, + data.withdrawalVaultBalance, + data.elRewardsVaultBalance, + data.sharesRequestedToBurn, + data.withdrawalFinalizationBatches, + data.simulatedShareRate + ); + } + + function setLastProcessingRefSlot(uint256 refSlot) external { + _lastRefSlot = refSlot; + } + + function getLastProcessingRefSlot() external view returns (uint256) { + return _lastRefSlot; + } +}