Skip to content

ResourceConstraintManager v2 (add support for setMultiGasPricingConstraints)#415

Open
TucksonDev wants to merge 15 commits intodevelopfrom
resourceconstraintmanagerv2
Open

ResourceConstraintManager v2 (add support for setMultiGasPricingConstraints)#415
TucksonDev wants to merge 15 commits intodevelopfrom
resourceconstraintmanagerv2

Conversation

@TucksonDev
Copy link
Copy Markdown
Contributor

@TucksonDev TucksonDev commented Mar 6, 2026

This PR adds support for calling ArbOwner.setMultiGasPricingConstraints from the ResourceConstraintManager contract.

Reference code on external repos:

// We calculate the implied pricing exponent for each resource kind
uint8 numResourceKinds = uint8(type(ArbMultiGasConstraintsTypes.ResourceKind).max) + 1;
uint64[] memory pricingExponents = new uint64[](numResourceKinds);
for (uint256 i = 0; i < nConstraints; ++i) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe also check weight != 0

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it doesn't matter if a resource has a weight of 0, if I understand the nitro code correctly.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not necessary, but setting weight to 0 is probably a mistake (can be omitted instead) so good to check here

@TucksonDev TucksonDev requested a review from gzeoneth March 10, 2026 10:44
waelsy123
waelsy123 previously approved these changes Mar 19, 2026
gzeoneth
gzeoneth previously approved these changes Mar 20, 2026
Copy link
Copy Markdown
Member

@gzeoneth gzeoneth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, some minor additional validation suggested

// The check is performed here instead of in the loop below (for calculating pricing exponents)
// to prevent bypassing the check when setting a starting backlog value of zero
// (in that case, nitro would only store the last of the duplicated entries)
uint8 lastResourceKind = 0;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's set this to 1 to disallow ResourceKindUnknown(0)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've just removed the (j>0) guard so it also checks during the first iteration, which will revert if kind = 0

}
lastResourceKind = kind;
}
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can check final lastResourceKind is a valid ResourceKind too

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the struct property is ResourceKind resource;, it should revert if we ever pass a kind that is out of range there (if I understood your comment correctly)

@TucksonDev TucksonDev dismissed stale reviews from gzeoneth and waelsy123 via e266f6f March 20, 2026 09:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants