Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
2861d92a
Commit
2861d92a
authored
Jun 11, 2023
by
Ratimon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix linting for resource metering
parent
9a824b55
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
9 deletions
+8
-9
ResourceMetering.t.sol
...-bedrock/contracts/test/invariants/ResourceMetering.t.sol
+8
-9
No files found.
packages/contracts-bedrock/contracts/test/invariants/ResourceMetering.t.sol
View file @
2861d92a
...
@@ -4,7 +4,7 @@ pragma solidity 0.8.15;
...
@@ -4,7 +4,7 @@ pragma solidity 0.8.15;
import { Test } from "forge-std/Test.sol";
import { Test } from "forge-std/Test.sol";
import { StdUtils } from "forge-std/StdUtils.sol";
import { StdUtils } from "forge-std/StdUtils.sol";
import {
StdInvariant
} from "forge-std/StdInvariant.sol";
import {
StdInvariant
} from "forge-std/StdInvariant.sol";
import { Arithmetic } from "../../libraries/Arithmetic.sol";
import { Arithmetic } from "../../libraries/Arithmetic.sol";
import { ResourceMetering } from "../../L1/ResourceMetering.sol";
import { ResourceMetering } from "../../L1/ResourceMetering.sol";
...
@@ -12,7 +12,6 @@ import { Proxy } from "../../universal/Proxy.sol";
...
@@ -12,7 +12,6 @@ import { Proxy } from "../../universal/Proxy.sol";
import { Constants } from "../../libraries/Constants.sol";
import { Constants } from "../../libraries/Constants.sol";
contract ResourceMetering_User is StdUtils, ResourceMetering {
contract ResourceMetering_User is StdUtils, ResourceMetering {
bool public failedMaxGasPerBlock;
bool public failedMaxGasPerBlock;
bool public failedRaiseBaseFee;
bool public failedRaiseBaseFee;
bool public failedLowerBaseFee;
bool public failedLowerBaseFee;
...
@@ -45,11 +44,13 @@ contract ResourceMetering_User is StdUtils, ResourceMetering {
...
@@ -45,11 +44,13 @@ contract ResourceMetering_User is StdUtils, ResourceMetering {
ResourceMetering.ResourceConfig memory rcfg = Constants.DEFAULT_RESOURCE_CONFIG();
ResourceMetering.ResourceConfig memory rcfg = Constants.DEFAULT_RESOURCE_CONFIG();
return rcfg;
return rcfg;
}
}
/**
/**
* @notice Takes the necessary parameters to allow us to burn arbitrary amounts of gas to test
* @notice Takes the necessary parameters to allow us to burn arbitrary amounts of gas to test
* the underlying resource metering/gas market logic
* the underlying resource metering/gas market logic
*/
*/
function burn(uint256 _gasToBurn, bool _raiseBaseFee) public { // Part 1: we cache the current param values and do some basic checks on them.
function burn(uint256 _gasToBurn, bool _raiseBaseFee) public {
// Part 1: we cache the current param values and do some basic checks on them.
uint256 cachedPrevBaseFee = uint256(params.prevBaseFee);
uint256 cachedPrevBaseFee = uint256(params.prevBaseFee);
uint256 cachedPrevBoughtGas = uint256(params.prevBoughtGas);
uint256 cachedPrevBoughtGas = uint256(params.prevBoughtGas);
uint256 cachedPrevBlockNum = uint256(params.prevBlockNum);
uint256 cachedPrevBlockNum = uint256(params.prevBlockNum);
...
@@ -151,7 +152,6 @@ contract ResourceMetering_User is StdUtils, ResourceMetering {
...
@@ -151,7 +152,6 @@ contract ResourceMetering_User is StdUtils, ResourceMetering {
}
}
function _burnInternal(uint64 _gasToBurn) private metered(_gasToBurn) {}
function _burnInternal(uint64 _gasToBurn) private metered(_gasToBurn) {}
}
}
contract ResourceMetering_Invariant is StdInvariant, Test {
contract ResourceMetering_Invariant is StdInvariant, Test {
...
@@ -177,18 +177,18 @@ contract ResourceMetering_Invariant is StdInvariant, Test {
...
@@ -177,18 +177,18 @@ contract ResourceMetering_Invariant is StdInvariant, Test {
* empty blocks in between), ensure this block's baseFee increased, but not by
* empty blocks in between), ensure this block's baseFee increased, but not by
* more than the max amount per block.
* more than the max amount per block.
*/
*/
function invariant_high_usage_raise_baseFee() external {
function invariant_high_usage_raise_baseFee() external {
assertFalse(actor.failedRaiseBaseFee());
assertFalse(actor.failedRaiseBaseFee());
}
}
/**
/**
* @custom:invariant The base fee should decrease if the last block used less
* @custom:invariant The base fee should decrease if the last block used less
* than the target amount of gas
* than the target amount of gas
*
*
* If the previous block used less than the target amount of gas, the base fee should decrease,
* If the previous block used less than the target amount of gas, the base fee should decrease,
* but not more than the max amount.
* but not more than the max amount.
*/
*/
function invariant_low_usage_lower_baseFee() external {
function invariant_low_usage_lower_baseFee() external {
assertFalse(actor.failedLowerBaseFee());
assertFalse(actor.failedLowerBaseFee());
}
}
...
@@ -245,4 +245,3 @@ contract ResourceMetering_Invariant is StdInvariant, Test {
...
@@ -245,4 +245,3 @@ contract ResourceMetering_Invariant is StdInvariant, Test {
assertFalse(actor.underflow());
assertFalse(actor.underflow());
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment