-
Notifications
You must be signed in to change notification settings - Fork 375
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'release/core-contracts/12' into martinvol/AddOraclesToF…
…eeHandlersSellers
- Loading branch information
Showing
31 changed files
with
1,485 additions
and
232 deletions.
There are no files selected for viewing
361 changes: 315 additions & 46 deletions
361
packages/protocol/contracts-0.8/common/EpochManager.sol
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
packages/protocol/contracts-0.8/common/PrecompilesOverride.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// SPDX-License-Identifier: LGPL-3.0-only | ||
pragma solidity >=0.8.7 <0.8.20; | ||
|
||
import "../../contracts/common/interfaces/ICeloVersionedContract.sol"; | ||
import "../../contracts-0.8/common/IsL2Check.sol"; | ||
|
||
import "./UsingPrecompiles.sol"; | ||
import "./UsingRegistry.sol"; | ||
|
||
/** | ||
* @title PrecompilesOverride Contract | ||
* @notice This contract allows for a smoother transition from L1 to L2 | ||
* by abstracting away the usingPrecompile contract, and taking care of the L1 to L2 swtiching logic. | ||
**/ | ||
contract PrecompilesOverride is UsingPrecompiles, UsingRegistry { | ||
/** | ||
* @notice Returns the epoch number at a block. | ||
* @param blockNumber Block number where epoch number is calculated. | ||
* @return Epoch number. | ||
*/ | ||
function getEpochNumberOfBlock(uint256 blockNumber) public view override returns (uint256) { | ||
if (isL2()) { | ||
return getEpochManager().getEpochNumberOfBlock(blockNumber); | ||
} else { | ||
return epochNumberOfBlock(blockNumber, getEpochSize()); | ||
} | ||
} | ||
|
||
/** | ||
* @notice Returns the epoch number at a block. | ||
* @return Current epoch number. | ||
*/ | ||
function getEpochNumber() public view override returns (uint256) { | ||
return getEpochNumberOfBlock(block.number); | ||
} | ||
|
||
/** | ||
* @notice Gets a validator signer address from the current validator set. | ||
* @param index Index of requested validator in the validator set. | ||
* @return Address of validator signer at the requested index. | ||
*/ | ||
function validatorSignerAddressFromCurrentSet( | ||
uint256 index | ||
) public view override returns (address) { | ||
if (isL2()) { | ||
return getEpochManager().getElectedSignerByIndex(index); | ||
} else { | ||
super.validatorSignerAddressFromCurrentSet(index); | ||
} | ||
} | ||
|
||
/** | ||
* @notice Gets a validator address from the current validator set. | ||
* @param index Index of requested validator in the validator set. | ||
* @return Address of validator at the requested index. | ||
*/ | ||
|
||
function validatorAddressFromCurrentSet(uint256 index) public view onlyL2 returns (address) { | ||
return getEpochManager().getElectedAccountByIndex(index); | ||
} | ||
|
||
/** | ||
* @notice Gets the size of the current elected validator set. | ||
* @return Size of the current elected validator set. | ||
*/ | ||
function numberValidatorsInCurrentSet() public view override returns (uint256) { | ||
if (isL2()) { | ||
return getEpochManager().numberOfElectedInCurrentSet(); | ||
} else { | ||
return super.numberValidatorsInCurrentSet(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.