-
Notifications
You must be signed in to change notification settings - Fork 710
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
Changes from all commits
15110ab
6b444f4
63a92c4
24bf507
b1ebf85
a9f6e6b
9b94a85
4e6cba6
e458d6d
abbdb92
fd142c1
72ad901
7798857
ee8255d
1f35521
471463a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| ### Changed | ||
| - Remove manual gas math from ArbRetryableTx.Redeem by using static L2 pricing backlog update cost |
| Original file line number | Diff line number | Diff line change | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -12,6 +12,7 @@ import ( | ||||||||||||||||
| "github.com/ethereum/go-ethereum/core/types" | |||||||||||||||||
| "github.com/ethereum/go-ethereum/params" | |||||||||||||||||
|
|
|||||||||||||||||
| "github.com/offchainlabs/nitro/arbos/l2pricing" | |||||||||||||||||
| "github.com/offchainlabs/nitro/arbos/retryables" | |||||||||||||||||
| "github.com/offchainlabs/nitro/arbos/util" | |||||||||||||||||
| "github.com/offchainlabs/nitro/util/arbmath" | |||||||||||||||||
|
|
@@ -99,11 +100,11 @@ func (con ArbRetryableTx) Redeem(c ctx, evm mech, ticketId bytes32) (bytes32, er | ||||||||||||||||
| gasCostToReturnResult := params.CopyGas | |||||||||||||||||
|
|
|||||||||||||||||
| // `redeem` must prepay the gas needed by the trailing call to | |||||||||||||||||
| // L2PricingState().AddToGasPool(). GasPoolUpdateCost(ArbOSVersion) returns | |||||||||||||||||
| // that amount based on the storage read/write mix used by AddToGasPool(). | |||||||||||||||||
| gasPoolUpdateCost := c.State.L2PricingState().BacklogUpdateCost() | |||||||||||||||||
| // L2PricingState().ShrinkBacklog(). BacklogUpdateCost() returns | |||||||||||||||||
| // that amount based on the storage read/write mix used by ShrinkBacklog(). | |||||||||||||||||
| backlogUpdateCost := c.State.L2PricingState().BacklogUpdateCost() | |||||||||||||||||
|
|
|||||||||||||||||
| futureGasCosts := eventCost + gasCostToReturnResult + gasPoolUpdateCost | |||||||||||||||||
| futureGasCosts := eventCost + gasCostToReturnResult + backlogUpdateCost | |||||||||||||||||
| if c.GasLeft() < futureGasCosts { | |||||||||||||||||
| return hash{}, c.Burn(multigas.ResourceKindComputation, futureGasCosts) // this will error | |||||||||||||||||
| } | |||||||||||||||||
|
|
@@ -132,7 +133,16 @@ func (con ArbRetryableTx) Redeem(c ctx, evm mech, ticketId bytes32) (bytes32, er | ||||||||||||||||
|
|
|||||||||||||||||
| // Add the gasToDonate back to the gas pool: the retryable attempt will then consume it. | |||||||||||||||||
| // This ensures that the gas pool has enough gas to run the retryable attempt. | |||||||||||||||||
| // TODO(NIT-4120): clarify the gas dimension for gasToDonate | |||||||||||||||||
| // Starting from ArbosVersion_MultiGasConstraintsVersion, don't charge gas for the ShrinkBacklog call. | |||||||||||||||||
| stopChargingGas := c.State.L2PricingState().ArbosVersion >= params.ArbosVersion_MultiGasConstraintsVersion | |||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. where do you charge the backlog update cost?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is my current understanding:
So having the single gas constraints configured on ArbOS 50 should be the only broken state (fixed by MultiConstraintFix)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With the latest changes:
|
|||||||||||||||||
| if stopChargingGas { | |||||||||||||||||
| if err := c.Burn(multigas.ResourceKindComputation, l2pricing.MultiConstraintStaticBacklogUpdateCost); err != nil { | |||||||||||||||||
| return hash{}, err | |||||||||||||||||
| } | |||||||||||||||||
|
|
|||||||||||||||||
| c.SetUnmeteredGasAccounting(true) | |||||||||||||||||
| defer c.SetUnmeteredGasAccounting(false) | |||||||||||||||||
| } | |||||||||||||||||
| return retryTxHash, c.State.L2PricingState().ShrinkBacklog(gasToDonate, multigas.ComputationGas(gasToDonate)) | |||||||||||||||||
| } | |||||||||||||||||
|
|
|||||||||||||||||
|
|
|||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.