Skip to content

Commit 3fc535b

Browse files
authored
Merge pull request #19 from OffchainLabs/add-precompiles-for-multi-constraint-pricer
Add precompile interfaces for Multi-Constraint Pricer
2 parents a359a65 + edd0528 commit 3fc535b

File tree

6 files changed

+71
-10
lines changed

6 files changed

+71
-10
lines changed

ArbAggregator.sol

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ interface ArbAggregator {
4141
/// This reverts unless called by the batch poster, its fee collector, or a chain owner
4242
/// @param batchPoster The batch poster to set the fee collector for
4343
/// @param newFeeCollector The new fee collector to set
44-
function setFeeCollector(address batchPoster, address newFeeCollector) external;
44+
function setFeeCollector(
45+
address batchPoster,
46+
address newFeeCollector
47+
) external;
4548

4649
/// @notice Deprecated, always returns zero
4750
/// @notice Get the tx base fee (in approximate L1 gas) for aggregator
@@ -56,5 +59,8 @@ interface ArbAggregator {
5659
/// Revert if feeInL1Gas is outside the chain's allowed bounds
5760
/// @param aggregator The aggregator to set the fee for
5861
/// @param feeInL1Gas The base fee in L1 gas
59-
function setTxBaseFee(address aggregator, uint256 feeInL1Gas) external;
62+
function setTxBaseFee(
63+
address aggregator,
64+
uint256 feeInL1Gas
65+
) external;
6066
}

ArbDebug.sol

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ interface ArbDebug {
1313
function becomeChainOwner() external;
1414

1515
/// @notice Emit events with values based on the args provided
16-
function events(bool flag, bytes32 value) external payable returns (address, uint256);
16+
function events(
17+
bool flag,
18+
bytes32 value
19+
) external payable returns (address, uint256);
1720

1821
/// @notice Tries (and fails) to emit logs in a view context
1922
function eventsView() external view;

ArbFunctionTable.sol

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,8 @@ interface ArbFunctionTable {
2222
) external view returns (uint256);
2323

2424
/// @notice No-op
25-
function get(address addr, uint256 index) external view returns (uint256, bool, uint256);
25+
function get(
26+
address addr,
27+
uint256 index
28+
) external view returns (uint256, bool, uint256);
2629
}

ArbGasInfo.sol

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ interface ArbGasInfo {
4949
function getPricesInArbGas() external view returns (uint256, uint256, uint256);
5050

5151
/// @notice Get the gas accounting parameters. `gasPoolMax` is always zero, as the exponential pricing model has no such notion.
52+
/// @notice Starting from ArbOS version 50, returns `speedLimitPerSecond` as the target from the longest-period constraint.
53+
/// @notice For new integrations, prefer `getMaxBlockGasLimit` and `getGasPricingConstraints`.
5254
/// @return (speedLimitPerSecond, gasPoolMax, maxBlockGasLimit)
55+
/// @dev Deprecated starting from ArbOS version 50.
5356
function getGasAccountingParams() external view returns (uint256, uint256, uint256);
5457

5558
/// @notice Get the maxTxGasLimit
@@ -80,12 +83,21 @@ interface ArbGasInfo {
8083
function getCurrentTxL1GasFees() external view returns (uint256);
8184

8285
/// @notice Get the backlogged amount of gas burnt in excess of the speed limit
86+
/// @notice Starting from ArbOS version 50, returns the backlog of the longest-period constraint among all configured constraints.
87+
/// @notice For new integrations, prefer `getGasPricingConstraints`.
88+
/// @dev Deprecated starting from ArbOS version 50.
8389
function getGasBacklog() external view returns (uint64);
8490

8591
/// @notice Get how slowly ArbOS updates the L2 basefee in response to backlogged gas
92+
/// @notice Starting from ArbOS version 50, returns the inertia value derived from the longest-period constraint
93+
/// @notice For new integrations, prefer `getGasPricingConstraints`.
94+
/// @dev Deprecated starting from ArbOS version 50.
8695
function getPricingInertia() external view returns (uint64);
8796

8897
/// @notice Get the forgivable amount of backlogged gas ArbOS will ignore when raising the basefee
98+
/// @notice Starting from ArbOS version 50, this function always returns zero.
99+
/// @notice There is no tolerance for backlogged gas in the new pricing model.
100+
/// @dev Deprecated starting from ArbOS version 50.
89101
function getGasBacklogTolerance() external view returns (uint64);
90102

91103
/// @notice Returns the surplus of funds for L1 batch posting payments (may be negative).
@@ -120,4 +132,17 @@ interface ArbGasInfo {
120132
/// @notice Returns the L1 pricing surplus as of the last update (may be negative).
121133
/// @notice Available in ArbOS version 20 and above
122134
function getLastL1PricingSurplus() external view returns (int256);
135+
136+
/// @notice Get the maximum block gas limit
137+
/// @notice Available in ArbOS version 50 and above
138+
function getMaxBlockGasLimit() external view returns (uint64);
139+
140+
/// @notice Get the current gas pricing constraints used by the Multi-Constraint Pricer.
141+
/// @notice Each constraint contains the following values:
142+
/// - `uint64 gas_target_per_second`: target gas usage per second
143+
/// - `uint64 time_constant_seconds`: time constant in seconds
144+
/// - `uint64 backlog`: current backlog in gas units
145+
/// @return constraints Array of triples (gas_target_per_second, time_constant_seconds, backlog)
146+
/// @notice Available in ArbOS version 50 and above.
147+
function getGasPricingConstraints() external view returns (uint64[3][] memory constraints);
123148
}

ArbOwner.sol

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ interface ArbOwner {
7777
) external;
7878

7979
/// @notice Set the computational speed limit for the chain
80+
/// @notice Starting from ArbOS version 50, this function always returns an error.
81+
/// @notice Use `setGasPricingConstraints` instead, which supports configuring multiple constraints.
82+
/// @dev Deprecated starting from ArbOS version 50.
8083
function setSpeedLimit(
8184
uint64 limit
8285
) external;
@@ -93,11 +96,17 @@ interface ArbOwner {
9396
) external;
9497

9598
/// @notice Set the L2 gas pricing inertia
99+
/// @notice Starting from ArbOS version 50, this function always returns an error.
100+
/// @notice Use `setGasPricingConstraints` instead, which supports configuring multiple constraints.
101+
/// @dev Deprecated starting from ArbOS version 50.
96102
function setL2GasPricingInertia(
97103
uint64 sec
98104
) external;
99105

100106
/// @notice Set the L2 gas backlog tolerance
107+
/// @notice Starting from ArbOS version 50, this function always returns an error.
108+
/// @notice Use `setGasPricingConstraints` instead, which supports configuring multiple constraints.
109+
/// @dev Deprecated starting from ArbOS version 50.
101110
function setL2GasBacklogTolerance(
102111
uint64 sec
103112
) external;
@@ -121,7 +130,10 @@ interface ArbOwner {
121130
) external;
122131

123132
/// @notice Upgrades ArbOS to the requested version at the requested timestamp
124-
function scheduleArbOSUpgrade(uint64 newVersion, uint64 timestamp) external;
133+
function scheduleArbOSUpgrade(
134+
uint64 newVersion,
135+
uint64 timestamp
136+
) external;
125137

126138
/// @notice Sets equilibration units parameter for L1 price adjustment algorithm
127139
function setL1PricingEquilibrationUnits(
@@ -217,7 +229,10 @@ interface ArbOwner {
217229
/// @notice Available in ArbOS version 30 and above
218230
/// @param gas amount of gas paid in increments of 256 when not the program is not cached
219231
/// @param cached amount of gas paid in increments of 64 when the program is cached
220-
function setWasmMinInitGas(uint8 gas, uint16 cached) external;
232+
function setWasmMinInitGas(
233+
uint8 gas,
234+
uint16 cached
235+
) external;
221236

222237
/// @notice Sets the linear adjustment made to program init costs.
223238
/// @notice Available in ArbOS version 30 and above
@@ -268,6 +283,18 @@ interface ArbOwner {
268283
bool enable
269284
) external;
270285

286+
/// @notice Sets the list of gas pricing constraints for the Multi-Constraint Pricer.
287+
/// @notice Replaces the existing constraints configuration and sets each constraint's starting backlog value.
288+
/// @notice All existing backlogs are replaced by the provided values.
289+
/// @notice Any changes to gas targets, periods, or starting backlogs may cause immediate price fluctuations.
290+
/// @notice Operators are fully responsible for the resulting behavior and should adjust parameters carefully.
291+
/// @notice Use ArbGasInfo.getGasPricingConstraints() to retrieve the current configuration.
292+
/// @notice Available in ArbOS version 50 and above.
293+
/// @param constraints Array of triples (gas_target_per_second, period_seconds, starting_backlog_value)
294+
function setGasPricingConstraints(
295+
uint64[3][] calldata constraints
296+
) external;
297+
271298
/// Emitted when a successful call is made to this precompile
272299
event OwnerActs(bytes4 indexed method, address indexed owner, bytes data);
273300
}

ArbStatistics.sol

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,5 @@ interface ArbStatistics {
1515
/// Number of transaction receipt issued,
1616
/// Number of contracts created,
1717
/// )
18-
function getStats()
19-
external
20-
view
21-
returns (uint256, uint256, uint256, uint256, uint256, uint256);
18+
function getStats() external view returns (uint256, uint256, uint256, uint256, uint256, uint256);
2219
}

0 commit comments

Comments
 (0)