Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: post zhejiang fixes #602

Merged
merged 97 commits into from
Feb 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
5a4d5c2
test: base oracle: add deploy test, mock base oracle, mock hash conse…
DiRaiks Feb 10, 2023
b4617e8
feat: added baseOracle submitReport tests and updated helpers&mocks
Jeday Feb 10, 2023
cae279f
feat: submitReport => getConsensusReport tests, helpers linting
Jeday Feb 11, 2023
2bece61
fix: handle report resubmit case
Jeday Feb 11, 2023
f84bab4
test fixes
bulbozaur Feb 11, 2023
4a79281
Merge remote-tracking branch 'origin/feature/shapella-upgrade' into f…
bulbozaur Feb 11, 2023
40f56b8
chore: inconsistent comment
TheDZhon Feb 11, 2023
efb01d4
chore: fix unsafely method comments
TheDZhon Feb 11, 2023
963cfec
fix tests
bulbozaur Feb 11, 2023
729f10a
feat: DSM with custom errors instead of strs
TheDZhon Feb 11, 2023
6fb0107
chore: burner errors naming
TheDZhon Feb 11, 2023
3cdaa59
test: unstoppable stETH approvals
TheDZhon Feb 11, 2023
d99608a
chore: comment about unused deposit calldata
TheDZhon Feb 11, 2023
e59c883
chore: `ConsensusContractSet`->`ConsensusHashC...`
TheDZhon Feb 11, 2023
6a556c5
fix: vars naming
TheDZhon Feb 11, 2023
82d768a
fix: missing await in assertRevert
Jeday Feb 11, 2023
04eb418
chore: naming in sanity checks
TheDZhon Feb 11, 2023
5eb1d9f
Merge branch 'feature/shapella-upgrade' of github.com:lidofinance/lid…
DiRaiks Feb 11, 2023
8f84675
chore: args naming in Lido ifaces
TheDZhon Feb 11, 2023
3618050
feat: set consensus contract,version tests and helper contract updates
Jeday Feb 11, 2023
d348148
test: base oracle: add access control tests, add admin to deploy
DiRaiks Feb 11, 2023
77276e0
Merge branch 'feature/shapella-upgrade-tests-base-oracle' of github.c…
DiRaiks Feb 11, 2023
1f75ec0
fix: -extra pause check `transferSharesFrom`
TheDZhon Feb 11, 2023
f2665ca
fix: DSM calls canDeposit from Lido
TheDZhon Feb 11, 2023
81ea055
test: base oracle: change mock init
DiRaiks Feb 11, 2023
e9b74c7
chore: Lido comments and naming
TheDZhon Feb 11, 2023
ad25d5d
chore: handleOracleReport namings
TheDZhon Feb 11, 2023
fe83a03
fix: check finalization share rate special vals
TheDZhon Feb 11, 2023
c8bbc7c
feat: checkConsensusData tests & relevant mock updates
Jeday Feb 12, 2023
fe0b5bf
fix: helper utils imports typo error
manneredboor Feb 12, 2023
f773d36
test: method getReportVariants returns empty data if lastReportRefSlo…
manneredboor Feb 12, 2023
e774e5c
test: HashConsensus deploy reverts if admin or processor address equa…
manneredboor Feb 12, 2023
94b6cd0
test: addMember reverts if member address equals zero
manneredboor Feb 12, 2023
39a4e6e
test: refactor helpers usage
manneredboor Feb 12, 2023
a426b57
test: HashConsensus.setFastLaneLengthSlots
manneredboor Feb 12, 2023
830f07f
test: base oracle: fix test disc
DiRaiks Feb 12, 2023
de17bb0
test: HashConsensus Report Submitting revert cases
manneredboor Feb 12, 2023
2ec33f9
test: fix fast lane length naming
manneredboor Feb 12, 2023
1745a04
fix: simulated share rate sancheck
TheDZhon Feb 12, 2023
bfc7d74
feat: startProcessing tests & update helper
Jeday Feb 12, 2023
9ab9283
fix: add instead of sub for simulated share rate
TheDZhon Feb 12, 2023
71a955e
Merge branch 'feature/shapella-upgrade-tests-base-oracle' of github.c…
Jeday Feb 12, 2023
d547911
fix: clean up helpers
Jeday Feb 12, 2023
cda3398
Merge pull request #601 from lidofinance/fix/repeating-missed-report-…
skozin Feb 12, 2023
68d7fe4
feat: added missing functions tests
Jeday Feb 12, 2023
87c3398
chore: clean up, formatting, typos
Jeday Feb 12, 2023
b8274a9
chore: NOR chores
TheDZhon Feb 12, 2023
1e643f0
chore: use `Versioned` for LegacyOracle
TheDZhon Feb 12, 2023
fcbbb9e
fix: remove reduntant bunker check on deposit
TheDZhon Feb 12, 2023
41ea87a
feat: sanity check on EL rewards vault balance
TheDZhon Feb 12, 2023
718c359
refactor: move sanity check out of while loop for optimizing gas usage
ujenjt Feb 12, 2023
a0b636a
fix: OracleDaemonConfig empty value + tests
TheDZhon Feb 12, 2023
bdbe1d6
test fixes
bulbozaur Feb 13, 2023
0d2e2cf
fix: empty value set for daemon config
TheDZhon Feb 13, 2023
5e88035
fix: handle report resubmit case
Jeday Feb 11, 2023
1d9c0f6
test fixes
bulbozaur Feb 13, 2023
1c29a3c
fix: +`CLValidatorsUpdated` event for Lido
TheDZhon Feb 13, 2023
db01adc
add handle report
bulbozaur Feb 13, 2023
a6865a6
chore: NOR typo
TheDZhon Feb 13, 2023
f36fe3d
refactor: don't use Error* prefix for errors
TheDZhon Feb 13, 2023
d593a0a
fix: precalc Lido constants keccak256
TheDZhon Feb 13, 2023
0cf616c
feat: add unsafeModifyDepositedValidators
TheDZhon Feb 13, 2023
710f536
Merge remote-tracking branch 'origin/feature/tests-fix' into feature/…
TheDZhon Feb 13, 2023
4d81784
Add methods for a summary of module and node operator. Rename batch m…
Psirex Feb 13, 2023
382a8e2
Add missing doc comments to the IStakingModule
Psirex Feb 13, 2023
2465ad7
fix: visibility
TheDZhon Feb 13, 2023
32510e0
chore: _checkFinalizationShareRate view->pure
TheDZhon Feb 13, 2023
56363bb
fix nor, update tests
loga4 Feb 13, 2023
65260fc
fix comments
loga4 Feb 13, 2023
3fcffd2
getKeysOpIndex deprecated
loga4 Feb 13, 2023
c7bd2f7
Merge pull request #590 from lidofinance/feature/shapella-upgrade-tes…
TheDZhon Feb 13, 2023
6509e1a
move penalty delay to initialize
loga4 Feb 13, 2023
badd75c
fix: polish naming and move comment for solidity compiler into the ri…
ujenjt Feb 13, 2023
ce98639
handle oracle report more tests
bulbozaur Feb 13, 2023
52ae638
Merge pull request #606 from lidofinance/feature/staking-router-batch…
TheDZhon Feb 13, 2023
9fffe82
skip unchecked tests
loga4 Feb 13, 2023
9cfe6b9
Merge pull request #604 from lidofinance/refactor/gas-golfing-for-acc…
TheDZhon Feb 13, 2023
2478df2
await reverts
loga4 Feb 13, 2023
72bf913
fix test
loga4 Feb 13, 2023
bd1cb0f
Merge pull request #610 from lidofinance/feature/tests-fix
TheDZhon Feb 13, 2023
470d265
Merge pull request #609 from lidofinance/feature/post-zhejiang-fixes-…
TheDZhon Feb 13, 2023
38aa9ed
replace selfdestruct with setBalance
bulbozaur Feb 13, 2023
3775eee
Emit BaseURISet event
Psirex Feb 13, 2023
516f6a3
fix: redundant `_whenNotStopped()` in stETH
TheDZhon Feb 13, 2023
fe554e1
refactor: share rate sanity check precedence
TheDZhon Feb 13, 2023
0e37533
Merge remote-tracking branch 'origin/feature/post-zhejiang-fixes' int…
bulbozaur Feb 13, 2023
1bcc13a
Consistent naming with ERC721 for baseURI
Psirex Feb 13, 2023
8327ee2
fix: zero check
TheDZhon Feb 13, 2023
0ee6690
chore: naming
TheDZhon Feb 13, 2023
ea14cc5
fix: redundant `_whenNotStopped()` in stETH
TheDZhon Feb 13, 2023
ce08fb2
chore: comment about sanity check
TheDZhon Feb 13, 2023
9591abb
Merge branch 'feature/post-zhejiang-fixes' into fix/share-rate-sanity…
TheDZhon Feb 13, 2023
5d1c551
remove selfdestruct from tests completely
bulbozaur Feb 13, 2023
2d16655
refactor: transfer method
krogla Feb 13, 2023
65fde22
Merge pull request #612 from lidofinance/fix/share-rate-sanity-check
ujenjt Feb 13, 2023
caff03d
Merge pull request #611 from lidofinance/feature/tests-fix
TheDZhon Feb 13, 2023
313113e
refactor: transfer optimize
krogla Feb 13, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
241 changes: 177 additions & 64 deletions contracts/0.4.24/Lido.sol

