Skip to content

Commit 75fbb78

Browse files
feat: add listResourceConstraints view
1 parent fa4b4e4 commit 75fbb78

File tree

3 files changed

+35
-9
lines changed

3 files changed

+35
-9
lines changed

ArbOwner.sol

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
pragma solidity >=0.4.21 <0.9.0;
66

7+
import {ArbResourceConstraintsTypes} from "./ArbResourceConstraintsTypes.sol";
8+
79
/**
810
* @title Provides owners with tools for managing the rollup.
911
* @notice Calls by non-owners will always revert.
@@ -256,21 +258,13 @@ interface ArbOwner {
256258
bool enable
257259
) external;
258260

259-
/// @notice A pair representing a resource kind and its weight in constraint calculations.
260-
/// @param resource the resource kind (see Nitro documentation for list of resources)
261-
/// @param weight the relative weight of this resource in the constraint
262-
struct ResourceWeight {
263-
uint8 resource;
264-
uint64 weight;
265-
}
266-
267261
/// @notice Adds or updates a resource constraint
268262
/// @notice Available on ArbOS version 50 and above
269263
/// @param resources an array of (resource, weight) pairs
270264
/// @param periodSecs the time window for the constraint
271265
/// @param targetPerSec allowed usage per second across weighted resources
272266
function setResourceConstraint(
273-
ResourceWeight[] calldata resources,
267+
ArbResourceConstraintsTypes.ResourceWeight[] calldata resources,
274268
uint32 periodSecs,
275269
uint64 targetPerSec
276270
) external;

ArbOwnerPublic.sol

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
pragma solidity >=0.4.21 <0.9.0;
66

7+
import {ArbResourceConstraintsTypes} from "./ArbResourceConstraintsTypes.sol";
8+
79
/// @title Provides non-owners with info about the current chain owners.
810
/// @notice Precompiled contract that exists in every Arbitrum chain at 0x000000000000000000000000000000000000006b.
911
interface ArbOwnerPublic {
@@ -55,4 +57,11 @@ interface ArbOwnerPublic {
5557
function isCalldataPriceIncreaseEnabled() external view returns (bool);
5658

5759
event ChainOwnerRectified(address rectifiedOwner);
60+
61+
/// @notice Lists all resource constraints currently configured in ArbOS.
62+
/// @notice Available on ArbOS version 50 and above
63+
function listResourceConstraints()
64+
external
65+
view
66+
returns (ArbResourceConstraintsTypes.ResourceConstraint[] memory constraints);
5867
}

ArbResourceConstraintsTypes.sol

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright 2025, Offchain Labs, Inc.
2+
// For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE
3+
// SPDX-License-Identifier: BUSL-1.1
4+
5+
pragma solidity >=0.4.21 <0.9.0;
6+
7+
/// @title ArbResourceConstraintsTypes
8+
/// @notice Resource constraints type definitions used by ArbOwner and ArbOwnerPublic precompiles.
9+
library ArbResourceConstraintsTypes {
10+
/// @notice A pair representing a resource kind and its weight in constraint calculations.
11+
struct ResourceWeight {
12+
uint8 resource;
13+
uint64 weight;
14+
}
15+
16+
/// @notice A constraint describing limits for a set of weighted resources.
17+
struct ResourceConstraint {
18+
ResourceWeight[] resources;
19+
uint32 periodSecs;
20+
uint64 targetPerSec;
21+
uint64 backlog;
22+
}
23+
}

0 commit comments

Comments
 (0)