Commit 8dc0f910 authored by elenadimitrova's avatar elenadimitrova Committed by Kelvin Fichter

Remove unused predeploy interface iOVM_GasPriceOracle

and remove SafeMath from 0.8 GasPriceOracle contract
parent a9fc7310
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity ^0.8.7; pragma solidity ^0.8.7;
/* Internal Imports */
import { iOVM_GasPriceOracle } from "./iOVM_GasPriceOracle.sol";
/* External Imports */ /* External Imports */
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
import { SafeMath } from "@openzeppelin/contracts/math/SafeMath.sol";
/** /**
* @title OVM_GasPriceOracle * @title OVM_GasPriceOracle
...@@ -19,7 +15,7 @@ import { SafeMath } from "@openzeppelin/contracts/math/SafeMath.sol"; ...@@ -19,7 +15,7 @@ import { SafeMath } from "@openzeppelin/contracts/math/SafeMath.sol";
* constructor doesn't run in practice as the L2 state generation script uses * constructor doesn't run in practice as the L2 state generation script uses
* the deployed bytecode instead of running the initcode. * the deployed bytecode instead of running the initcode.
*/ */
contract OVM_GasPriceOracle is Ownable, iOVM_GasPriceOracle { contract OVM_GasPriceOracle is Ownable {
/************* /*************
* Variables * * Variables *
...@@ -52,6 +48,15 @@ contract OVM_GasPriceOracle is Ownable, iOVM_GasPriceOracle { ...@@ -52,6 +48,15 @@ contract OVM_GasPriceOracle is Ownable, iOVM_GasPriceOracle {
transferOwnership(_owner); transferOwnership(_owner);
} }
/**********
* Events *
**********/
event GasPriceUpdated(uint256);
event L1BaseFeeUpdated(uint256);
event OverheadUpdated(uint256);
event ScalarUpdated(uint256);
event DecimalsUpdated(uint256);
/******************** /********************
* Public Functions * * Public Functions *
...@@ -65,7 +70,6 @@ contract OVM_GasPriceOracle is Ownable, iOVM_GasPriceOracle { ...@@ -65,7 +70,6 @@ contract OVM_GasPriceOracle is Ownable, iOVM_GasPriceOracle {
uint256 _gasPrice uint256 _gasPrice
) )
public public
override
onlyOwner onlyOwner
{ {
gasPrice = _gasPrice; gasPrice = _gasPrice;
...@@ -80,7 +84,6 @@ contract OVM_GasPriceOracle is Ownable, iOVM_GasPriceOracle { ...@@ -80,7 +84,6 @@ contract OVM_GasPriceOracle is Ownable, iOVM_GasPriceOracle {
uint256 _baseFee uint256 _baseFee
) )
public public
override
onlyOwner onlyOwner
{ {
l1BaseFee = _baseFee; l1BaseFee = _baseFee;
...@@ -95,7 +98,6 @@ contract OVM_GasPriceOracle is Ownable, iOVM_GasPriceOracle { ...@@ -95,7 +98,6 @@ contract OVM_GasPriceOracle is Ownable, iOVM_GasPriceOracle {
uint256 _overhead uint256 _overhead
) )
public public
override
onlyOwner onlyOwner
{ {
overhead = _overhead; overhead = _overhead;
...@@ -110,7 +112,6 @@ contract OVM_GasPriceOracle is Ownable, iOVM_GasPriceOracle { ...@@ -110,7 +112,6 @@ contract OVM_GasPriceOracle is Ownable, iOVM_GasPriceOracle {
uint256 _scalar uint256 _scalar
) )
public public
override
onlyOwner onlyOwner
{ {
scalar = _scalar; scalar = _scalar;
...@@ -125,7 +126,6 @@ contract OVM_GasPriceOracle is Ownable, iOVM_GasPriceOracle { ...@@ -125,7 +126,6 @@ contract OVM_GasPriceOracle is Ownable, iOVM_GasPriceOracle {
uint256 _decimals uint256 _decimals
) )
public public
override
onlyOwner onlyOwner
{ {
decimals = _decimals; decimals = _decimals;
...@@ -142,16 +142,15 @@ contract OVM_GasPriceOracle is Ownable, iOVM_GasPriceOracle { ...@@ -142,16 +142,15 @@ contract OVM_GasPriceOracle is Ownable, iOVM_GasPriceOracle {
function getL1Fee(bytes memory _data) function getL1Fee(bytes memory _data)
public public
view view
override
returns ( returns (
uint256 uint256
) )
{ {
uint256 l1GasUsed = getL1GasUsed(_data); uint256 l1GasUsed = getL1GasUsed(_data);
uint256 l1Fee = SafeMath.mul(l1GasUsed, l1BaseFee); uint256 l1Fee = l1GasUsed * l1BaseFee;
uint256 divisor = 10**decimals; uint256 divisor = 10**decimals;
uint256 unscaled = SafeMath.mul(l1Fee, scalar); uint256 unscaled = l1Fee * scalar;
uint256 scaled = SafeMath.div(unscaled, divisor); uint256 scaled = unscaled / divisor;
return scaled; return scaled;
} }
...@@ -180,7 +179,6 @@ contract OVM_GasPriceOracle is Ownable, iOVM_GasPriceOracle { ...@@ -180,7 +179,6 @@ contract OVM_GasPriceOracle is Ownable, iOVM_GasPriceOracle {
function getL1GasUsed(bytes memory _data) function getL1GasUsed(bytes memory _data)
public public
view view
override
returns ( returns (
uint256 uint256
) )
...@@ -193,7 +191,7 @@ contract OVM_GasPriceOracle is Ownable, iOVM_GasPriceOracle { ...@@ -193,7 +191,7 @@ contract OVM_GasPriceOracle is Ownable, iOVM_GasPriceOracle {
total += 16; total += 16;
} }
} }
uint256 unsigned = SafeMath.add(total, overhead); uint256 unsigned = total + overhead;
return SafeMath.add(unsigned, 68 * 16); return unsigned + (68 * 16);
} }
} }
// SPDX-License-Identifier: MIT
pragma solidity >0.5.0 <0.8.0;
/**
* @title iOVM_GasPriceOracle
*/
interface iOVM_GasPriceOracle {
/**********
* Events *
**********/
event GasPriceUpdated(uint256);
event L1BaseFeeUpdated(uint256);
event OverheadUpdated(uint256);
event ScalarUpdated(uint256);
event DecimalsUpdated(uint256);
/********************
* Public Functions *
********************/
function setGasPrice(uint256 _gasPrice) external;
function setL1BaseFee(uint256 _baseFee) external;
function setOverhead(uint256 _overhead) external;
function setScalar(uint256 _scalar) external;
function setDecimals(uint256 _decimals) external;
function getL1Fee(bytes memory _data) external returns (uint256);
function getL1GasUsed(bytes memory _data) external returns (uint256);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment