Skip to content

Add a type for modeling multiple-dimensional gas #482

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jul 3, 2025

Conversation

gligneul
Copy link
Contributor

@gligneul gligneul commented Jul 2, 2025

This PR introduces the package multigas that contains the code related to multi-dimensional gas. It adds the ResourceKind enum that represents a gas resource.

This PR introduces the package multigas that contains the code related
to multi-dimensional gas. It adds the ResourceKind enum that represents
a gas resource, and the ResourceConstraints struct that represents a set
of constraints.

Close NIT-3487
@gligneul gligneul requested review from eljobe, magicxyyz and Copilot July 2, 2025 13:37
@cla-bot cla-bot bot added the s CLA signed label Jul 2, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR defines a new multigas package to model per-resource gas constraints for the EVM.

  • Introduces ResourceKind enum and MultiGas array type
  • Implements ResourceConstraints map with SetConstraint and ClearConstraint methods
  • Adds unit tests covering basic constraint operations

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
arbitrum/multigas/resources.go Defines ResourceKind enum and MultiGas type
arbitrum/multigas/doc.go Adds package-level documentation
arbitrum/multigas/constraint.go Implements ResourceConstraints type and its methods
arbitrum/multigas/constraint_test.go Tests for adding, updating, and clearing resource constraints
Comments suppressed due to low confidence (3)

arbitrum/multigas/constraint.go:6

  • The identifier 'constraint' collides with Go's generic 'constraint' keyword and is ambiguous. Consider renaming it to something more specific, e.g. 'resourceConstraint'.
type constraint struct {

arbitrum/multigas/constraint.go:23

  • Exported constructor is missing a doc comment. Please add a comment describing what NewResourceConstraints returns and any initialization details.
func NewResourceConstraints() ResourceConstraints {

arbitrum/multigas/constraint_test.go:8

  • The test currently covers only Computation and HistoryGrowth. Consider adding cases for StorageAccess and StorageGrowth to ensure all resource kinds are initialized and handled correctly.
func TestResourceConstraints(t *testing.T) {

@eljobe eljobe assigned gligneul and unassigned eljobe Jul 2, 2025
@gligneul gligneul requested a review from eljobe July 2, 2025 14:42
@gligneul gligneul assigned eljobe and unassigned gligneul Jul 2, 2025
@eljobe eljobe assigned gligneul and unassigned eljobe Jul 2, 2025
The resource constraint struct won't be used directly in go-ethereum, so
we decided to move it to the nitro repository.
@gligneul gligneul changed the title Add a type for modeling a Resource Constraint Add a type for modeling multiple-dimensional gas Jul 3, 2025
gligneul added a commit to OffchainLabs/nitro that referenced this pull request Jul 3, 2025
The ResourceConstraints struct tracks the constraints used in
constraint-based pricing.

Depends on OffchainLabs/go-ethereum#482
Close NIT-3487
@gligneul gligneul merged commit 5f6f869 into master Jul 3, 2025
15 checks passed
@gligneul gligneul deleted the gligneul/gas-resources branch July 3, 2025 12:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants