Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions ArbGasInfo.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

pragma solidity >=0.4.21 <0.9.0;

import {ArbResourceConstraintsTypes} from "./ArbResourceConstraintsTypes.sol";

/// @title Provides insight into the cost of using the chain.
/// @notice These methods have been adjusted to account for Nitro's heavy use of calldata compression.
/// Of note to end-users, we no longer make a distinction between non-zero and zero-valued calldata bytes.
Expand Down Expand Up @@ -120,4 +122,11 @@ interface ArbGasInfo {
/// @notice Returns the L1 pricing surplus as of the last update (may be negative).
/// @notice Available in ArbOS version 20 and above
function getLastL1PricingSurplus() external view returns (int256);

/// @notice Lists all resource constraints currently configured in ArbOS.
/// @notice Available on ArbOS version 60 and above
function listResourceConstraints()
external
view
returns (ArbResourceConstraintsTypes.ResourceConstraint[] memory constraints);
}
22 changes: 22 additions & 0 deletions ArbOwner.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

pragma solidity >=0.4.21 <0.9.0;

import {ArbResourceConstraintsTypes} from "./ArbResourceConstraintsTypes.sol";

/**
* @title Provides owners with tools for managing the rollup.
* @notice Calls by non-owners will always revert.
Expand Down Expand Up @@ -268,6 +270,26 @@ interface ArbOwner {
bool enable
) external;

/// @notice Adds or updates a resource constraint
/// @notice Available on ArbOS version 60 and above
/// @param resources an array of resource–weight pairs (see Nitro documentation for the list of resources)
/// @param periodSecs the time window for the constraint
/// @param targetPerSec allowed usage per second across weighted resources
function setResourceConstraint(
ArbResourceConstraintsTypes.ResourceWeight[] calldata resources,
uint32 periodSecs,
uint64 targetPerSec
) external;

/// @notice Removes a resource constraint
/// @notice Available on ArbOS version 60 and above
/// @param resources the list of resource kinds to be removed (see Nitro documentation for the list of resources)
/// @param periodSecs the time window for the constraint
function clearConstraint(
ArbResourceConstraintsTypes.ResourceKind[] calldata resources,
uint32 periodSecs
) external;

/// Emitted when a successful call is made to this precompile
event OwnerActs(bytes4 indexed method, address indexed owner, bytes data);
}
36 changes: 36 additions & 0 deletions ArbResourceConstraintsTypes.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright 2025, Offchain Labs, Inc.
// For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE
// SPDX-License-Identifier: BUSL-1.1

pragma solidity >=0.4.21 <0.9.0;

/// @title ArbResourceConstraintsTypes
/// @notice Resource constraints type definitions used by ArbOwner and ArbOwnerPublic precompiles.
library ArbResourceConstraintsTypes {
/// @notice Enumerates the distinct resource kinds used for multi-dimensional gas accounting.
/// @dev The numeric values of this enum must remain consistent with the corresponding
/// @dev The values defined here must stay synchronized with `go-ethereum/arbitrum/multigas/resources.go`.
enum ResourceKind {
Unknown,
Computation,
HistoryGrowth,
StorageAccess,
StorageGrowth,
L1Calldata,
L2Calldata,
WasmComputation
}

/// @notice A pair representing a resource kind and its weight in constraint calculations.
struct ResourceWeight {
ResourceKind resource;
uint64 weight;
}

/// @notice A constraint describing limits for a set of weighted resources.
struct ResourceConstraint {
ResourceWeight[] resources;
uint32 periodSecs;
uint64 targetPerSec;
}
}
Loading