fix: all account overrides + gas limits#22173
Conversation
|
Merged |
…of github.com:Aztt push!ecProtocol/aztec-packages into gj/wallet_improvements
sirasistant
left a comment
There was a problem hiding this comment.
Inner gas stuff LGTM but haven't read much of the wallet side.
benesjan
left a comment
There was a problem hiding this comment.
Docs and naming Karen is back!
| /** User-provided partial gas settings. */ | ||
| gasSettings?: Partial<FieldsOf<GasSettings>>; | ||
| /** If true, uses high gas limits for estimation/simulation. If false, uses protocol max limits. */ | ||
| forEstimation?: boolean; |
There was a problem hiding this comment.
Why is it called forEstimation?
Could you also explain the difference between high gas limits and protocol max limits? I don't really understand it.
There was a problem hiding this comment.
I understood the naming from below. Maybe something like "canExceedProtocolLimits" would be better?
Then we could explain here why it's fine and desirable to exceed the limits when simulating.
There was a problem hiding this comment.
This is only every used for estimation with the combination of skipFeeEnforcement and skipTxValidation. I wouldn't complicate it further
There was a problem hiding this comment.
I am fine with keeping it as "forEstimation" but would explain here that the high gas limits are higher than the protocol max and how is it even possible and why do we do it. Setting here higher limits than protocol max is very confusing and I think wallet builders will want to understand this so would not dismiss this as it being just an unimportant setting that noone will see (even if it was just for internal team it would make sense to explain).
There was a problem hiding this comment.
I don't see it updated. If you don't want to repeat the explanation here then would point to where it's explained.
| /** Default gas settings to use when user has not provided them. Requires explicit max fees per gas. */ | ||
| static default(overrides: { | ||
| /** | ||
| * Fills in gas limits high enough for transactions to be included in most cases. |
There was a problem hiding this comment.
"in most cases"
I would expect everyone to be asking what are the cases this will fail.
Would also explain here why it's called fallback.
There was a problem hiding this comment.
Explained cases where this would fail
| * Fills in gas limits high enough for transactions to be included in most cases. | ||
| * gasLimits is set to the maximum the protocol allows; since teardown gas is reserved | ||
| * from gasLimits during private execution (see gas_meter.nr), the effective gas available | ||
| * for app logic will be gasLimits - teardownGasLimits - privateOverhead. |
There was a problem hiding this comment.
Unrelated to your PR but the fact that we cannot just use the max protocol limits makes me think the constants were incorrectly defined and now the complexity leaks all the way here and is vomited in the dev's face.
There was a problem hiding this comment.
It's not a constants definition problem, but a chicken-and-egg problem. You need to pay for teardown unconditionally, so you need to allocate some gas to it. How much? Well, you don't know until you estimate. Hence, there's no "max" in the protocol, since you could potentially allocate MAX_PROCESSABLE_L2_GAS to teardown...but then you cannot do anything else
| l2Gas: DEFAULT_TEARDOWN_L2_GAS_LIMIT, | ||
| daGas: DEFAULT_TEARDOWN_DA_GAS_LIMIT, |
There was a problem hiding this comment.
These 2 constants now have stale naming.
There was a problem hiding this comment.
mmm, I thought it was fine keeping them the same, since it's an arbitrary value. Maybe FALLBACK_TEARDOWN_L2_GAS_LIMIT?
| /** User-provided partial gas settings. */ | ||
| gasSettings?: Partial<FieldsOf<GasSettings>>; | ||
| /** If true, uses high gas limits for estimation/simulation. If false, uses protocol max limits. */ | ||
| forEstimation?: boolean; |
There was a problem hiding this comment.
I don't see it updated. If you don't want to repeat the explanation here then would point to where it's explained.
The introduction of `NO_FROM` means that sometimes we might want to override account contracts during simulations that are not the `from` of the transaction (for example, to do authwit capture when the entrypoint is an FPC). This PR overrides accounts also in the `additionalScopes` list before simulating. Gas estimations were poorly defined in the previous implementation. Simulation always estimates gas, and our default gas limits for sending embedded in the protocol. These constants have been removed and moved to `GasSettings` with proper explanations. Furthermore, the pipeline is simplified: * `BaseWallet` will use the user-provided gas limits for everything, and then resort to the an arbitrary max (during sending) or the estimation values (during simulation) if they're not provided. * `EmbeddedWallet` will do the same for simulation, but for sending will simulate first and then apply the estimated gas with a padding to the tx *if the user didn't provide limits*. Why respect the user-provided gas limits during simulation/gas estimation? Sometimes the tx itself will enforce certain conditions on the gas/fee consumed (during teardown, for example). Setting the max limit on teardown will cause those transactions to fail simulation, since teardown gas is charged unconditionally. Closes: https://linear.app/aztec-labs/issue/F-404/decrease-or-remove-default-gas-limits --------- Co-authored-by: Jan Beneš <janbenes1234@gmail.com>
|
✅ Successfully backported to backport-to-v4-next-staging #22258. |
BEGIN_COMMIT_OVERRIDE chore: remove dead to_be_bytes fn (#22243) fix: correct args length in `#[authorize_once]` (#22209) chore: fix inconsistent usage of contract class hash fn (#22248) chore: delete old field comparison fns in favor of lt (#22249) fix: all account overrides + gas limits (#22173) feat: allow for runtime length arrays of sorts and selects (#22250) chore: remove dead pub global vars reexport (#22244) chore: changed default wait behavior (#22325) chore: apply code consistency consolidation (#22251) END_COMMIT_OVERRIDE
BEGIN_COMMIT_OVERRIDE fix: pippenger edge case (#22256) cherry-pick: fix: separate fisherman StatefulSet from rpc-node and stop archiver pollution (#22183) — WITH CONFLICTS fix: separate fisherman StatefulSet from rpc-node and stop archiver pollution (backport #22183) (#22284) fix: preserve DeployAccountMethod type in with() method chaining (#22322) docs: backport docs build/release infrastructure from #22106 and #22144 (#22223) chore(docs): remove v5 nightly and devnet versioned docs (backport #22193) (#22236) chore: improve release-docs skill and add release-network-docs skill (#22328) chore: remove dead to_be_bytes fn (#22243) fix: correct args length in `#[authorize_once]` (#22209) chore: fix inconsistent usage of contract class hash fn (#22248) chore: delete old field comparison fns in favor of lt (#22249) fix: all account overrides + gas limits (#22173) feat: allow for runtime length arrays of sorts and selects (#22250) chore: remove dead pub global vars reexport (#22244) chore: changed default wait behavior (#22325) chore: apply code consistency consolidation (#22251) fix(docs): simplify TypeScript API reference links (backport #22232) (#22369) fix: remove detailed revert codes (#22380) fix: backport #21673 — prevent HA peer proposals from blocking equivocation in duplicate proposal test (#21693) fix: subfield note selectors (#22211) END_COMMIT_OVERRIDE
The introduction of
NO_FROMmeans that sometimes we might want to override account contracts during simulations that are not thefromof the transaction (for example, to do authwit capture when the entrypoint is an FPC). This PR overrides accounts also in theadditionalScopeslist before simulating.Gas estimations were poorly defined in the previous implementation. Simulation always estimates gas, and our default gas limits for sending embedded in the protocol. These constants have been removed and moved to
GasSettingswith proper explanations. Furthermore, the pipeline is simplified:BaseWalletwill use the user-provided gas limits for everything, and then resort to the an arbitrary max (during sending) or the estimation values (during simulation) if they're not provided.EmbeddedWalletwill do the same for simulation, but for sending will simulate first and then apply the estimated gas with a padding to the tx if the user didn't provide limits.Why respect the user-provided gas limits during simulation/gas estimation? Sometimes the tx itself will enforce certain conditions on the gas/fee consumed (during teardown, for example). Setting the max limit on teardown will cause those transactions to fail simulation, since teardown gas is charged unconditionally.
Closes: https://linear.app/aztec-labs/issue/F-404/decrease-or-remove-default-gas-limits