Skip to content

Conversation

@MishkaRogachev
Copy link
Contributor

@MishkaRogachev MishkaRogachev commented Nov 14, 2025

Fixes NIT-4069
(Temporary includes #3995)

Depends on:

Changes:

  • Implement multi-gas pricing constraints model
  • Modify AddToGasPool to accept multigas
  • Implement GasModelToUse to select a model depending on the configuration
  • Migrating gas constraints from single-dimensional to multi-dimensional model (open question)

@MishkaRogachev MishkaRogachev force-pushed the add-multi-dimensional-multi-constraint-pricer-algorithm branch from a3cb346 to 5dc32f7 Compare November 17, 2025 10:00
@MishkaRogachev MishkaRogachev force-pushed the add-multi-dimensional-multi-constraint-pricer-algorithm branch from 5dc32f7 to a7acb86 Compare November 17, 2025 11:21
@github-actions
Copy link

github-actions bot commented Nov 17, 2025

❌ 2 Tests Failed:

Tests completed Failed Passed Skipped
2178 2 2176 0
View the top 2 failed tests by shortest run time
TestVersion30
Stack Traces | 6.090s run time
... [CONTENT TRUNCATED: Keeping last 20 lines]
INFO [11-28|17:10:22.367] HTTP server stopped                      endpoint=127.0.0.1:41571
TRACE[11-28|17:10:22.367] P2P networking is spinning down
    precompile_inclusion_test.go:94: goroutine 455538 [running]:
        runtime/debug.Stack()
        	/opt/hostedtoolcache/go/1.25.4/x64/src/runtime/debug/stack.go:26 +0x5e
        github.com/offchainlabs/nitro/util/testhelpers.RequireImpl({0x40e7a50, 0xc0b16cda40}, {0x40a52e0, 0xc139590660}, {0x0, 0x0, 0x0})
        	/home/runner/work/nitro/nitro/util/testhelpers/testhelpers.go:29 +0x55
        github.com/offchainlabs/nitro/system_tests.Require(0xc0b16cda40, {0x40a52e0, 0xc139590660}, {0x0, 0x0, 0x0})
        	/home/runner/work/nitro/nitro/system_tests/common_test.go:1790 +0x5d
        github.com/offchainlabs/nitro/system_tests.testPrecompiles(0xc0b16cda40, 0x1e, {0xc0765f7db0, 0x6, 0x0?})
        	/home/runner/work/nitro/nitro/system_tests/precompile_inclusion_test.go:94 +0x371
        github.com/offchainlabs/nitro/system_tests.TestVersion30(0xc0b16cda40?)
        	/home/runner/work/nitro/nitro/system_tests/precompile_inclusion_test.go:67 +0x798
        testing.tRunner(0xc0b16cda40, 0x3d2a6b8)
        	/opt/hostedtoolcache/go/1.25.4/x64/src/testing/testing.go:1934 +0xea
        created by testing.(*T).Run in goroutine 1
        	/opt/hostedtoolcache/go/1.25.4/x64/src/testing/testing.go:1997 +0x465
        
    precompile_inclusion_test.go:94: �[31;1m [] execution aborted (timeout = 5s) �[0;0m
--- FAIL: TestVersion30 (6.09s)
TestVersion40
Stack Traces | 6.560s run time
... [CONTENT TRUNCATED: Keeping last 20 lines]
INFO [11-28|17:10:21.905] HTTP server stopped                      endpoint=127.0.0.1:35639
TRACE[11-28|17:10:21.905] P2P networking is spinning down
    precompile_inclusion_test.go:94: goroutine 455539 [running]:
        runtime/debug.Stack()
        	/opt/hostedtoolcache/go/1.25.4/x64/src/runtime/debug/stack.go:26 +0x5e
        github.com/offchainlabs/nitro/util/testhelpers.RequireImpl({0x40e7a50, 0xc0b16cdc00}, {0x40a52e0, 0xc08c44d200}, {0x0, 0x0, 0x0})
        	/home/runner/work/nitro/nitro/util/testhelpers/testhelpers.go:29 +0x55
        github.com/offchainlabs/nitro/system_tests.Require(0xc0b16cdc00, {0x40a52e0, 0xc08c44d200}, {0x0, 0x0, 0x0})
        	/home/runner/work/nitro/nitro/system_tests/common_test.go:1790 +0x5d
        github.com/offchainlabs/nitro/system_tests.testPrecompiles(0xc0b16cdc00, 0x28, {0xc050b43df8, 0x5, 0x39?})
        	/home/runner/work/nitro/nitro/system_tests/precompile_inclusion_test.go:94 +0x371
        github.com/offchainlabs/nitro/system_tests.TestVersion40(0xc0b16cdc00?)
        	/home/runner/work/nitro/nitro/system_tests/precompile_inclusion_test.go:71 +0x64b
        testing.tRunner(0xc0b16cdc00, 0x3d2a6c0)
        	/opt/hostedtoolcache/go/1.25.4/x64/src/testing/testing.go:1934 +0xea
        created by testing.(*T).Run in goroutine 1
        	/opt/hostedtoolcache/go/1.25.4/x64/src/testing/testing.go:1997 +0x465
        
    precompile_inclusion_test.go:94: �[31;1m [] execution aborted (timeout = 5s) �[0;0m
--- FAIL: TestVersion40 (6.56s)

📣 Thoughts on this report? Let Codecov know! | Powered by Codecov

@MishkaRogachev MishkaRogachev force-pushed the add-multi-dimensional-multi-constraint-pricer-algorithm branch 2 times, most recently from 454b599 to 28a7a5f Compare November 18, 2025 13:44
@MishkaRogachev MishkaRogachev marked this pull request as ready for review November 19, 2025 15:04
@MishkaRogachev MishkaRogachev force-pushed the add-multi-dimensional-multi-constraint-pricer-algorithm branch from fa8781a to 4f2c34e Compare November 21, 2025 12:04
@MishkaRogachev MishkaRogachev force-pushed the add-multi-dimensional-multi-constraint-pricer-algorithm branch from 8ec77cd to 0611789 Compare November 21, 2025 14:03
@MishkaRogachev MishkaRogachev assigned gligneul and unassigned gligneul Nov 21, 2025
@MishkaRogachev MishkaRogachev force-pushed the add-multi-dimensional-multi-constraint-pricer-algorithm branch 2 times, most recently from b14c464 to 46e002a Compare November 24, 2025 10:55
@gligneul gligneul assigned MishkaRogachev and unassigned gligneul Nov 24, 2025
@MishkaRogachev MishkaRogachev force-pushed the add-multi-dimensional-multi-constraint-pricer-algorithm branch 3 times, most recently from 0953140 to a138b23 Compare November 25, 2025 17:51
@MishkaRogachev MishkaRogachev force-pushed the add-multi-dimensional-multi-constraint-pricer-algorithm branch from a138b23 to 9392bb1 Compare November 26, 2025 10:47
@MishkaRogachev MishkaRogachev force-pushed the add-multi-dimensional-multi-constraint-pricer-algorithm branch from fd0e681 to 752c710 Compare November 26, 2025 15:43
const GethBlockGasLimit = 1 << 50
const gasConstraintsMaxNum = 20
const MaxExponentBips = arbmath.Bips(85_000)
const multiGasConstraintsMaxNum = 10
Copy link
Contributor

Choose a reason for hiding this comment

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

10 might not be enough.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is a related issue with retryable redeem: if we have more than 17 multi-gas constraints, storage would charge extra 15000 gas units for chunking (assumption). My suggestion is to put 15 for now and after NIT-4152 remove this limit

Comment on lines 279 to 281
func (ps *L2PricingState) MultiGasConstraintsMaxNum() int {
return multiGasConstraintsMaxNum
}
Copy link
Contributor

Choose a reason for hiding this comment

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

You can make the constant public instead of having this method.

}

// GrowBacklog increases the backlog for the active pricing model.
func (ps *L2PricingState) GrowBacklog(usedGas uint64, usedMultiGas multigas.MultiGas) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

You split some functions into separate grow/shrink, but others continue to use the boolean constant, making the code look strange. I have another suggestion:

Suggested change
func (ps *L2PricingState) GrowBacklog(usedGas uint64, usedMultiGas multigas.MultiGas) error {
enum BacklogOp int
const (
Shrink BacklopOp = iota
Grow
)
func (ps *L2PricingState) UpdateBacklog(op BacklogOp, usedGas uint64, usedMultiGas multigas.MultiGas) error {

Copy link
Contributor

Choose a reason for hiding this comment

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

We can probably even make this parameter generic, but I'm not sure if Go can handle this:

Suggested change
func (ps *L2PricingState) GrowBacklog(usedGas uint64, usedMultiGas multigas.MultiGas) error {
func (ps *L2PricingState) UpdateBacklog[op BacklogOp](usedGas uint64, usedMultiGas multigas.MultiGas) error { ```

Comment on lines 129 to 131
if usedMultiGas.SingleGas() != usedGas {
log.Warn("usedGas does not match sum of usedMultiGas", "usedGas", usedGas, "usedMultiGas", usedMultiGas.SingleGas())
}
Copy link
Contributor

Choose a reason for hiding this comment

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

It is so easy to just ignore this warning. I'd rather remove this and think of a better way of testing that these numbers won't diverge.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, by the time we see this warning in production, it will be too late to fix it because we will have to support this divergence forever.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed for now, probably there is way to have a debug-only assertion

Comment on lines 96 to 98
// IncrementBacklog increments the constraint backlog based on multi-dimensional gas usage
func (c *MultiGasConstraint) IncrementBacklog(multiGas multigas.MultiGas) error {
totalBacklog, err := c.backlog.Get()
Copy link
Contributor

Choose a reason for hiding this comment

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

To be consistent with the other models, it would be better to receive the BacklogOp and call applyGasDelta

@MishkaRogachev MishkaRogachev force-pushed the add-multi-dimensional-multi-constraint-pricer-algorithm branch from c8f6c5a to 09d57c1 Compare November 28, 2025 16:53
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.

3 participants