Skip to content

Commit

Permalink
Removal of smart contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
pahor167 committed Jun 18, 2023
1 parent 5b2cec9 commit dd0ca84
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 180 deletions.
3 changes: 1 addition & 2 deletions packages/protocol/contracts/common/CalledByVm.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.5.13 <0.9.0;
pragma solidity ^0.5.13;

contract CalledByVm {
modifier onlyVm() {
Expand Down
3 changes: 1 addition & 2 deletions packages/protocol/contracts/common/FixidityLib.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.5.13 <0.9.0;
pragma solidity ^0.5.13;

/**
* @title FixidityLib
Expand Down
65 changes: 9 additions & 56 deletions packages/protocol/contracts/common/GasPriceMinimum.sol
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity >=0.8.7;
pragma solidity ^0.5.13;

import "@openzeppelin/contracts8/access/Ownable.sol";
import "openzeppelin-solidity/contracts/math/SafeMath.sol";
import "openzeppelin-solidity/contracts/ownership/Ownable.sol";

import "./CalledByVm.sol";
import "./Initializable.sol";
import "./interfaces/ICeloVersionedContract.sol";
import "./FixidityLib.sol";
import "./UsingRegistry8.sol";
import "./UsingRegistry.sol";
import "../stability/interfaces/ISortedOracles.sol";

/**
Expand All @@ -21,12 +21,12 @@ contract GasPriceMinimum is
CalledByVm
{
using FixidityLib for FixidityLib.Fraction;
using SafeMath for uint256;

event TargetDensitySet(uint256 targetDensity);
event GasPriceMinimumFloorSet(uint256 gasPriceMinimumFloor);
event AdjustmentSpeedSet(uint256 adjustmentSpeed);
event GasPriceMinimumUpdated(uint256 gasPriceMinimum);
event BaseFeeOpCodeActivationBlockSet(uint256 baseFeeOpCodeActivationBlock);

uint256 public gasPriceMinimum;
uint256 public gasPriceMinimumFloor;
Expand All @@ -37,8 +37,6 @@ contract GasPriceMinimum is
// Speed of gas price minimum adjustment due to congestion.
FixidityLib.Fraction public adjustmentSpeed;

uint256 public baseFeeOpCodeActivationBlock;

/**
* @notice Sets initialized == true on implementation contracts
* @param test Set to true to skip implementation initialization
Expand All @@ -62,22 +60,19 @@ contract GasPriceMinimum is
* @param _gasPriceMinimumFloor The lowest value the gas price minimum can be.
* @param _targetDensity The target gas fullness of blocks, expressed as a fixidity fraction.
* @param _adjustmentSpeed How quickly the minimum changes, expressed as a fixidity fraction.
* @param _baseFeeOpCodeActivationBlock Block number where the baseFee opCode is activated
*/
function initialize(
address _registryAddress,
uint256 _gasPriceMinimumFloor,
uint256 _targetDensity,
uint256 _adjustmentSpeed,
uint256 _baseFeeOpCodeActivationBlock
uint256 _adjustmentSpeed
) external initializer {
_transferOwnership(msg.sender);
setRegistry(_registryAddress);
gasPriceMinimum = _gasPriceMinimumFloor;
setGasPriceMinimumFloor(_gasPriceMinimumFloor);
setTargetDensity(_targetDensity);
setAdjustmentSpeed(_adjustmentSpeed);
_setBaseFeeOpCodeActivationBlock(_baseFeeOpCodeActivationBlock, true);
}

/**
Expand Down Expand Up @@ -113,60 +108,25 @@ contract GasPriceMinimum is
emit GasPriceMinimumFloorSet(_gasPriceMinimumFloor);
}

/**
* @notice Set the activation block of the baseFee opCode.
* @param _baseFeeOpCodeActivationBlock Block number where the baseFee opCode is activated
* @dev Value is expected to be > 0.
*/
function setBaseFeeOpCodeActivationBlock(uint256 _baseFeeOpCodeActivationBlock)
external
onlyOwner
{
_setBaseFeeOpCodeActivationBlock(_baseFeeOpCodeActivationBlock, false);
}

/**
* @notice Set the activation block of the baseFee opCode.
* @param _baseFeeOpCodeActivationBlock Block number where the baseFee opCode is activated
* @dev Value is expected to be > 0.
*/
function _setBaseFeeOpCodeActivationBlock(uint256 _baseFeeOpCodeActivationBlock, bool allowZero)
private
onlyOwner
{
require(
allowZero || _baseFeeOpCodeActivationBlock > 0,
"baseFee opCode activation block must be greater than zero"
);
baseFeeOpCodeActivationBlock = _baseFeeOpCodeActivationBlock;
emit BaseFeeOpCodeActivationBlockSet(_baseFeeOpCodeActivationBlock);
}

/**
* @notice Retrieve the current gas price minimum for a currency.
* @param tokenAddress The currency the gas price should be in (defaults to gold).
* @return current gas price minimum in the requested currency
*/
function getGasPriceMinimum(address tokenAddress) external view returns (uint256) {
uint256 _gasPriceMinimum;
if (baseFeeOpCodeActivationBlock > 0 && block.number >= baseFeeOpCodeActivationBlock) {
_gasPriceMinimum = block.basefee;
} else {
_gasPriceMinimum = gasPriceMinimum;
}
if (
tokenAddress == address(0) ||
tokenAddress == registry.getAddressForOrDie(GOLD_TOKEN_REGISTRY_ID)
) {
return _gasPriceMinimum;
return gasPriceMinimum;
} else {
ISortedOracles sortedOracles = ISortedOracles(
registry.getAddressForOrDie(SORTED_ORACLES_REGISTRY_ID)
);
uint256 rateNumerator;
uint256 rateDenominator;
(rateNumerator, rateDenominator) = sortedOracles.medianRate(tokenAddress);
return ((_gasPriceMinimum * rateNumerator) / rateDenominator);
return (gasPriceMinimum.mul(rateNumerator).div(rateDenominator));
}
}

Expand Down Expand Up @@ -213,15 +173,8 @@ contract GasPriceMinimum is
? FixidityLib.fixed1().add(adjustmentSpeed.multiply(densityDelta))
: FixidityLib.fixed1().subtract(adjustmentSpeed.multiply(densityDelta));

uint256 _gasPriceMinimum;
if (baseFeeOpCodeActivationBlock > 0 && block.number >= baseFeeOpCodeActivationBlock) {
_gasPriceMinimum = block.basefee;
} else {
_gasPriceMinimum = gasPriceMinimum;
}

uint256 newGasPriceMinimum = adjustment
.multiply(FixidityLib.newFixed(_gasPriceMinimum))
.multiply(FixidityLib.newFixed(gasPriceMinimum))
.add(FixidityLib.fixed1())
.fromFixed();

Expand Down
3 changes: 1 addition & 2 deletions packages/protocol/contracts/common/Initializable.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.5.13 <0.9.0;
pragma solidity ^0.5.13;

contract Initializable {
bool public initialized;
Expand Down
3 changes: 1 addition & 2 deletions packages/protocol/contracts/common/UsingPrecompiles.sol
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ contract UsingPrecompiles {
* @param index Index of requested validator in the validator set.
* @return Address of validator at the requested index.
*/
// TODO: (soloseng) add to precompiles
function validatorSignerAddressFromCurrentSet(uint256 index) public view returns (address) {
bytes memory out;
bool success;
Expand Down Expand Up @@ -135,7 +134,6 @@ contract UsingPrecompiles {
* @notice Gets the size of the current elected validator set.
* @return Size of the current elected validator set.
*/
// TODO:(soloseng) add to precompiles.
function numberValidatorsInCurrentSet() public view returns (uint256) {
bytes memory out;
bool success;
Expand Down Expand Up @@ -270,4 +268,5 @@ contract UsingPrecompiles {
function minQuorumSizeInCurrentSet() public view returns (uint256) {
return minQuorumSize(block.number);
}

}
110 changes: 0 additions & 110 deletions packages/protocol/contracts/common/UsingRegistry8.sol

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.5.13 <0.9.0;
pragma solidity ^0.5.13;

interface IAttestations {
function revoke(bytes32, uint256) external;
Expand Down
3 changes: 1 addition & 2 deletions packages/protocol/contracts/identity/interfaces/IRandom.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.5.13 <0.9.0;
pragma solidity ^0.5.13;

interface IRandom {
function revealAndCommit(bytes32, bytes32, address) external;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.5.13 <0.9.0;
pragma solidity ^0.5.13;

interface ISortedOracles {
function addOracle(address, address) external;
Expand Down

0 comments on commit dd0ca84

Please sign in to comment.