Skip to content

Commit

Permalink
Deprecate GasPriceMinimum for L2 (#11012)
Browse files Browse the repository at this point in the history
* deprecate GasPriceMinimum for L2

* version update

* GPM fix

* GPM fix2

* GPM version update
  • Loading branch information
pahor167 authored May 29, 2024
1 parent 1644216 commit 2b8084f
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 7 deletions.
14 changes: 8 additions & 6 deletions packages/protocol/contracts-0.8/common/GasPriceMinimum.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import "../../contracts/common/FixidityLib.sol";
import "./UsingRegistry.sol";
import "../../contracts/stability/interfaces/ISortedOracles.sol";
import "@openzeppelin/contracts8/utils/math/Math.sol";
import "./IsL2Check.sol";

/**
* @title Stores and provides gas price minimum for various currencies.
Expand All @@ -19,6 +20,7 @@ contract GasPriceMinimum is
Ownable,
Initializable,
UsingRegistry,
IsL2Check,
CalledByVm
{
// TODO add IGasPriceMinimum
Expand Down Expand Up @@ -79,7 +81,7 @@ contract GasPriceMinimum is
*/
function setBaseFeeOpCodeActivationBlock(
uint256 _baseFeeOpCodeActivationBlock
) external onlyOwner {
) external onlyOwner onlyL1 {
_setBaseFeeOpCodeActivationBlock(_baseFeeOpCodeActivationBlock, false);
}

Expand All @@ -93,7 +95,7 @@ contract GasPriceMinimum is
function updateGasPriceMinimum(
uint256 blockGasTotal,
uint256 blockGasLimit
) external onlyVm returns (uint256) {
) external onlyVm onlyL1 returns (uint256) {
deprecated_gasPriceMinimum = getUpdatedGasPriceMinimum(blockGasTotal, blockGasLimit);
emit GasPriceMinimumUpdated(deprecated_gasPriceMinimum);
return deprecated_gasPriceMinimum;
Expand Down Expand Up @@ -121,15 +123,15 @@ contract GasPriceMinimum is
* @return Patch version of the contract.
*/
function getVersionNumber() external pure returns (uint256, uint256, uint256, uint256) {
return (1, 2, 0, 1);
return (1, 2, 1, 0);
}

/**
* @notice Set a multiplier that impacts how quickly gas price minimum is adjusted.
* @param _adjustmentSpeed How quickly the minimum changes, expressed as a fixidity fraction.
* @dev Value is expected to be < 1.
*/
function setAdjustmentSpeed(uint256 _adjustmentSpeed) public onlyOwner {
function setAdjustmentSpeed(uint256 _adjustmentSpeed) public onlyOwner onlyL1 {
adjustmentSpeed = FixidityLib.wrap(_adjustmentSpeed);
require(adjustmentSpeed.lt(FixidityLib.fixed1()), "adjustment speed must be smaller than 1");
emit AdjustmentSpeedSet(_adjustmentSpeed);
Expand All @@ -140,7 +142,7 @@ contract GasPriceMinimum is
* @param _targetDensity The target gas fullness of blocks, expressed as a fixidity fraction.
* @dev Value is expected to be < 1.
*/
function setTargetDensity(uint256 _targetDensity) public onlyOwner {
function setTargetDensity(uint256 _targetDensity) public onlyOwner onlyL1 {
targetDensity = FixidityLib.wrap(_targetDensity);
require(targetDensity.lt(FixidityLib.fixed1()), "target density must be smaller than 1");
emit TargetDensitySet(_targetDensity);
Expand All @@ -151,7 +153,7 @@ contract GasPriceMinimum is
* @param _gasPriceMinimumFloor The lowest value the gas price minimum can be.
* @dev Value is expected to be > 0.
*/
function setGasPriceMinimumFloor(uint256 _gasPriceMinimumFloor) public onlyOwner {
function setGasPriceMinimumFloor(uint256 _gasPriceMinimumFloor) public onlyOwner onlyL1 {
require(_gasPriceMinimumFloor > 0, "gas price minimum floor must be greater than zero");
gasPriceMinimumFloor = _gasPriceMinimumFloor;
emit GasPriceMinimumFloorSet(_gasPriceMinimumFloor);
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol/scripts/bash/release-on-devchain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ fi

echo "- Verify bytecode of the network"

yarn run truffle exec ./scripts/truffle/verify-bytecode.js --network development --build_artifacts $BUILD_DIR/contracts --branch $BRANCH --librariesFile libraries.json
yarn run truffle exec ./scripts/truffle/verify-bytecode.js --network development --build_artifacts $BUILD_DIR/contracts --build_artifacts08 $BUILD_DIR/contracts-0.8 --branch $BRANCH --librariesFile libraries.json

echo "- Check versions of current branch"
# From check-versions.sh
Expand Down
23 changes: 23 additions & 0 deletions packages/protocol/test-sol/common/GasPriceMinimum.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ contract GasPriceMinimumTest is Test {
uint256 adjustmentSpeed = FixidityLib.newFixedFraction(5, 10).unwrap();
FixidityLib.Fraction adjustmentSpeedFraction = FixidityLib.newFixedFraction(5, 10);
address registryAddress = 0x000000000000000000000000000000000000ce10;
address constant proxyAdminAddress = 0x4200000000000000000000000000000000000018;

event TargetDensitySet(uint256 targetDensity);
event GasPriceMinimumFloorSet(uint256 gasPriceMinimumFloor);
Expand Down Expand Up @@ -62,6 +63,10 @@ contract GasPriceMinimumTest is Test {
0
);
}

function _whenL2() public {
deployCodeTo("Registry.sol", abi.encode(false), proxyAdminAddress);
}
}

contract GasPriceMinimumTest_initialize is GasPriceMinimumTest {
Expand Down Expand Up @@ -120,6 +125,12 @@ contract GasPriceMinimumTest_setAdjustmentSpeed is GasPriceMinimumTest {
vm.expectRevert("Ownable: caller is not the owner");
gasPriceMinimum.setAdjustmentSpeed(newAdjustmentSpeed);
}

function test_shouldRevertWhenL2() public {
_whenL2();
vm.expectRevert("This method is no longer supported in L2.");
gasPriceMinimum.setAdjustmentSpeed(newAdjustmentSpeed);
}
}

contract GasPriceMinimumTest_setTargetDensity is GasPriceMinimumTest {
Expand Down Expand Up @@ -148,6 +159,12 @@ contract GasPriceMinimumTest_setTargetDensity is GasPriceMinimumTest {
vm.expectRevert("Ownable: caller is not the owner");
gasPriceMinimum.setTargetDensity(newTargetDensity);
}

function test_ShouldRevertWhenL2() public {
_whenL2();
vm.expectRevert("This method is no longer supported in L2.");
gasPriceMinimum.setTargetDensity(newTargetDensity);
}
}

contract GasPriceMinimumTest_setGasPriceMinimumFloor is GasPriceMinimumTest {
Expand Down Expand Up @@ -175,6 +192,12 @@ contract GasPriceMinimumTest_setGasPriceMinimumFloor is GasPriceMinimumTest {
vm.expectRevert("Ownable: caller is not the owner");
gasPriceMinimum.setGasPriceMinimumFloor(newGasPriceMinimumFloor);
}

function test_shouldRevertWhenL2() public {
_whenL2();
vm.expectRevert("This method is no longer supported in L2.");
gasPriceMinimum.setGasPriceMinimumFloor(newGasPriceMinimumFloor);
}
}

contract GasPriceMinimumTest_setUpdatedGasPriceMinimum is GasPriceMinimumTest {
Expand Down

0 comments on commit 2b8084f

Please sign in to comment.