-
Notifications
You must be signed in to change notification settings - Fork 696
Stop charging gas for retryable redeem gas pool update on ArbOS 60+ #4101
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?
Stop charging gas for retryable redeem gas pool update on ArbOS 60+ #4101
Conversation
❌ 4 Tests Failed:
View the top 3 failed tests by shortest run time
📣 Thoughts on this report? Let Codecov know! | Powered by Codecov |
4fa5689 to
85e2c9c
Compare
32ca70c to
2bc088b
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 good, just minor comments.
749e9c7 to
29a5c43
Compare
precompiles/ArbRetryableTx_test.go
Outdated
| } | ||
|
|
||
| func TestRetryableRedeem(t *testing.T) { | ||
| func overrideStateArbOSVersion(evm *vm.EVM, arbosVersion uint64) error { |
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.
instead of that, use newMockEVMForTestingWithVersion
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.
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 follw. If newMockEVMForTestingWithVersion needs to be fixed, let's fix it. Let's talk about it later.
precompiles/ArbRetryableTx.go
Outdated
| // L2PricingState().ShrinkBacklog(). BacklogUpdateCost() returns | ||
| // that amount based on the storage read/write mix used by ShrinkBacklog(). | ||
| backlogUpdateCost := uint64(0) | ||
| if c.State.L2PricingState().ArbosVersion >= params.ArbosVersion_60 { |
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.
in all of those this shouldn't be ArbosVersion60, but arbosVersion_RedeemChargingFix or something similar.
So we could easily change the version in which this applies (can be a number only after it's issued)
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 fixed it to ArbosVersion_MultiGasConstraintsVersion to exclude the possibility of an intermediate state under which there is no implementation.
precompiles/ArbRetryableTx.go
Outdated
| backlogUpdateCost := uint64(0) | ||
| if c.State.L2PricingState().ArbosVersion >= params.ArbosVersion_60 { | ||
| // Charge static price for any pricer starting from ArbOS 60 | ||
| backlogUpdateCost = l2pricing.ArbOS60StaticBacklogUpdateCost |
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 just add that logic into L2PricingState().BacklogUpdateCost() ?
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.
fixed
precompiles/ArbRetryableTx.go
Outdated
| return retryTxHash, c.State.L2PricingState().ShrinkBacklog(gasToDonate, multigas.ComputationGas(gasToDonate)) | ||
| // Starting from ArbOS 60, we don't charge gas for the ShrinkBacklog call here | ||
| if c.State.L2PricingState().ArbosVersion >= params.ArbosVersion_60 { | ||
| err = c.WithUnmeteredGasAccounting(func() error { |
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 get the idea and kind of like it.. however, since the context only exists for a specific call and will be removed once you return from this function (it is created in "func (p *Precompile) Call"), I think this adds more complexity then safety, and it'll probably be simpler to just have a context.StopCollectingGas() function or something similar. This will also allow you to reuse the call to ShrinkBacklog between the options and help us in case we do anything else in the end of the function make sure we don't spend (and need to allocate) more gas.
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 agree, but there is one nuance: after the method completes, the context is still in use, and I see a difference of 3 gas units if I leave it free. I corrected it to a compromise option with defer c.SetUnmeteredGasAccounting(false)
29a5c43 to
48b4998
Compare
48b4998 to
789b552
Compare
precompiles/ArbOwner.go
Outdated
|
|
||
| if c.State.ArbOSVersion() >= params.ArbosVersion_MultiConstraintFix { | ||
| arbosVersion := c.State.ArbOSVersion() | ||
| if arbosVersion >= params.ArbosVersion_MultiConstraintFix && arbosVersion < params.ArbosVersion_60 { |
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.
this should be ArbosVersion_MultiGasConstraintsVersion instead of ArbosVersion_60
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.
Fixed
| evm mech, | ||
| constraints []MultiGasConstraint, | ||
| ) error { | ||
| limit := l2pricing.MultiGasConstraintsMaxNum |
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.
better to make this depend on arbosVersion then remove entirely (I think this check won't spend gas so won't be a problem to add)
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.
Removing this check was a desirable change, as we only introduced it to avoid breaking retyrable-redeem. We did not release a version with this code yet, so I believe it's safe to remove it. (There is also similar check for signle-gas constraints, but this one should be kept)
precompiles/ArbRetryableTx_test.go
Outdated
| } | ||
|
|
||
| func TestRetryableRedeem(t *testing.T) { | ||
| func overrideStateArbOSVersion(evm *vm.EVM, arbosVersion uint64) error { |
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 follw. If newMockEVMForTestingWithVersion needs to be fixed, let's fix it. Let's talk about it later.
1ddc554 to
020720a
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #4101 +/- ##
==========================================
- Coverage 33.25% 32.95% -0.30%
==========================================
Files 459 459
Lines 55826 55835 +9
==========================================
- Hits 18567 18403 -164
- Misses 34015 34210 +195
+ Partials 3244 3222 -22 |
bf4cf7d to
b6f8080
Compare
| } | ||
|
|
||
| func testContextWithVersion(caller addr, evm mech, version uint64) *Context { | ||
| versionOffset := uint64(0) |
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.
Initially I put this version present into testContext, but there is at least one test TestArbInfraFeeAccount which assumes arbosState starts with initial version, so I believe testContextWithVersion is a better fit for retryable edge case
6f44f27 to
e458d6d
Compare
Fixes NIT-4152
pulls in OffchainLabs/go-ethereum#599
Changes:
WithUnmeteredGasAccountingto the precompile context to ignore gas charges within theShrinkBacklogcall.