Large diffs are not rendered by default.

5 changes: 0 additions & 5 deletions contracts/0.4.24/StETH.sol
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,6 @@ contract StETH is IERC20, Pausable {
* @dev The `_amount` argument is the amount of tokens, not shares.
*/
function transferFrom(address _sender, address _recipient, uint256 _amount) external returns (bool) {
_whenNotStopped();

uint256 currentAllowance = allowances[_sender][msg.sender];
require(currentAllowance >= _amount, "TRANSFER_AMOUNT_EXCEEDS_ALLOWANCE");

Expand Down Expand Up @@ -363,8 +361,6 @@ contract StETH is IERC20, Pausable {
function transferSharesFrom(
address _sender, address _recipient, uint256 _sharesAmount
) external returns (uint256) {
_whenNotStopped();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_transferShares


uint256 currentAllowance = allowances[_sender][msg.sender];
uint256 tokensAmount = getPooledEthByShares(_sharesAmount);
require(currentAllowance >= tokensAmount, "TRANSFER_AMOUNT_EXCEEDS_ALLOWANCE");
Expand Down Expand Up @@ -490,7 +486,6 @@ contract StETH is IERC20, Pausable {
*/
function _burnShares(address _account, uint256 _sharesAmount) internal returns (uint256 newTotalShares) {
require(_account != address(0), "BURN_FROM_THE_ZERO_ADDRESS");
_whenNotStopped();

uint256 accountShares = shares[_account];
require(_sharesAmount <= accountShares, "BURN_AMOUNT_EXCEEDS_BALANCE");
Expand Down
82 changes: 45 additions & 37 deletions contracts/0.4.24/nos/NodeOperatorsRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ contract NodeOperatorsRegistry is AragonApp, Versioned {
event NodeOperatorActiveSet(uint256 indexed nodeOperatorId, bool active);
event NodeOperatorNameSet(uint256 indexed nodeOperatorId, string name);
event NodeOperatorRewardAddressSet(uint256 indexed nodeOperatorId, address rewardAddress);
event NodeOperatorStakingLimitSet(uint256 indexed nodeOperatorId, uint64 stakingLimit);
event NodeOperatorTotalStoppedValidatorsReported(uint256 indexed nodeOperatorId, uint64 totalStopped);
event NodeOperatorTotalKeysTrimmed(uint256 indexed nodeOperatorId, uint64 totalKeysTrimmed);
event KeysOpIndexSet(uint256 keysOpIndex);
event ContractVersionSet(uint256 version);
Expand Down Expand Up @@ -93,22 +91,23 @@ contract NodeOperatorsRegistry is AragonApp, Versioned {
uint8 internal constant DEPOSITED_KEYS_COUNT_OFFSET = 3;

// TargetValidatorsStats
/// @dev DAO target limit, used to check how many keys shoud be go to exit
/// UINT64_MAX - unlim
/// @dev DAO target limit, used to check how many keys should go to exit
/// UINT64_MAX - unlimited
/// 0 - all deposited keys
/// N < deposited keys -
/// N < deposited keys - (deposited-N) keys
/// deposited < N < vetted - use (N-deposited) as available
uint8 internal constant IS_TARGET_LIMIT_ACTIVE_OFFSET = 0;
/// @dev relative target active validators limit for operator, set by DAO, UINT64_MAX === no limit
/// @notice stores value +1 based, so 0 is means target coun is unlimited (i.e. = -1),
/// and 1 is means target count = 0 (i.e. all validaotrs should be exited)
/// @dev relative target active validators limit for operator, set by DAO, UINT64_MAX === 'no limit'
/// @notice stores value +1 based, so 0 is means target count is unlimited (i.e. = -1),
/// and 1 is means target count = 0 (i.e. all validators should be exited)
uint8 internal constant TARGET_VALIDATORS_COUNT_OFFSET = 1;

// StuckPenaltyStats
/// @dev stuck keys count from oracle report
uint8 internal constant STUCK_VALIDATORS_COUNT_OFFSET = 0;
/// @dev refunded keys count from dao
uint8 internal constant REFUNDED_VALIDATORS_COUNT_OFFSET = 1;
/// @dev extra penalty time after stuck keys resolved (refunded and/or exited)
uint8 internal constant STUCK_PENALTY_END_TIMESTAMP_OFFSET = 2;

//
Expand Down Expand Up @@ -149,11 +148,14 @@ contract NodeOperatorsRegistry is AragonApp, Versioned {
struct NodeOperator {
/// @dev Flag indicating if the operator can participate in further staking and reward distribution
bool active;
/// @dev Ethereum address on Execution Layer which receives steth rewards for this operator
/// @dev Ethereum address on Execution Layer which receives stETH rewards for this operator
address rewardAddress;
/// @dev Human-readable name
string name;
/// @dev The below variables store the signing keys info of the node operator.
/// signingKeysStats - contains packed variables: uint64 exitedSigningKeysCount, uint64 depositedSigningKeysCount,
/// uint64 vettedSigningKeysCount, uint64 totalSigningKeysCount
///
/// These variables can take values in the following ranges:
///
/// 0 <= exitedSigningKeysCount <= depositedSigningKeysCount
Expand All @@ -179,7 +181,6 @@ contract NodeOperatorsRegistry is AragonApp, Versioned {

/// @dev Mapping of all node operators. Mapping is used to be able to extend the struct.
mapping(uint256 => NodeOperator) internal _nodeOperators;
// NodeOperatorTotals internal _nodeOperatorTotals;

//
// METHODS
Expand All @@ -197,8 +198,6 @@ contract NodeOperatorsRegistry is AragonApp, Versioned {
_checkContractVersion(0);
_initialize_v2(_locator, _type);

_setStuckPenaltyDelay(2 days);

uint256 totalOperators = getNodeOperatorsCount();
Packed64x4.Packed memory signingKeysStats;
for (uint256 operatorId; operatorId < totalOperators; ++operatorId) {
Expand Down Expand Up @@ -233,8 +232,10 @@ contract NodeOperatorsRegistry is AragonApp, Versioned {

_setContractVersion(2);

_setStuckPenaltyDelay(2 days);

// set unlimited allowance for burner from staking router
// to burn finalized requests' shares
// to burn stuck keys penalized shares
IStETH(getLocator().lido()).approve(getLocator().burner(), ~uint256(0));

emit ContractVersionSet(2);
Expand Down Expand Up @@ -319,7 +320,7 @@ contract NodeOperatorsRegistry is AragonApp, Versioned {
function setNodeOperatorName(uint256 _nodeOperatorId, string _name) external {
_onlyValidNodeOperatorName(_name);
_onlyExistedNodeOperator(_nodeOperatorId);
_authP(MANAGE_NODE_OPERATOR_ROLE, arr(uint256(_nodeOperatorId)));
_auth(MANAGE_NODE_OPERATOR_ROLE);

_requireNotSameValue(keccak256(bytes(_nodeOperators[_nodeOperatorId].name)) != keccak256(bytes(_name)));
_nodeOperators[_nodeOperatorId].name = _name;
Expand All @@ -332,7 +333,7 @@ contract NodeOperatorsRegistry is AragonApp, Versioned {
function setNodeOperatorRewardAddress(uint256 _nodeOperatorId, address _rewardAddress) external {
_onlyNonZeroAddress(_rewardAddress);
_onlyExistedNodeOperator(_nodeOperatorId);
_authP(MANAGE_NODE_OPERATOR_ROLE, arr(uint256(_nodeOperatorId), uint256(_rewardAddress)));
_auth(MANAGE_NODE_OPERATOR_ROLE);

_requireNotSameValue(_nodeOperators[_nodeOperatorId].rewardAddress != _rewardAddress);
_nodeOperators[_nodeOperatorId].rewardAddress = _rewardAddress;
Expand Down Expand Up @@ -374,6 +375,7 @@ contract NodeOperatorsRegistry is AragonApp, Versioned {
_auth(STAKING_ROUTER_ROLE);
// since we're pushing rewards to operators after exited validators counts are
// updated (as opposed to pulling by node ops), we don't need any handling here
// see `onAllValidatorCountersUpdated()`
}

/// @notice Called by StakingRouter to update the number of the validators of the given node
Expand Down Expand Up @@ -423,20 +425,21 @@ contract NodeOperatorsRegistry is AragonApp, Versioned {
_distributeRewards();
}

/// @notice Unsafely updates the number of the validators in the EXITED state for node operator with given id
/// @notice Unsafely updates the number of validators in the EXITED/STUCK states for node operator with given id
/// 'unsafely' means that this method can both increase and decrease exited and stuck counters
/// @param _nodeOperatorId Id of the node operator
/// @param _exitedValidatorsCount New number of EXITED validators of the node operator
/// @return Total number of exited validators across all node operators.
/// @param _exitedValidatorsCount New number of EXITED validators for the node operator
/// @param _stuckValidatorsCount New number of STUCK validator for the node operator
function unsafeUpdateValidatorsCount(
uint256 _nodeOperatorId,
uint256 _exitedValidatorsCount,
uint256 _stuckValidatorsKeysCount
uint256 _stuckValidatorsCount
) external {
_onlyExistedNodeOperator(_nodeOperatorId);
_auth(STAKING_ROUTER_ROLE);

_updateExitedValidatorsCount(_nodeOperatorId, uint64(_exitedValidatorsCount), true);
_updateStuckValidatorsCount(_nodeOperatorId, uint64(_stuckValidatorsKeysCount));
_updateExitedValidatorsCount(_nodeOperatorId, uint64(_exitedValidatorsCount), true /* _allowDecrease */);
_updateStuckValidatorsCount(_nodeOperatorId, uint64(_stuckValidatorsCount));
}

function _updateExitedValidatorsCount(uint256 _nodeOperatorId, uint64 _exitedValidatorsKeysCount, bool _allowDecrease)
Expand All @@ -460,7 +463,7 @@ contract NodeOperatorsRegistry is AragonApp, Versioned {

/// @notice Updates the limit of the validators that can be used for deposit by DAO
/// @param _nodeOperatorId Id of the node operator
/// @param _targetLimit New number of EXITED validators of the node operator
/// @param _targetLimit Target limit of the node operator
/// @param _isTargetLimitActive active flag
function updateTargetValidatorsLimits(uint256 _nodeOperatorId, bool _isTargetLimitActive, uint64 _targetLimit) external {
_onlyExistedNodeOperator(_nodeOperatorId);
Expand Down Expand Up @@ -507,7 +510,7 @@ contract NodeOperatorsRegistry is AragonApp, Versioned {
emit RefundedValidatorsCountChanged(_nodeOperatorId, _refundedValidatorsCount);
}

/// @notice Invalidates all unused validators for all node operators
/// @notice Invalidates all unused deposit data for all node operators
function onWithdrawalCredentialsChanged() external {
uint256 operatorsCount = getNodeOperatorsCount();
if (operatorsCount > 0) {
Expand Down Expand Up @@ -548,11 +551,13 @@ contract NodeOperatorsRegistry is AragonApp, Versioned {

/// @notice Obtains up to _depositsCount deposit data to be used by StakingRouter
/// to deposit to the Ethereum Deposit contract
/// @dev the second param is optional staking module calldata
/// (not used for NodeOperatorsRegistry)
/// @param _depositsCount Desireable number of deposits to be done
/// @return depositsCount Actual deposits count might be done with returned data
/// @return publicKeys Batch of the concatenated public validators keys
/// @return signatures Batch of the concatenated deposit signatures for returned public keys
function obtainDepositData(uint256 _depositsCount, bytes)
function obtainDepositData(uint256 _depositsCount, bytes /* _depositCalldata */)
external
returns (
uint256 depositsCount,
Expand Down Expand Up @@ -795,11 +800,11 @@ contract NodeOperatorsRegistry is AragonApp, Versioned {
Packed64x4.Packed memory signingKeysStats = _loadOperatorSigningKeysStats(_nodeOperatorId);
uint256 totalSigningKeysCount = signingKeysStats.get(TOTAL_KEYS_COUNT_OFFSET);

_requireValidRange(totalSigningKeysCount.add(_keysCount) <= UINT64_MAX);

totalSigningKeysCount =
SIGNING_KEYS_MAPPING_NAME.addKeysSigs(_nodeOperatorId, _keysCount, totalSigningKeysCount, _publicKeys, _signatures);

_requireValidRange(totalSigningKeysCount.add(_keysCount) <= UINT64_MAX);

emit TotalSigningKeysCountChanged(_nodeOperatorId, totalSigningKeysCount);

signingKeysStats.set(TOTAL_KEYS_COUNT_OFFSET, uint64(totalSigningKeysCount));
Expand Down Expand Up @@ -888,16 +893,6 @@ contract NodeOperatorsRegistry is AragonApp, Versioned {
return signingKeysStats.get(TOTAL_KEYS_COUNT_OFFSET) - signingKeysStats.get(DEPOSITED_KEYS_COUNT_OFFSET);
}

/// @notice Returns a monotonically increasing counter that gets incremented when any of the following happens:
/// 1. a node operator's key(s) is added;
/// 2. a node operator's key(s) is removed;
/// 3. a node operator's vetted keys count is changed.
/// 4. a node operator was activated/deactivated. Activation or deactivation of node operator
/// might lead to usage of unvalidated keys in the assignNextSigningKeys method.
function getKeysOpIndex() external view returns (uint256) {
return KEYS_OP_INDEX_POSITION.getStorageUint256();
}

/// @notice Returns n-th signing key of the node operator #`_nodeOperatorId`
/// @param _nodeOperatorId Node Operator id
/// @param _index Index of the key, starting with 0
Expand Down Expand Up @@ -1045,6 +1040,19 @@ contract NodeOperatorsRegistry is AragonApp, Versioned {
return KEYS_OP_INDEX_POSITION.getStorageUint256();
}

/// @notice Returns a counter that MUST change its value whenever the deposit data set changes.
/// Below is the typical list of actions that requires an update of the nonce:
/// 1. a node operator's deposit data is added
/// 2. a node operator's deposit data is removed
/// 3. a node operator's ready-to-deposit data size is changed
/// 4. a node operator was activated/deactivated
/// 5. a node operator's deposit data is used for the deposit
/// Note: Depending on the StakingModule implementation above list might be extended
/// @dev DEPRECATED use getNonce() instead
function getKeysOpIndex() external view returns (uint256) {
return KEYS_OP_INDEX_POSITION.getStorageUint256();
}

/// @notice distributes rewards among node operators
/// @return the amount of stETH shares distributed among node operators
function _distributeRewards() internal returns (uint256 distributed) {
Expand Down Expand Up @@ -1139,7 +1147,7 @@ contract NodeOperatorsRegistry is AragonApp, Versioned {
}

function _onlyCorrectNodeOperatorState(bool _pass) internal pure {
require(_pass, "WORNG_OPERATOR_ACTIVE_STATE");
require(_pass, "WRONG_OPERATOR_ACTIVE_STATE");
}

function _auth(bytes32 _role) internal view {
Expand Down
32 changes: 13 additions & 19 deletions contracts/0.4.24/oracle/LegacyOracle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import "@aragon/os/contracts/apps/AragonApp.sol";

import "../../common/interfaces/ILidoLocator.sol";

import "../utils/Versioned.sol";


interface IAccountingOracle {
function getConsensusContract() external view returns (address);
Expand Down Expand Up @@ -43,7 +45,7 @@ interface IHashConsensus {
*
* See docs.lido.fi for more info.
*/
contract LegacyOracle is AragonApp {
contract LegacyOracle is Versioned, AragonApp {

struct ChainSpec {
uint64 epochsPerFrame;
Expand Down Expand Up @@ -79,8 +81,6 @@ contract LegacyOracle is AragonApp {
uint256 totalShares
);

event ContractVersionSet(uint256 version);

/// Address of the Lido contract
bytes32 internal constant LIDO_POSITION =
0xf6978a4f7e200f6d3a24d82d44c48bddabce399a3b8ec42a480ea8a2d5fe6ec5; // keccak256("lido.LidoOracle.lido")
Expand All @@ -93,13 +93,8 @@ contract LegacyOracle is AragonApp {
bytes32 internal constant BEACON_SPEC_POSITION =
0x805e82d53a51be3dfde7cfed901f1f96f5dad18e874708b082adb8841e8ca909; // keccak256("lido.LidoOracle.beaconSpec")

/// Version of the initialized contract data
/// NB: Contract versioning starts from 1.
/// The version stored in CONTRACT_VERSION_POSITION equals to
/// - 0 right after deployment when no initializer is invoked yet
/// - N after calling initialize() during deployment from scratch, where N is the current contract version
/// - N after upgrading contract from the previous version (after calling finalize_vN())
bytes32 internal constant CONTRACT_VERSION_POSITION =
/// Version of the initialized contract data (DEPRECATED)
bytes32 internal constant CONTRACT_VERSION_POSITION_DEPRECATED =
0x75be19a3f314d89bd1f84d30a6c84e2f1cd7afc7b6ca21876564c265113bb7e4; // keccak256("lido.LidoOracle.contractVersion")

/// Historic data about 2 last completed reports and their times
Expand All @@ -126,17 +121,17 @@ contract LegacyOracle is AragonApp {
return ACCOUNTING_ORACLE_POSITION.getStorageAddress();
}

///
/// Compatibility interface (DEPRECATED)
///

/**
* @notice Returns the initialized version of this contract starting from 0.
*/
function getVersion() external view returns (uint256) {
return CONTRACT_VERSION_POSITION.getStorageUint256();
return getContractVersion();
}

///
/// Compatibility interface (DEPRECATED)
///

/**
* @notice DEPRECATED, kept for compatibility purposes only.
*
Expand Down Expand Up @@ -275,7 +270,7 @@ contract LegacyOracle is AragonApp {
address _accountingOracleConsensusContract
) external onlyInit {
// Initializations for v0 --> v3
require(CONTRACT_VERSION_POSITION.getStorageUint256() == 0, "BASE_VERSION_MUST_BE_ZERO");
_checkContractVersion(0);
require(_lidoLocator != address(0), "ZERO_LOCATOR_ADDRESS");
ILidoLocator locator = ILidoLocator(_lidoLocator);

Expand All @@ -297,7 +292,7 @@ contract LegacyOracle is AragonApp {
* Can be called only once.
*/
function finalizeUpgrade_v4(address _accountingOracle) external {
require(CONTRACT_VERSION_POSITION.getStorageUint256() == 3, "WRONG_BASE_VERSION");
require(CONTRACT_VERSION_POSITION_DEPRECATED.getStorageUint256() == 3, "WRONG_BASE_VERSION");
IHashConsensus consensus = IHashConsensus(IAccountingOracle(_accountingOracle).getConsensusContract());

_initialize_v4(_accountingOracle);
Expand All @@ -316,8 +311,7 @@ contract LegacyOracle is AragonApp {
function _initialize_v4(address _accountingOracle) internal {
require(_accountingOracle != address(0), "ZERO_ACCOUNTING_ORACLE_ADDRESS");
ACCOUNTING_ORACLE_POSITION.setStorageAddress(_accountingOracle);
CONTRACT_VERSION_POSITION.setStorageUint256(4);
emit ContractVersionSet(4);
_setContractVersion(4);
}

function _getChainSpec()
Expand Down
37 changes: 0 additions & 37 deletions contracts/0.4.24/test_helpers/LidoMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -70,41 +70,4 @@ contract LidoMock is Lido {
function burnShares(address _account, uint256 _amount) external {
_burnShares(_account, _amount);
}

function handleOracleReportDirect(
// Oracle timings
uint256 _reportTimestamp,
uint256 _timeElapsed,
// CL values
uint256 _clValidators,
uint256 _clBalance,
// EL values
uint256 _withdrawalVaultBalance,
uint256 _elRewardsVaultBalance,
// Decision about withdrawals processing
uint256 _lastFinalizableRequestId,
uint256 _simulatedShareRate
) external returns (
uint256 totalPooledEther,
uint256 totalShares,
uint256 withdrawals,
uint256 elRewards
) {

OracleReportContracts memory protocolContracts = _loadOracleReportContracts();

return _handleOracleReport(
OracleReportedData(
_reportTimestamp,
_timeElapsed,
_clValidators,
_clBalance,
_withdrawalVaultBalance,
_elRewardsVaultBalance,
_lastFinalizableRequestId,
_simulatedShareRate
),
protocolContracts
);
}
}
Loading