Add Uniswap TWAP fee oracle for batch_policy.log_gas_price - #30
Open
stephenctw wants to merge 19 commits into
Open
Add Uniswap TWAP fee oracle for batch_policy.log_gas_price#30stephenctw wants to merge 19 commits into
stephenctw wants to merge 19 commits into
Conversation
Drop the redundant current_frame_fee argument so dequeue/execute always use the lane's committed WriteHead fee.
Extract Alloy's MetaMask-style medium estimator behind a small helper so batch submission and fee charging stay on one policy.
Convert base+priority gas into fee-token units via a pinned V3 TWAP, apply 10× slack, and persist log_gas_price through a dedicated writer.
Resolve fixed vs Uniswap sources from config, require an initial refresh before the inclusion lane starts, and join the oracle on shutdown.
Record fee-token TWAP charging, writer ownership, env knobs, and Uniswap pool trust in the operator-facing and threat-model docs.
Add live-source worker/math/TWAP unit tests and assert a configured fixed log_gas_price is sampled into the first frame fee on devnet.
Exercise worker shutdown/transient retention, canonical Uniswap sqrt vectors, encode bump behavior, and full Uniswap config overrides.
Move the tenfold price slack into batch_policy.log_slack and encode oracle quotes with fee_from_linear_ceil so the linear path stays exact.
Store the reviewed fee source in deployment_identity, refuse unknown-chain free pricing, refresh before opening the Tip, and skip the worker for Fixed. Misconfig exits terminal; transient quote failures stay unclassified.
Pin Fixed fee at setup in the harness and read the first frame fee directly so the Tip-before-refresh ordering bug cannot regress quietly.
Record that fee-oracle mode and addresses are setup identity, free pricing is refused on unknown chains, and recommended fee includes log_slack (default 1356).
The post-recovery gold-batch pump (~150 self-transfers) needs ~6M in fees at log_recommended_fee 1356; the old 2M deposit ran out mid-loop.
Schema and batch sizing docs still described 10× slack inside the oracle and omitted log_slack from the recommended-fee formula.
Values above fee_to_linear(MAX_EXPONENT) can no longer saturate silently; fee_from_linear_ceil and encode_log_gas_price return an error instead.
Only Uniswap OLD reverts map to insufficient observations / misconfig; other observe failures stay provider errors and exit transient at connect.
Match bootstrap: arithmetic that cannot encode without undercharging pages the operator (EXIT_TERMINAL) instead of an unclassified restart.
Decode the revert payload and require an exact "OLD" reason so gateway messages like THRESHOLD cannot become EXIT_TERMINAL misconfig.
refresh_once already opens the writer before spawn; open_read_only could not catch the failure mode it was shaped for.
Record setup's Fixed write of log_gas_price, fix l1/ list indentation, and document that observe-only failures do not trip the L1 stale-view detector while Uniswap run boot deliberately requires live L1.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
base_fee + priority) into fee-token smallest units via a pinned Uniswap V3 WETH/X 30‑minute TWAP, applies 10× slack, and updatesbatch_policy.log_gas_price.Test plan
cargo test -p sequencer --lib fee_oraclecargo test -p sequencer --lib eip1559cargo test -p sequencer --lib config::cargo run -p rollups-e2e --bin rollups-e2e -- fixed_fee_oracle_sets_frame_fee_test --exactlog_gas_price = 0when fee-oracle env is unset