ResourceConstraintManager v2 (add support for setMultiGasPricingConstraints)#415
ResourceConstraintManager v2 (add support for setMultiGasPricingConstraints)#415TucksonDev wants to merge 15 commits intodevelopfrom
Conversation
| // 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) { |
There was a problem hiding this comment.
I think it doesn't matter if a resource has a weight of 0, if I understand the nitro code correctly.
There was a problem hiding this comment.
not necessary, but setting weight to 0 is probably a mistake (can be omitted instead) so good to check here
gzeoneth
left a comment
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
let's set this to 1 to disallow ResourceKindUnknown(0)
There was a problem hiding this comment.
I've just removed the (j>0) guard so it also checks during the first iteration, which will revert if kind = 0
| } | ||
| lastResourceKind = kind; | ||
| } | ||
| } |
There was a problem hiding this comment.
we can check final lastResourceKind is a valid ResourceKind too
There was a problem hiding this comment.
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)
This PR adds support for calling ArbOwner.setMultiGasPricingConstraints from the ResourceConstraintManager contract.
Reference code on external repos: