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

❌ 4 Tests Failed:

Tests completed Failed Passed Skipped
2180 4 2176 0
View the top 3 failed tests by shortest run time
TestVersion30
Stack Traces | 5.430s run time
... [CONTENT TRUNCATED: Keeping last 20 lines]
ERROR[12-02|10:31:50.538] a large batch posting backlog exists     recentlyHitL1Bounds=false currentPosition=9 messageCount=103 messagesPerBatch=1 postedMessages=1 unpostedMessages=94  batchBacklogEstimate=94
ERROR[12-02|10:31:50.553] Dangling trie nodes after full cleanup
    precompile_inclusion_test.go:94: goroutine 454113 [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({0x40e7f90, 0xc09fbbfdc0}, {0x40a5820, 0xc0ac6b7cb0}, {0x0, 0x0, 0x0})
        	/home/runner/work/nitro/nitro/util/testhelpers/testhelpers.go:29 +0x55
        github.com/offchainlabs/nitro/system_tests.Require(0xc09fbbfdc0, {0x40a5820, 0xc0ac6b7cb0}, {0x0, 0x0, 0x0})
        	/home/runner/work/nitro/nitro/system_tests/common_test.go:1817 +0x5d
        github.com/offchainlabs/nitro/system_tests.testPrecompiles(0xc09fbbfdc0, 0x1e, {0xc0d1199db0, 0x6, 0x0?})
        	/home/runner/work/nitro/nitro/system_tests/precompile_inclusion_test.go:94 +0x371
        github.com/offchainlabs/nitro/system_tests.TestVersion30(0xc09fbbfdc0?)
        	/home/runner/work/nitro/nitro/system_tests/precompile_inclusion_test.go:67 +0x798
        testing.tRunner(0xc09fbbfdc0, 0x3d2a800)
        	/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 (5.43s)
TestPrimaryToSecondaryFailover
Stack Traces | 5.440s run time
=== RUN   TestPrimaryToSecondaryFailover
=== PAUSE TestPrimaryToSecondaryFailover
=== CONT  TestPrimaryToSecondaryFailover
INFO [12-02|10:23:11.032] arbitrum websocket broadcast server is listening address=[::]:46579
    broadcastclients_test.go:206: Primary broadcaster listening on: [::]:46579
INFO [12-02|10:23:11.032] arbitrum websocket broadcast server is listening address=[::]:35531
    broadcastclients_test.go:207: Secondary broadcaster listening on: [::]:35531
    broadcastclients_test.go:230: Primary URL: ws://127.0.0.1:46579
    broadcastclients_test.go:231: Secondary URL: ws://127.0.0.1:35531
INFO [12-02|10:23:11.033] connecting to arbitrum inbox message broadcaster url=ws://127.0.0.1:46579
    broadcastclients_test.go:278: Phase 1: Sending messages from primary broadcaster
INFO [12-02|10:23:11.034] Feed connected                           feedServerVersion=2 chainId=1234 requestedSeqNum=0
INFO [12-02|10:23:16.244] secondary feed started                   url=ws://127.0.0.1:35531 startingFromSeq=4
INFO [12-02|10:23:16.244] connecting to arbitrum inbox message broadcaster url=ws://127.0.0.1:35531
INFO [12-02|10:23:16.246] Feed connected                           feedServerVersion=2 chainId=1234 requestedSeqNum=4
    broadcastclients_test.go:308: Timed out waiting for message 5/5 from primary
--- FAIL: TestPrimaryToSecondaryFailover (5.44s)
TestVersion40
Stack Traces | 5.460s run time
... [CONTENT TRUNCATED: Keeping last 20 lines]
=== CONT  TestVersion40
�[38;5;48;1myay!! we validated block 3 in 59.83ms�[0;0m
    precompile_inclusion_test.go:94: goroutine 454114 [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({0x40e7f90, 0xc0a19408c0}, {0x40a5820, 0xc0acffe240}, {0x0, 0x0, 0x0})
        	/home/runner/work/nitro/nitro/util/testhelpers/testhelpers.go:29 +0x55
        github.com/offchainlabs/nitro/system_tests.Require(0xc0a19408c0, {0x40a5820, 0xc0acffe240}, {0x0, 0x0, 0x0})
        	/home/runner/work/nitro/nitro/system_tests/common_test.go:1817 +0x5d
        github.com/offchainlabs/nitro/system_tests.testPrecompiles(0xc0a19408c0, 0x28, {0xc0affabdf8, 0x5, 0x39?})
        	/home/runner/work/nitro/nitro/system_tests/precompile_inclusion_test.go:94 +0x371
        github.com/offchainlabs/nitro/system_tests.TestVersion40(0xc0a19408c0?)
        	/home/runner/work/nitro/nitro/system_tests/precompile_inclusion_test.go:71 +0x64b
        testing.tRunner(0xc0a19408c0, 0x3d2a808)
        	/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 (5.46s)

📣 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 5 times, most recently from fd0e681 to 752c710 Compare November 26, 2025 15:43
@MishkaRogachev MishkaRogachev force-pushed the add-multi-dimensional-multi-constraint-pricer-algorithm branch 2 times, most recently from 09d57c1 to 45af934 Compare December 1, 2025 09:46
gligneul
gligneul previously approved these changes Dec 1, 2025
Copy link
Contributor

@gligneul gligneul left a comment

Choose a reason for hiding this comment

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

Looks great

@gligneul gligneul assigned eljobe and unassigned gligneul Dec 1, 2025
@MishkaRogachev MishkaRogachev force-pushed the add-multi-dimensional-multi-constraint-pricer-algorithm branch from 45af934 to 92ac6ef Compare December 1, 2025 12:05
const GethBlockGasLimit = 1 << 50
const gasConstraintsMaxNum = 20
const MaxExponentBips = arbmath.Bips(85_000)
const GasConstraintsMaxNum = 20
Copy link
Member

Choose a reason for hiding this comment

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

How did we decide on 20?

It feels like a "magic number". Let's document the "why"

Also, I feel like we're probably actually going to want more than 20.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These limits are very tight because of retryables. I added TODO(NIT-4152) for increasing/removing these limits in close future

const gasConstraintsMaxNum = 20
const MaxExponentBips = arbmath.Bips(85_000)
const GasConstraintsMaxNum = 20
const MultiGasConstraintsMaxNum = 15
Copy link
Member

Choose a reason for hiding this comment

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

Same question about "why?"

const MaxExponentBips = arbmath.Bips(85_000)
const GasConstraintsMaxNum = 20
const MultiGasConstraintsMaxNum = 15
const MaxPricingExponentBips = arbmath.Bips(85_000)
Copy link
Member

Choose a reason for hiding this comment

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

I also don't know what this means or why it's set to 85,000

// that the new model (which normally applies weight normalization) matches the
// results of the old single-gas model.
//
// resourceWeights := make(map[uint8]uint64, len(FeeRelevantResourceKinds))
Copy link
Member

Choose a reason for hiding this comment

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

Is this commented out code, or part of the documentation? I don't think I really follow what's going on from the description.

// }
resourceWeights := map[uint8]uint64{uint8(multigas.ResourceKindComputation): 1}

var uint32Window uint32
Copy link
Member

Choose a reason for hiding this comment

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

I don't like that the variable name also says the type. It feels very "not go style."

return nil
}

// applyGasDelta adds delta to backlog if growBacklog=true, otherwise subtracts delta (saturating at zero).
Copy link
Member

Choose a reason for hiding this comment

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

I don't see a growBacklog parameter. Stale comment?

// compared to the legacy single-gas model. In the compatibility tests we
// sometimes build a constraint where only ResourceKindComputation has
// weight=1 (all other weights are 0); in that case sumWeights=1 and this
// reduces to the legacy exponent. The commented alternative below shows the
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure it's useful to have the comment about the unnormalized divisor.

// This ensures that the gas pool has enough gas to run the retryable attempt.
return retryTxHash, c.State.L2PricingState().AddToGasPool(arbmath.SaturatingCast[int64](gasToDonate))
// TODO(NIT-4120): clarify the gas dimension for gasToDonate
return retryTxHash, c.State.L2PricingState().UpdateBacklog(l2pricing.Shrink, gasToDonate, multigas.ComputationGas(gasToDonate))
Copy link
Member

Choose a reason for hiding this comment

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

Why not "l2pricing.ShrinkBacklog" and "l2pricing.GrowBacklog" Are we going to support other operations?

@eljobe eljobe assigned MishkaRogachev and unassigned eljobe Dec 1, 2025
@MishkaRogachev MishkaRogachev force-pushed the add-multi-dimensional-multi-constraint-pricer-algorithm branch 3 times, most recently from 5ba72e8 to f68c58c Compare December 1, 2025 17:48
@MishkaRogachev MishkaRogachev force-pushed the add-multi-dimensional-multi-constraint-pricer-algorithm branch from f68c58c to 7b28238 Compare December 2, 2025 10:12
@MishkaRogachev MishkaRogachev marked this pull request as draft December 2, 2025 12:10
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