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
b3bfb3c7
Commit
b3bfb3c7
authored
Mar 09, 2023
by
Mark Tyneway
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
resource-metering: change params
parent
4f96e19c
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
70 additions
and
90 deletions
+70
-90
.gas-snapshot
packages/contracts-bedrock/.gas-snapshot
+7
-9
ResourceMetering.sol
packages/contracts-bedrock/contracts/L1/ResourceMetering.sol
+11
-9
BenchmarkTest.t.sol
...ages/contracts-bedrock/contracts/test/BenchmarkTest.t.sol
+3
-3
ResourceMetering.t.sol
...s/contracts-bedrock/contracts/test/ResourceMetering.t.sol
+47
-67
foundry.toml
packages/contracts-bedrock/foundry.toml
+1
-1
package.json
packages/contracts-bedrock/package.json
+1
-1
No files found.
packages/contracts-bedrock/.gas-snapshot
View file @
b3bfb3c7
...
...
@@ -397,17 +397,15 @@ RLPWriter_writeUint_Test:test_writeUint_smallint_succeeds() (gas: 7280)
RLPWriter_writeUint_Test:test_writeUint_zero_succeeds() (gas: 7749)
ResolvedDelegateProxy_Test:test_fallback_addressManagerNotSet_reverts() (gas: 605906)
ResolvedDelegateProxy_Test:test_fallback_delegateCallBar_reverts() (gas: 24783)
ResourceMeteringCustom_Test:test_meter_generateArtifact_succeeds() (gas: 1042150946)
ResourceMetering_Test:test_meter_initialBaseFee_succeeds() (gas: 7245)
ResourceMetering_Test:test_meter_initialBaseFee_succeeds() (gas: 7025)
ResourceMetering_Test:test_meter_initialResourceParams_succeeds() (gas: 8983)
ResourceMetering_Test:test_meter_minBaseFeeLessThanMaxBaseFee_succeeds() (gas: 6
420
)
ResourceMetering_Test:test_meter_updateNoGasDelta_succeeds() (gas:
2008226
)
ResourceMetering_Test:test_meter_updateOneEmptyBlock_succeeds() (gas: 18
645
)
ResourceMetering_Test:test_meter_minBaseFeeLessThanMaxBaseFee_succeeds() (gas: 6
194
)
ResourceMetering_Test:test_meter_updateNoGasDelta_succeeds() (gas:
4008242
)
ResourceMetering_Test:test_meter_updateOneEmptyBlock_succeeds() (gas: 18
441
)
ResourceMetering_Test:test_meter_updateParamsNoChange_succeeds() (gas: 14005)
ResourceMetering_Test:test_meter_updateTenEmptyBlocks_succeeds() (gas: 21651)
ResourceMetering_Test:test_meter_updateTwoEmptyBlocks_succeeds() (gas: 21607)
ResourceMetering_Test:test_meter_useMaxWithMaxBaseFee_succeeds() (gas: 29466331)
ResourceMetering_Test:test_meter_useMax_succeeds() (gas: 8017710)
ResourceMetering_Test:test_meter_updateTenEmptyBlocks_succeeds() (gas: 21243)
ResourceMetering_Test:test_meter_updateTwoEmptyBlocks_succeeds() (gas: 21199)
ResourceMetering_Test:test_meter_useMax_succeeds() (gas: 20017420)
ResourceMetering_Test:test_meter_useMoreThanMax_reverts() (gas: 16142)
SafeCall_call_Test:test_callWithMinGas_noLeakageHigh_succeeds() (gas: 2075873614)
SafeCall_call_Test:test_callWithMinGas_noLeakageLow_succeeds() (gas: 753665282)
...
...
packages/contracts-bedrock/contracts/L1/ResourceMetering.sol
View file @
b3bfb3c7
...
...
@@ -29,13 +29,14 @@ abstract contract ResourceMetering is Initializable {
/**
* @notice Maximum amount of the resource that can be used within this block.
* This value cannot be larger than the L2 block gas limit.
*/
int256 public constant MAX_RESOURCE_LIMIT =
8
_000_000;
int256 public constant MAX_RESOURCE_LIMIT =
20
_000_000;
/**
* @notice Along with the resource limit, determines the target resource limit.
*/
int256 public constant ELASTICITY_MULTIPLIER =
4
;
int256 public constant ELASTICITY_MULTIPLIER =
5
;
/**
* @notice Target amount of the resource that should be used within this block.
...
...
@@ -50,22 +51,21 @@ abstract contract ResourceMetering is Initializable {
/**
* @notice Minimum base fee value, cannot go lower than this.
*/
int256 public constant MINIMUM_BASE_FEE = 1
0_000
;
int256 public constant MINIMUM_BASE_FEE = 1
gwei
;
/**
* @notice Maximum base fee value, cannot go higher than this.
* This value must be small enough to allow a user to request the
* MAX_RESOURCE_LIMIT when the base fee is at its max value.
* Setting this value too large can result in more gas being
* consumed than the L1 block gas limit.
* It is possible for the MAXIMUM_BASE_FEE to raise to a value
* that is so large it will consume the entire gas limit of
* an L1 block.
*/
int256 public constant MAXIMUM_BASE_FEE = int256(uint256((type(uint
32).max / 7) * 6
));
int256 public constant MAXIMUM_BASE_FEE = int256(uint256((type(uint
128).max)
));
/**
* @notice Initial base fee value. This value must be smaller than the
* MAXIMUM_BASE_FEE.
*/
uint128 public constant INITIAL_BASE_FEE = 1
_000_000_000
;
uint128 public constant INITIAL_BASE_FEE = 1
gwei
;
/**
* @notice EIP-1559 style gas parameters.
...
...
@@ -89,10 +89,12 @@ abstract contract ResourceMetering is Initializable {
// Run the underlying function.
_;
// Run the metering function.
_metered(_amount, initialGas);
}
/**
* @notice An internal function that holds all of the logic for metering a resource.
*
* @param _amount Amount of the resource requested.
...
...
packages/contracts-bedrock/contracts/test/BenchmarkTest.t.sol
View file @
b3bfb3c7
...
...
@@ -32,7 +32,7 @@ contract SetPrevBaseFee_Test is Portal_Initializer {
// In order to achieve this we make no assertions, and handle everything else in the setUp()
// function.
contract GasBenchMark_OptimismPortal is Portal_Initializer {
uint128 INITIAL_BASE_FEE;
uint128
internal
INITIAL_BASE_FEE;
// Reusable default values for a test withdrawal
Types.WithdrawalTransaction _defaultTx;
...
...
@@ -124,7 +124,7 @@ contract GasBenchMark_OptimismPortal is Portal_Initializer {
}
contract GasBenchMark_L1CrossDomainMessenger is Messenger_Initializer {
uint128 INITIAL_BASE_FEE;
uint128
internal
INITIAL_BASE_FEE;
function setUp() public virtual override {
super.setUp();
...
...
@@ -153,7 +153,7 @@ contract GasBenchMark_L1CrossDomainMessenger is Messenger_Initializer {
}
contract GasBenchMark_L1StandardBridge_Deposit is Bridge_Initializer {
uint128 INITIAL_BASE_FEE;
uint128
internal
INITIAL_BASE_FEE;
function setUp() public virtual override {
super.setUp();
...
...
packages/contracts-bedrock/contracts/test/ResourceMetering.t.sol
View file @
b3bfb3c7
This diff is collapsed.
Click to expand it.
packages/contracts-bedrock/foundry.toml
View file @
b3bfb3c7
...
...
@@ -20,7 +20,7 @@ fuzz_runs = 16
no_match_contract
=
'EchidnaFuzz'
fs_permissions
=
[
{
'access'='read-write'
,
'path'='./'
}
,
{
'access'='read-write'
,
'path'='./
.resource-metering.csv
'
}
,
]
[profile.ci]
...
...
packages/contracts-bedrock/package.json
View file @
b3bfb3c7
...
...
@@ -28,7 +28,7 @@
"test"
:
"yarn build:differential && yarn build:fuzz && forge test"
,
"coverage"
:
"yarn build:differential && yarn build:fuzz && forge coverage"
,
"coverage:lcov"
:
"yarn build:differential && yarn build:fuzz && forge coverage --report lcov"
,
"gas-snapshot"
:
"yarn build:differential && yarn build:fuzz && forge snapshot --no-match-test 'testDiff|testFuzz|invariant|
ResourceMeteringCustom
'"
,
"gas-snapshot"
:
"yarn build:differential && yarn build:fuzz && forge snapshot --no-match-test 'testDiff|testFuzz|invariant|
generateArtifact
'"
,
"storage-snapshot"
:
"./scripts/storage-snapshot.sh"
,
"validate-spacers"
:
"hardhat compile && hardhat validate-spacers"
,
"slither"
:
"./scripts/slither.sh"
,
...
...
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