Commit b3bfb3c7 authored by Mark Tyneway's avatar Mark Tyneway

resource-metering: change params

parent 4f96e19c
...@@ -397,17 +397,15 @@ RLPWriter_writeUint_Test:test_writeUint_smallint_succeeds() (gas: 7280) ...@@ -397,17 +397,15 @@ RLPWriter_writeUint_Test:test_writeUint_smallint_succeeds() (gas: 7280)
RLPWriter_writeUint_Test:test_writeUint_zero_succeeds() (gas: 7749) RLPWriter_writeUint_Test:test_writeUint_zero_succeeds() (gas: 7749)
ResolvedDelegateProxy_Test:test_fallback_addressManagerNotSet_reverts() (gas: 605906) ResolvedDelegateProxy_Test:test_fallback_addressManagerNotSet_reverts() (gas: 605906)
ResolvedDelegateProxy_Test:test_fallback_delegateCallBar_reverts() (gas: 24783) ResolvedDelegateProxy_Test:test_fallback_delegateCallBar_reverts() (gas: 24783)
ResourceMeteringCustom_Test:test_meter_generateArtifact_succeeds() (gas: 1042150946) ResourceMetering_Test:test_meter_initialBaseFee_succeeds() (gas: 7025)
ResourceMetering_Test:test_meter_initialBaseFee_succeeds() (gas: 7245)
ResourceMetering_Test:test_meter_initialResourceParams_succeeds() (gas: 8983) ResourceMetering_Test:test_meter_initialResourceParams_succeeds() (gas: 8983)
ResourceMetering_Test:test_meter_minBaseFeeLessThanMaxBaseFee_succeeds() (gas: 6420) ResourceMetering_Test:test_meter_minBaseFeeLessThanMaxBaseFee_succeeds() (gas: 6194)
ResourceMetering_Test:test_meter_updateNoGasDelta_succeeds() (gas: 2008226) ResourceMetering_Test:test_meter_updateNoGasDelta_succeeds() (gas: 4008242)
ResourceMetering_Test:test_meter_updateOneEmptyBlock_succeeds() (gas: 18645) ResourceMetering_Test:test_meter_updateOneEmptyBlock_succeeds() (gas: 18441)
ResourceMetering_Test:test_meter_updateParamsNoChange_succeeds() (gas: 14005) ResourceMetering_Test:test_meter_updateParamsNoChange_succeeds() (gas: 14005)
ResourceMetering_Test:test_meter_updateTenEmptyBlocks_succeeds() (gas: 21651) ResourceMetering_Test:test_meter_updateTenEmptyBlocks_succeeds() (gas: 21243)
ResourceMetering_Test:test_meter_updateTwoEmptyBlocks_succeeds() (gas: 21607) ResourceMetering_Test:test_meter_updateTwoEmptyBlocks_succeeds() (gas: 21199)
ResourceMetering_Test:test_meter_useMaxWithMaxBaseFee_succeeds() (gas: 29466331) ResourceMetering_Test:test_meter_useMax_succeeds() (gas: 20017420)
ResourceMetering_Test:test_meter_useMax_succeeds() (gas: 8017710)
ResourceMetering_Test:test_meter_useMoreThanMax_reverts() (gas: 16142) ResourceMetering_Test:test_meter_useMoreThanMax_reverts() (gas: 16142)
SafeCall_call_Test:test_callWithMinGas_noLeakageHigh_succeeds() (gas: 2075873614) SafeCall_call_Test:test_callWithMinGas_noLeakageHigh_succeeds() (gas: 2075873614)
SafeCall_call_Test:test_callWithMinGas_noLeakageLow_succeeds() (gas: 753665282) SafeCall_call_Test:test_callWithMinGas_noLeakageLow_succeeds() (gas: 753665282)
......
...@@ -29,13 +29,14 @@ abstract contract ResourceMetering is Initializable { ...@@ -29,13 +29,14 @@ abstract contract ResourceMetering is Initializable {
/** /**
* @notice Maximum amount of the resource that can be used within this block. * @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. * @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. * @notice Target amount of the resource that should be used within this block.
...@@ -50,22 +51,21 @@ abstract contract ResourceMetering is Initializable { ...@@ -50,22 +51,21 @@ abstract contract ResourceMetering is Initializable {
/** /**
* @notice Minimum base fee value, cannot go lower than this. * @notice Minimum base fee value, cannot go lower than this.
*/ */
int256 public constant MINIMUM_BASE_FEE = 10_000; int256 public constant MINIMUM_BASE_FEE = 1 gwei;
/** /**
* @notice Maximum base fee value, cannot go higher than this. * @notice Maximum base fee value, cannot go higher than this.
* This value must be small enough to allow a user to request the * It is possible for the MAXIMUM_BASE_FEE to raise to a value
* MAX_RESOURCE_LIMIT when the base fee is at its max value. * that is so large it will consume the entire gas limit of
* Setting this value too large can result in more gas being * an L1 block.
* consumed than the L1 block gas limit.
*/ */
int256 public constant MAXIMUM_BASE_FEE = int256(uint256((type(uint32).max / 7) * 6)); int256 public constant MAXIMUM_BASE_FEE = int256(uint256((type(uint128).max)));
/** /**
* @notice Initial base fee value. This value must be smaller than the * @notice Initial base fee value. This value must be smaller than the
* MAXIMUM_BASE_FEE. * 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. * @notice EIP-1559 style gas parameters.
...@@ -89,10 +89,12 @@ abstract contract ResourceMetering is Initializable { ...@@ -89,10 +89,12 @@ abstract contract ResourceMetering is Initializable {
// Run the underlying function. // Run the underlying function.
_; _;
// Run the metering function.
_metered(_amount, initialGas); _metered(_amount, initialGas);
} }
/** /**
* @notice An internal function that holds all of the logic for metering a resource. * @notice An internal function that holds all of the logic for metering a resource.
* *
* @param _amount Amount of the resource requested. * @param _amount Amount of the resource requested.
......
...@@ -32,7 +32,7 @@ contract SetPrevBaseFee_Test is Portal_Initializer { ...@@ -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() // In order to achieve this we make no assertions, and handle everything else in the setUp()
// function. // function.
contract GasBenchMark_OptimismPortal is Portal_Initializer { contract GasBenchMark_OptimismPortal is Portal_Initializer {
uint128 INITIAL_BASE_FEE; uint128 internal INITIAL_BASE_FEE;
// Reusable default values for a test withdrawal // Reusable default values for a test withdrawal
Types.WithdrawalTransaction _defaultTx; Types.WithdrawalTransaction _defaultTx;
...@@ -124,7 +124,7 @@ contract GasBenchMark_OptimismPortal is Portal_Initializer { ...@@ -124,7 +124,7 @@ contract GasBenchMark_OptimismPortal is Portal_Initializer {
} }
contract GasBenchMark_L1CrossDomainMessenger is Messenger_Initializer { contract GasBenchMark_L1CrossDomainMessenger is Messenger_Initializer {
uint128 INITIAL_BASE_FEE; uint128 internal INITIAL_BASE_FEE;
function setUp() public virtual override { function setUp() public virtual override {
super.setUp(); super.setUp();
...@@ -153,7 +153,7 @@ contract GasBenchMark_L1CrossDomainMessenger is Messenger_Initializer { ...@@ -153,7 +153,7 @@ contract GasBenchMark_L1CrossDomainMessenger is Messenger_Initializer {
} }
contract GasBenchMark_L1StandardBridge_Deposit is Bridge_Initializer { contract GasBenchMark_L1StandardBridge_Deposit is Bridge_Initializer {
uint128 INITIAL_BASE_FEE; uint128 internal INITIAL_BASE_FEE;
function setUp() public virtual override { function setUp() public virtual override {
super.setUp(); super.setUp();
......
...@@ -20,7 +20,7 @@ fuzz_runs = 16 ...@@ -20,7 +20,7 @@ fuzz_runs = 16
no_match_contract = 'EchidnaFuzz' no_match_contract = 'EchidnaFuzz'
fs_permissions = [ fs_permissions = [
{ 'access'='read-write', 'path'='./' }, { 'access'='read-write', 'path'='./.resource-metering.csv' },
] ]
[profile.ci] [profile.ci]
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
"test": "yarn build:differential && yarn build:fuzz && forge test", "test": "yarn build:differential && yarn build:fuzz && forge test",
"coverage": "yarn build:differential && yarn build:fuzz && forge coverage", "coverage": "yarn build:differential && yarn build:fuzz && forge coverage",
"coverage:lcov": "yarn build:differential && yarn build:fuzz && forge coverage --report lcov", "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", "storage-snapshot": "./scripts/storage-snapshot.sh",
"validate-spacers": "hardhat compile && hardhat validate-spacers", "validate-spacers": "hardhat compile && hardhat validate-spacers",
"slither": "./scripts/slither.sh", "slither": "./scripts/slither.sh",
......
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