-
Notifications
You must be signed in to change notification settings - Fork 681
Add multi dimensional multi constraint pricer algorithm #4012
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
base: master
Are you sure you want to change the base?
Add multi dimensional multi constraint pricer algorithm #4012
Conversation
a3cb346 to
5dc32f7
Compare
5dc32f7 to
a7acb86
Compare
❌ 4 Tests Failed:
View the top 3 failed tests by shortest run time
📣 Thoughts on this report? Let Codecov know! | Powered by Codecov |
454b599 to
28a7a5f
Compare
fa8781a to
4f2c34e
Compare
8ec77cd to
0611789
Compare
b14c464 to
46e002a
Compare
fd0e681 to
752c710
Compare
09d57c1 to
45af934
Compare
gligneul
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great
45af934 to
92ac6ef
Compare
| const GethBlockGasLimit = 1 << 50 | ||
| const gasConstraintsMaxNum = 20 | ||
| const MaxExponentBips = arbmath.Bips(85_000) | ||
| const GasConstraintsMaxNum = 20 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
arbos/l2pricing/l2pricing.go
Outdated
| // 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)) |
There was a problem hiding this comment.
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.
arbos/l2pricing/l2pricing.go
Outdated
| // } | ||
| resourceWeights := map[uint8]uint64{uint8(multigas.ResourceKindComputation): 1} | ||
|
|
||
| var uint32Window uint32 |
There was a problem hiding this comment.
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."
arbos/l2pricing/model.go
Outdated
| return nil | ||
| } | ||
|
|
||
| // applyGasDelta adds delta to backlog if growBacklog=true, otherwise subtracts delta (saturating at zero). |
There was a problem hiding this comment.
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?
arbos/l2pricing/model.go
Outdated
| // 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 |
There was a problem hiding this comment.
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.
precompiles/ArbRetryableTx.go
Outdated
| // 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)) |
There was a problem hiding this comment.
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?
5ba72e8 to
f68c58c
Compare
f68c58c to
7b28238
Compare
Fixes NIT-4069
(Temporary includes #3995)
Depends on:
Changes:
AddToGasPoolto accept multigasGasModelToUseto select a model depending on the configuration