@valve-tech/gas-oracle 0.10.1 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +2 -2
- package/CHANGELOG.md +63 -0
- package/README.md +18 -0
- package/dist/index.d.ts +12 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/math.d.ts +2 -1
- package/dist/math.d.ts.map +1 -1
- package/dist/math.js.map +1 -1
- package/dist/mempool.d.ts +1 -9
- package/dist/mempool.d.ts.map +1 -1
- package/dist/mempool.js.map +1 -1
- package/dist/oracle.d.ts +39 -2
- package/dist/oracle.d.ts.map +1 -1
- package/dist/oracle.js +96 -27
- package/dist/oracle.js.map +1 -1
- package/dist/ring.d.ts +103 -0
- package/dist/ring.d.ts.map +1 -0
- package/dist/ring.js +160 -0
- package/dist/ring.js.map +1 -0
- package/dist/samples.d.ts +1 -1
- package/dist/samples.d.ts.map +1 -1
- package/dist/samples.js.map +1 -1
- package/dist/transport.d.ts +8 -27
- package/dist/transport.d.ts.map +1 -1
- package/dist/transport.js.map +1 -1
- package/dist/types.d.ts +29 -43
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +6 -0
- package/dist/types.js.map +1 -1
- package/dist/viem-actions.d.ts.map +1 -1
- package/dist/viem-actions.js.map +1 -1
- package/package.json +2 -2
- package/skills/gas-oracle-integration/SKILL.md +1 -1
package/AGENTS.md
CHANGED
|
@@ -54,8 +54,8 @@ import { withGasOracle } from '@valve-tech/gas-oracle/viem-transport'
|
|
|
54
54
|
|
|
55
55
|
| Type | What it is |
|
|
56
56
|
|---|---|
|
|
57
|
-
| `CreateGasOracleOptions` | Constructor config. Required: `client`, `chainId`. Tuneables: `priorityFeeDecayCap`, `priorityModel`, `baseFeeLivenessBlocks`, `poll`, `keepMempoolSnapshot
|
|
58
|
-
| `GasOracleState` | What `oracle.getState()` returns. Holds the four-tier `tiers` map plus latest `baseFee`, `bufferedBaseFee`, mempool snapshot if enabled. |
|
|
57
|
+
| `CreateGasOracleOptions` | Constructor config. Required: `client`, `chainId`. Tuneables: `priorityFeeDecayCap`, `priorityModel`, `baseFeeLivenessBlocks`, `poll`, `keepMempoolSnapshot`, `ringWindowBlocks` (default 20n). |
|
|
58
|
+
| `GasOracleState` | What `oracle.getState()` returns. Holds the four-tier `tiers` map plus latest `baseFee`, `bufferedBaseFee`, mempool snapshot if enabled, the rolling block `ring`, and `lastReorg` (a `ReorgEvent \| null` describing the most recent ring trim, if any). |
|
|
59
59
|
| `TierRecommendation` | Per-tier struct: `{ maxPriorityFeePerGas, maxFeePerGas, gasPrice, maxFeePerBlobGas }`. All `bigint`. |
|
|
60
60
|
| `RawTx` | One mempool entry: `{ hash, from, to, nonce, value, maxPriorityFeePerGas, maxFeePerGas, gas, ... }`. Nullable fields for fields the chain may not expose. |
|
|
61
61
|
| `BlockPositionQuery` | Discriminated union — five mutually-exclusive shapes (see below). |
|
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,69 @@ All notable changes to `@valve-tech/gas-oracle` are documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/).
|
|
7
7
|
|
|
8
|
+
## [0.11.0] — 2026-05-11
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- 20-block ring lifecycle for `state.ring`. The single-element
|
|
13
|
+
placeholder is replaced with a real rolling window: each new block
|
|
14
|
+
goes through one of `append` / `duplicate` / `reorg` / `restart`,
|
|
15
|
+
with head-trim when the window cap would be exceeded. The poll
|
|
16
|
+
loop pre-fetches missing blocks via `source.getBlock(n)` to bridge
|
|
17
|
+
clean gaps before the reducer runs (one notification, not N).
|
|
18
|
+
- `createGasOracle` option `ringWindowBlocks?: bigint` — controls
|
|
19
|
+
the ring cap. Default `20n`, matching the `eth_feeHistory` window.
|
|
20
|
+
Pass `0n` to disable the cap (replay harnesses) or `1n` to restore
|
|
21
|
+
the v0.10 single-block-per-tick semantics.
|
|
22
|
+
- `GasOracleState.lastReorg: ReorgEvent | null` — populated when the
|
|
23
|
+
ring lifecycle trims diverged tail blocks. Persists across
|
|
24
|
+
subsequent clean appends; consumers asking "did a reorg happen on
|
|
25
|
+
THIS tick?" should compare `lastReorg.blockNumber === blockNumber`.
|
|
26
|
+
- Pure ring helper exported as `incorporateBlock(prevRing, newBlock,
|
|
27
|
+
maxWindow)` from the package root. Useful for replay harnesses or
|
|
28
|
+
tests verifying ring transitions independent of the rest of the
|
|
29
|
+
reducer.
|
|
30
|
+
- `reducePollInputs` accepts an optional `historicalBlocks?:
|
|
31
|
+
BlockResult[]` (oldest → newest) so callers replaying RPC payloads
|
|
32
|
+
can fill the ring in one call.
|
|
33
|
+
|
|
34
|
+
### Changed
|
|
35
|
+
|
|
36
|
+
- Tier numbers are now multi-block-stabilized: `state.tiers.*` are
|
|
37
|
+
computed from `ring[*].tips ++ mempoolSamples`, not just the latest
|
|
38
|
+
block's tips. This is the user-visible effect of the ring
|
|
39
|
+
lifecycle — quiet single-block dips no longer collapse the
|
|
40
|
+
paying-lane tiers (the cap mechanism was previously load-bearing
|
|
41
|
+
for that case). Behavior change is intentional; consumers wanting
|
|
42
|
+
the v0.10 semantics can pass `ringWindowBlocks: 1n`.
|
|
43
|
+
- Wire-shape types (`RawTx`, `BlockResult`, `FeeHistoryResult`,
|
|
44
|
+
`TxPoolContent`, `NormalizedMempool`) and the poll-cycle toggle
|
|
45
|
+
(`PollOptions`) are no longer declared locally — they're imported
|
|
46
|
+
from `@valve-tech/chain-source`, the canonical owner. The package
|
|
47
|
+
continues to re-export every one from `index.ts`, so downstream
|
|
48
|
+
`import { RawTx } from '@valve-tech/gas-oracle'` keeps working.
|
|
49
|
+
Type identity now unifies across the toolkit (a `BlockResult`
|
|
50
|
+
from gas-oracle is the same nominal type as one from chain-source).
|
|
51
|
+
No runtime change; no breaking change in consumed shapes.
|
|
52
|
+
|
|
53
|
+
### Notes
|
|
54
|
+
|
|
55
|
+
- Reorg-side backfill is intentionally **not** in this change. When a
|
|
56
|
+
parentHash mismatch is detected, the reducer trims the diverged
|
|
57
|
+
tail and continues from the new block forward — the new canonical
|
|
58
|
+
branch refills via natural forward polling rather than a
|
|
59
|
+
refetch-by-hash walk. (`@valve-tech/chain-source` doesn't expose a
|
|
60
|
+
by-hash fetch yet; adding one would be a chain-source change in
|
|
61
|
+
scope for a follow-up if user signal warrants it.)
|
|
62
|
+
- `reduceAndPublish` was refactored to take `inputs.block: BlockResult`
|
|
63
|
+
(non-null) — the previous defensive `if (next)` guard plus
|
|
64
|
+
`/* c8 ignore */` directive were silencing coverage on a path
|
|
65
|
+
unreachable from either caller (`handleBlock` and `pollOnce` both
|
|
66
|
+
gate on non-null block). No behavior change; the dead branch is
|
|
67
|
+
gone. Closes the workspace-wide 100% coverage goal alongside new
|
|
68
|
+
tests for the gap-bridge logic in `handleBlock`/`pollOnce` and
|
|
69
|
+
the deeper-ancestor branch in `ring.ts`.
|
|
70
|
+
|
|
8
71
|
## [0.10.1] — 2026-05-08
|
|
9
72
|
|
|
10
73
|
Synchronized release — no changes to this package. Republished at
|
package/README.md
CHANGED
|
@@ -164,6 +164,24 @@ lookups without a second RPC roundtrip. Memory cost is the size of one
|
|
|
164
164
|
`txpool_content` payload (5–15MB on busy ETH mainnet); leave off in
|
|
165
165
|
browser/mobile contexts. Default `false`.
|
|
166
166
|
|
|
167
|
+
### `ringWindowBlocks`
|
|
168
|
+
|
|
169
|
+
Maximum number of blocks retained in `state.ring` for percentile
|
|
170
|
+
sampling. Default `20n` (matches the `eth_feeHistory` window). Tier
|
|
171
|
+
recommendations are computed from `ring[*].tips ++ mempoolSamples`,
|
|
172
|
+
so a larger window stabilizes the tier numbers across blocks at the
|
|
173
|
+
cost of more memory (~150 tips/block). Pass `1n` to restore
|
|
174
|
+
single-block-per-tick behavior; pass `0n` to disable the cap (only
|
|
175
|
+
useful for replay harnesses).
|
|
176
|
+
|
|
177
|
+
The poll loop pre-fetches missing blocks via `source.getBlock(n)` to
|
|
178
|
+
bridge gaps between consecutive ticks (e.g. after `pauseWhenIdle`
|
|
179
|
+
resumes), so the ring stays dense across brief upstream pauses.
|
|
180
|
+
Reorgs trim the ring's diverged tail and surface as
|
|
181
|
+
`state.lastReorg` (a `ReorgEvent | null` describing the trim depth
|
|
182
|
+
and dropped hashes); the new canonical branch refills via natural
|
|
183
|
+
forward polling.
|
|
184
|
+
|
|
167
185
|
## Idle-traffic controls (v0.2.6+)
|
|
168
186
|
|
|
169
187
|
Real dapps run multiple oracles per session (e.g. PulseChain + Base)
|
package/dist/index.d.ts
CHANGED
|
@@ -15,11 +15,20 @@
|
|
|
15
15
|
export { createGasOracle, reducePollInputs, sampleGasFees, type CreateGasOracleOptions, type GasOracle, } from './oracle.js';
|
|
16
16
|
export { effectiveTip, computePercentiles, detectTrend, cappedTip, computeTiers, computeBlobBaseFee, flattenTxPool, gasWeightedPercentiles, sortedTips, DEFAULT_PRIORITY_FEE_DECAY_CAP, DEFAULT_BASE_FEE_LIVENESS_BLOCKS, } from './math.js';
|
|
17
17
|
export { blockToSample, mempoolToSamples, } from './samples.js';
|
|
18
|
-
export {
|
|
19
|
-
export type {
|
|
18
|
+
export { incorporateBlock } from './ring.js';
|
|
19
|
+
export type { ReorgEvent, RingMutation } from './ring.js';
|
|
20
|
+
export { fetchOracleInputs, fetchHeadBlockNumber, type OraclePollInputs, } from './transport.js';
|
|
21
|
+
export type { TipPercentiles, TierRecommendation, MempoolStats, BlobStats, BlockSample, GasOracleState, TipSample, } from './types.js';
|
|
20
22
|
export { PriorityModel, TierName, TIER_LADDER, Trend, TxType } from './types.js';
|
|
21
23
|
export { normalizeMempool, findByHash, findByAddressNonce, findInMempool, } from './mempool.js';
|
|
22
|
-
export type {
|
|
24
|
+
export type { TxIdentifier, MempoolBucket, MempoolHit, } from './mempool.js';
|
|
25
|
+
/**
|
|
26
|
+
* Wire-shape types describing raw `eth_*` responses, plus the poll-cycle
|
|
27
|
+
* toggle. Owned by `@valve-tech/chain-source`; re-exported here so
|
|
28
|
+
* downstream consumers don't have to add a second package import to
|
|
29
|
+
* type a fixture or a stored snapshot.
|
|
30
|
+
*/
|
|
31
|
+
export type { BlockResult, FeeHistoryResult, NormalizedMempool, PollOptions, RawTx, TxPoolContent, } from '@valve-tech/chain-source';
|
|
23
32
|
export { tipForBlockPosition } from './block-position.js';
|
|
24
33
|
export type { BlockPositionQuery, BlockPositionResult, } from './block-position.js';
|
|
25
34
|
export { minimumReplacementFee, bumpForReplacement, recommendBumpTier, BumpStrategy, ReplacementBumpPercent, } from './replacement.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,KAAK,sBAAsB,EAC3B,KAAK,SAAS,GACf,MAAM,aAAa,CAAA;AAEpB,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,WAAW,EACX,SAAS,EACT,YAAY,EACZ,kBAAkB,EAClB,aAAa,EACb,sBAAsB,EACtB,UAAU,EACV,8BAA8B,EAC9B,gCAAgC,GACjC,MAAM,WAAW,CAAA;AAElB,OAAO,EACL,aAAa,EACb,gBAAgB,GACjB,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,KAAK,sBAAsB,EAC3B,KAAK,SAAS,GACf,MAAM,aAAa,CAAA;AAEpB,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,WAAW,EACX,SAAS,EACT,YAAY,EACZ,kBAAkB,EAClB,aAAa,EACb,sBA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AE,MAAM,uBAAuB,CAAA;AAG9E,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,KAAK,WAAW,GACjB,MAAM,cAAc,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -15,6 +15,10 @@
|
|
|
15
15
|
export { createGasOracle, reducePollInputs, sampleGasFees, } from './oracle.js';
|
|
16
16
|
export { effectiveTip, computePercentiles, detectTrend, cappedTip, computeTiers, computeBlobBaseFee, flattenTxPool, gasWeightedPercentiles, sortedTips, DEFAULT_PRIORITY_FEE_DECAY_CAP, DEFAULT_BASE_FEE_LIVENESS_BLOCKS, } from './math.js';
|
|
17
17
|
export { blockToSample, mempoolToSamples, } from './samples.js';
|
|
18
|
+
// Pure ring-buffer maintenance (used by the reducer; exposed for
|
|
19
|
+
// replay harnesses + tests that want to verify ring transitions
|
|
20
|
+
// independent of the rest of the reducer).
|
|
21
|
+
export { incorporateBlock } from './ring.js';
|
|
18
22
|
export { fetchOracleInputs, fetchHeadBlockNumber, } from './transport.js';
|
|
19
23
|
// Const-namespace pairs (value + type share the identifier — see types.ts).
|
|
20
24
|
export { PriorityModel, TierName, TIER_LADDER, Trend, TxType } from './types.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,aAAa,GAGd,MAAM,aAAa,CAAA;AAEpB,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,WAAW,EACX,SAAS,EACT,YAAY,EACZ,kBAAkB,EAClB,aAAa,EACb,sBAAsB,EACtB,UAAU,EACV,8BAA8B,EAC9B,gCAAgC,GACjC,MAAM,WAAW,CAAA;AAElB,OAAO,EACL,aAAa,EACb,gBAAgB,GACjB,MAAM,cAAc,CAAA;AAErB,OAAO,EACL,iBAAiB,EACjB,oBAAoB,
|
|
1
|
+
{"version":3,"file":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|
|
7
7
|
* (legacy txs, EIP-1559 with zero headroom, cold-start cap, post-EIP-4844
|
|
8
8
|
* blob fee) is handled here rather than at higher layers.
|
|
9
9
|
*/
|
|
10
|
-
import {
|
|
10
|
+
import type { RawTx } from '@valve-tech/chain-source';
|
|
11
|
+
import { PriorityModel, TierName, Trend, type TierRecommendation, type TipPercentiles, type TipSample } from './types.js';
|
|
11
12
|
/** Default priority-fee decay cap = 12.5% / block (EIP-1559 parity). */
|
|
12
13
|
export declare const DEFAULT_PRIORITY_FEE_DECAY_CAP: bigint;
|
|
13
14
|
/**
|
package/dist/math.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"math.d.ts","sourceRoot":"","sources":["../src/math.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EACL,aAAa,EACb,QAAQ,EACR,KAAK,EAEL,KAAK,
|
|
1
|
+
{"version":3,"file":"math.d.ts","sourceRoot":"","sources":["../src/math.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAA;AAErD,OAAO,EACL,aAAa,EACb,QAAQ,EACR,KAAK,EAEL,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,SAAS,EACf,MAAM,YAAY,CAAA;AAcnB,wEAAwE;AACxE,eAAO,MAAM,8BAA8B,QAAW,CAAA;AAEtD;;;;;;;;;GASG;AACH,eAAO,MAAM,YAAY,GAAI,IAAI,KAAK,EAAE,SAAS,MAAM,KAAG,MAezD,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAAI,QAAQ,MAAM,EAAE,KAAG,cASrD,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,UAAU,GAAI,KAAK,KAAK,EAAE,EAAE,SAAS,MAAM,KAAG,MAAM,EAK5B,CAAA;AAErC;;;;GAIG;AACH,eAAO,MAAM,WAAW,GAAI,SAAS,MAAM,EAAE,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AAI,eAAe,MAAM,KAAG,MAY1D,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GACxB,MAAM,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,GAAG,SAAS,GAAG,IAAI,KAC7D,KAAK,EAOP,CAAA"}
|
package/dist/math.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"math.js","sourceRoot":"","sources":["../src/math.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;
|
|
1
|
+
{"version":3,"file":"math.js","sourceRoot":"","sources":["../src/math.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,EACL,aAAa,EACb,QAAQ,EACR,KAAK,EACL,MAAM,GAIP,MAAM,YAAY,CAAA;AAEnB,MAAM,0BAA0B,GAAG,GAAG,CAAA;AACtC,MAAM,2BAA2B,GAAG,CAAC,GAAG,CAAA;AAExC;;;;;;GAMG;AACH,MAAM,GAAG,GAAG,oBAA0B,CAAA;AAEtC,wEAAwE;AACxE,MAAM,CAAC,MAAM,8BAA8B,GAAG,GAAG,GAAG,EAAE,CAAA;AAEtD;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,EAAS,EAAE,OAAe,EAAU,EAAE;IACjE,IAAI,EAAE,CAAC,YAAY,IAAI,EAAE,CAAC,oBAAoB,EAAE,CAAC;QAC/C,MAAM,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC,YAAY,CAAC,CAAA;QACtC,MAAM,WAAW,GAAG,MAAM,CAAC,EAAE,CAAC,oBAAoB,CAAC,CAAA;QACnD,MAAM,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAA;QACjC,IAAI,QAAQ,IAAI,EAAE;YAAE,OAAO,EAAE,CAAA;QAC7B,OAAO,WAAW,GAAG,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAA;IACxD,CAAC;IAED,I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AI,CAAC,IAAI;QAAE,OAAO,EAAE,CAAA;IACpB,MAAM,GAAG,GAAY,EAAE,CAAA;IACvB,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1C,KAAK,MAAM,EAAE,IAAI,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC;YAAE,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IACvD,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA"}
|
package/dist/mempool.d.ts
CHANGED
|
@@ -19,15 +19,7 @@
|
|
|
19
19
|
* functionally identical to `TxPoolContent`, but the type alias names
|
|
20
20
|
* the invariant.
|
|
21
21
|
*/
|
|
22
|
-
import type { TxPoolContent } from '
|
|
23
|
-
import type { RawTx } from './types.js';
|
|
24
|
-
/**
|
|
25
|
-
* `TxPoolContent` after a single normalization pass — every sender
|
|
26
|
-
* address key is lowercase ASCII, every nonce key is a decimal string.
|
|
27
|
-
* All lookup helpers expect this form; pass raw `TxPoolContent` through
|
|
28
|
-
* `normalizeMempool` first.
|
|
29
|
-
*/
|
|
30
|
-
export type NormalizedMempool = TxPoolContent;
|
|
22
|
+
import type { NormalizedMempool, RawTx, TxPoolContent } from '@valve-tech/chain-source';
|
|
31
23
|
/**
|
|
32
24
|
* Discriminated identifier for a single tx — either by its hash, or by
|
|
33
25
|
* sender + nonce. Re-used across mempool lookups (`findInMempool`) and
|
package/dist/mempool.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mempool.d.ts","sourceRoot":"","sources":["../src/mempool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"mempool.d.ts","sourceRoot":"","sources":["../src/mempool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EACV,iBAAiB,EACjB,K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AAA;IAE7C,MAAM,KAAK,GAAG,CACZ,OAA0D,EAC1D,MAAqB,EACF,EAAE;QACrB,MAAM,EAAE,GAAG,OAAO,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC,YAAY,CAAC,CAAA;QAC/C,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,IAAI,CAAA;IAC5E,CAAC,CAAA;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;AACvE,CAAC,CAAA;AAED;;;;;GAKG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,IAA0C,EAC1C,EAAgB,EACG,EAAE;IACrB,IAAI,MAAM,IAAI,EAAE;QAAE,OAAO,UAAU,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,CAAA;IAClD,OAAO,kBAAkB,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,KAAK,CAAC,CAAA;AACvD,CAAC,CAAA"}
|
package/dist/oracle.d.ts
CHANGED
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
* process, instantiate many oracles. They don't share any state.
|
|
12
12
|
*/
|
|
13
13
|
import type { PublicClient } from 'viem';
|
|
14
|
-
import { type ChainSource, type NormalizedMempool } from '@valve-tech/chain-source';
|
|
14
|
+
import { type BlockResult, type ChainSource, type NormalizedMempool, type PollOptions } from '@valve-tech/chain-source';
|
|
15
15
|
import { type OraclePollInputs } from './transport.js';
|
|
16
|
-
import type { GasOracleState,
|
|
16
|
+
import type { GasOracleState, PriorityModel } from './types.js';
|
|
17
17
|
export interface CreateGasOracleOptions {
|
|
18
18
|
/**
|
|
19
19
|
* Pre-built `ChainSource`. Preferred for new code: lets multiple
|
|
@@ -152,6 +152,19 @@ export interface CreateGasOracleOptions {
|
|
|
152
152
|
* Web Worker contexts where `document` is undefined.
|
|
153
153
|
*/
|
|
154
154
|
pauseWhenHidden?: boolean;
|
|
155
|
+
/**
|
|
156
|
+
* How many recent blocks to retain in `state.ring` for percentile
|
|
157
|
+
* sampling and reorg detection. Default 20n (matches the
|
|
158
|
+
* `eth_feeHistory` window). Pass 0n to disable the cap (the ring
|
|
159
|
+
* grows without bound; only useful for replay harnesses).
|
|
160
|
+
*
|
|
161
|
+
* The ring fills naturally as the poll loop receives blocks, with
|
|
162
|
+
* pre-fetched gap bridging via `source.getBlock` when consecutive
|
|
163
|
+
* polls miss intermediate blocks. Larger windows give more samples
|
|
164
|
+
* (more stable tier numbers) at the cost of more memory and more
|
|
165
|
+
* I/O on resume after a long pause.
|
|
166
|
+
*/
|
|
167
|
+
ringWindowBlocks?: bigint;
|
|
155
168
|
}
|
|
156
169
|
export interface GasOracle {
|
|
157
170
|
/** Begin the poll loop. Idempotent — calling twice is a no-op. */
|
|
@@ -191,14 +204,38 @@ export interface GasOracle {
|
|
|
191
204
|
*
|
|
192
205
|
* Pure: no I/O, no global state, no time. Test by feeding it fixture
|
|
193
206
|
* inputs and asserting the returned shape.
|
|
207
|
+
*
|
|
208
|
+
* Ring lifecycle. The reducer maintains `state.ring` across calls
|
|
209
|
+
* using `incorporateBlock` (see `ring.ts`): clean appends, duplicate
|
|
210
|
+
* detection, reorg trim, restart on irrecoverable gaps. The poll loop
|
|
211
|
+
* in `createGasOracle` pre-fetches missing blocks for clean gaps and
|
|
212
|
+
* passes them as `historicalBlocks` so the ring stays dense across
|
|
213
|
+
* brief interruptions; callers using `reducePollInputs` directly
|
|
214
|
+
* (replay harnesses, snapshot tests) can pass the same param.
|
|
194
215
|
*/
|
|
195
216
|
export declare const reducePollInputs: (input: {
|
|
196
217
|
inputs: OraclePollInputs;
|
|
197
218
|
chainId: number;
|
|
198
219
|
prev: GasOracleState | null;
|
|
220
|
+
/**
|
|
221
|
+
* Older blocks to slot into the ring before the current input block.
|
|
222
|
+
* Ordered oldest → newest. Used by the I/O-driven gap bridge in
|
|
223
|
+
* `oracle.ts`'s poll loop and by replay harnesses; standalone callers
|
|
224
|
+
* can omit it. Each historical block contributes its `tips` to the
|
|
225
|
+
* percentile sample base; `feeHistory` and `txPool` from `inputs`
|
|
226
|
+
* still apply to the current block only.
|
|
227
|
+
*/
|
|
228
|
+
historicalBlocks?: BlockResult[];
|
|
199
229
|
priorityFeeDecayCap?: bigint | null;
|
|
200
230
|
priorityModel?: PriorityModel;
|
|
201
231
|
baseFeeLivenessBlocks?: number;
|
|
232
|
+
/**
|
|
233
|
+
* Maximum ring size. Defaults to 20 blocks (matching the
|
|
234
|
+
* `eth_feeHistory` window). Pass 0n to disable the cap. Older
|
|
235
|
+
* entries are dropped from the head as new appends would exceed
|
|
236
|
+
* the window.
|
|
237
|
+
*/
|
|
238
|
+
ringWindowBlocks?: bigint;
|
|
202
239
|
}) => GasOracleState | null;
|
|
203
240
|
/**
|
|
204
241
|
* Build a configured oracle. Nothing happens until you call `start()`.
|
package/dist/oracle.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oracle.d.ts","sourceRoot":"","sources":["../src/oracle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AACxC,OAAO,
|
|
1
|
+
{"version":3,"file":"oracle.d.ts","sourceRoot":"","sources":["../src/oracle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AACxC,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,KAAK,WAAW,EACjB,MAAM,0BAA0B,CAAA;AAEjC,OAAO,EAAqB,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AASzE,OAAO,KAAK,EAGV,cAAc,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,KAAK,IAAI,CAAA;CACjD,KAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAahC,CAAA;AAID,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AACtD,YAAY,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA"}
|
package/dist/oracle.js
CHANGED
|
@@ -13,16 +13,26 @@
|
|
|
13
13
|
import { createChainSource, } from '@valve-tech/chain-source';
|
|
14
14
|
import { fetchOracleInputs } from './transport.js';
|
|
15
15
|
import { computeBlobBaseFee, computeTiers, detectTrend, flattenTxPool, } from './math.js';
|
|
16
|
+
import { incorporateBlock } from './ring.js';
|
|
16
17
|
import { blockToSample, mempoolToSamples } from './samples.js';
|
|
17
18
|
const DEFAULT_POLL_INTERVAL_MS = 10000n;
|
|
18
19
|
const TREND_WINDOW = 5;
|
|
19
20
|
const WAD = 1000000000000000000n;
|
|
21
|
+
const DEFAULT_RING_WINDOW_BLOCKS = 20n;
|
|
20
22
|
/**
|
|
21
23
|
* Reduce a poll cycle's RPC outputs into a new oracle state, using the
|
|
22
24
|
* previous state to anchor the cap-decay and the base-fee history.
|
|
23
25
|
*
|
|
24
26
|
* Pure: no I/O, no global state, no time. Test by feeding it fixture
|
|
25
27
|
* inputs and asserting the returned shape.
|
|
28
|
+
*
|
|
29
|
+
* Ring lifecycle. The reducer maintains `state.ring` across calls
|
|
30
|
+
* using `incorporateBlock` (see `ring.ts`): clean appends, duplicate
|
|
31
|
+
* detection, reorg trim, restart on irrecoverable gaps. The poll loop
|
|
32
|
+
* in `createGasOracle` pre-fetches missing blocks for clean gaps and
|
|
33
|
+
* passes them as `historicalBlocks` so the ring stays dense across
|
|
34
|
+
* brief interruptions; callers using `reducePollInputs` directly
|
|
35
|
+
* (replay harnesses, snapshot tests) can pass the same param.
|
|
26
36
|
*/
|
|
27
37
|
export const reducePollInputs = (input) => {
|
|
28
38
|
const { block, feeHistory, txPool } = input.inputs;
|
|
@@ -38,14 +48,24 @@ export const reducePollInputs = (input) => {
|
|
|
38
48
|
? feeHistory.baseFeePerGas.map((hex) => BigInt(hex))
|
|
39
49
|
: [baseFee];
|
|
40
50
|
const baseFeeTrend = detectTrend(baseFeeHistory.slice(-TREND_WINDOW));
|
|
41
|
-
// Build the rolling ring.
|
|
42
|
-
//
|
|
43
|
-
//
|
|
44
|
-
|
|
45
|
-
|
|
51
|
+
// Build the rolling ring. Pure helper handles append / duplicate /
|
|
52
|
+
// reorg-trim / restart; the I/O-driven gap bridge happens in
|
|
53
|
+
// `handleBlock` and arrives here pre-fetched via `historicalBlocks`.
|
|
54
|
+
const ringWindow = input.ringWindowBlocks ?? DEFAULT_RING_WINDOW_BLOCKS;
|
|
55
|
+
let workingRing = input.prev?.ring ?? [];
|
|
56
|
+
let lastReorg = input.prev?.lastReorg ?? null;
|
|
57
|
+
for (const histBlock of input.historicalBlocks ?? []) {
|
|
58
|
+
const histMutation = incorporateBlock(workingRing, blockToSample(histBlock), ringWindow);
|
|
59
|
+
workingRing = histMutation.ring;
|
|
60
|
+
if (histMutation.reorg)
|
|
61
|
+
lastReorg = histMutation.reorg;
|
|
62
|
+
}
|
|
46
63
|
const blockSample = blockToSample(block);
|
|
47
|
-
const
|
|
48
|
-
const
|
|
64
|
+
const mutation = incorporateBlock(workingRing, blockSample, ringWindow);
|
|
65
|
+
const ring = mutation.ring;
|
|
66
|
+
if (mutation.reorg)
|
|
67
|
+
lastReorg = mutation.reorg;
|
|
68
|
+
const ringSamples = ring.flatMap((b) => b.tips);
|
|
49
69
|
// Mempool — best-effort signal.
|
|
50
70
|
let mempool = {
|
|
51
71
|
pendingCount: 0n,
|
|
@@ -106,6 +126,7 @@ export const reducePollInputs = (input) => {
|
|
|
106
126
|
blob,
|
|
107
127
|
tiers,
|
|
108
128
|
ring,
|
|
129
|
+
lastReorg,
|
|
109
130
|
mempoolSamples,
|
|
110
131
|
lastPublishedTips: publishedTips,
|
|
111
132
|
lastPublishedBlockNumber: blockNumber,
|
|
@@ -208,37 +229,84 @@ export const createGasOracle = (options) => {
|
|
|
208
229
|
catch { /* swallow per-subscriber errors */ }
|
|
209
230
|
}
|
|
210
231
|
};
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
232
|
+
const ringWindowBlocks = options.ringWindowBlocks ?? DEFAULT_RING_WINDOW_BLOCKS;
|
|
233
|
+
/**
|
|
234
|
+
* Reduce a (block, feeHistory, mempool) tuple into the next state +
|
|
235
|
+
* notify. Shared between the subscribe-driven path (timer ticks)
|
|
236
|
+
* and the on-demand path (`pollOnce`). `historicalBlocks` carries
|
|
237
|
+
* any gap-bridge blocks fetched by `handleBlock` so the ring fills
|
|
238
|
+
* in chronological order in a single reducer call (one notification).
|
|
239
|
+
*
|
|
240
|
+
* The `block` field on `inputs` is **required non-null** here —
|
|
241
|
+
* both callers (`handleBlock` and `pollOnce`) already gate on a
|
|
242
|
+
* non-null block, so the pure reducer's null-block-early-return
|
|
243
|
+
* arm cannot fire from this path. Typing the parameter
|
|
244
|
+
* accordingly removes the dead `if (next)` guard and the
|
|
245
|
+
* `c8 ignore` directive that was needed to silence coverage.
|
|
246
|
+
*/
|
|
247
|
+
const reduceAndPublish = (inputs, historicalBlocks) => {
|
|
215
248
|
const next = reducePollInputs({
|
|
216
249
|
inputs,
|
|
250
|
+
historicalBlocks,
|
|
217
251
|
chainId: options.chainId,
|
|
218
252
|
prev: state,
|
|
219
253
|
priorityFeeDecayCap: options.priorityFeeDecayCap,
|
|
220
254
|
priorityModel: options.priorityModel,
|
|
221
255
|
baseFeeLivenessBlocks: options.baseFeeLivenessBlocks,
|
|
256
|
+
ringWindowBlocks,
|
|
222
257
|
});
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
// gates on a non-null block. Guard kept defensively in case a
|
|
226
|
-
// future caller wires it differently.
|
|
227
|
-
/* c8 ignore next */
|
|
228
|
-
if (next) {
|
|
229
|
-
state = next;
|
|
230
|
-
notify(next);
|
|
231
|
-
}
|
|
258
|
+
state = next;
|
|
259
|
+
notify(next);
|
|
232
260
|
return next;
|
|
233
261
|
};
|
|
262
|
+
/**
|
|
263
|
+
* Pre-fetch missing blocks between `prev.ring`'s tip and `newBlock`
|
|
264
|
+
* so the reducer's ring stays dense across brief upstream pauses.
|
|
265
|
+
*
|
|
266
|
+
* Bounded by `ringWindowBlocks` — gaps larger than the window
|
|
267
|
+
* trigger a ring restart anyway, so spending RPC calls to bridge
|
|
268
|
+
* them is wasted. Each missing block is fetched by number via
|
|
269
|
+
* `source.getBlock`. Failures are silently dropped: a partial bridge
|
|
270
|
+
* still leaves the new block as the new tip, and the reducer's pure
|
|
271
|
+
* helper handles incomplete ancestry by restarting if necessary.
|
|
272
|
+
*
|
|
273
|
+
* Reorgs (parentHash mismatch with `prev.tip.hash`) are NOT
|
|
274
|
+
* backfilled here — that would require fetching by hash, which
|
|
275
|
+
* `chain-source` doesn't expose. The reducer's trim handles them
|
|
276
|
+
* correctly; the new canonical branch refills via natural forward
|
|
277
|
+
* polling.
|
|
278
|
+
*/
|
|
279
|
+
const bridgeGap = async (newBlock) => {
|
|
280
|
+
if (state === null || state.ring.length === 0)
|
|
281
|
+
return [];
|
|
282
|
+
const tip = state.ring[state.ring.length - 1];
|
|
283
|
+
const newNumber = BigInt(newBlock.number);
|
|
284
|
+
const gap = newNumber - tip.number;
|
|
285
|
+
if (gap <= 1n)
|
|
286
|
+
return [];
|
|
287
|
+
if (ringWindowBlocks > 0n && gap > ringWindowBlocks)
|
|
288
|
+
return [];
|
|
289
|
+
const missing = [];
|
|
290
|
+
for (let n = tip.number + 1n; n < newNumber; n += 1n) {
|
|
291
|
+
const fetched = await source.getBlock(n);
|
|
292
|
+
if (!fetched)
|
|
293
|
+
break;
|
|
294
|
+
missing.push(fetched);
|
|
295
|
+
}
|
|
296
|
+
return missing;
|
|
297
|
+
};
|
|
234
298
|
// Block-event handler. Fires once per de-duped block emit from the
|
|
235
299
|
// source. Fetches feeHistory on demand (so a static head doesn't
|
|
236
|
-
// re-fetch it),
|
|
300
|
+
// re-fetch it), bridges any clean gap from the prev tip, then
|
|
301
|
+
// reduces with the most recent mempool snapshot.
|
|
237
302
|
const handleBlock = async (block) => {
|
|
238
|
-
const feeHistory =
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
303
|
+
const [feeHistory, historicalBlocks] = await Promise.all([
|
|
304
|
+
fetchFeeHistoryEnabled
|
|
305
|
+
? source.getFeeHistory(20, [10, 25, 50, 75, 90])
|
|
306
|
+
: Promise.resolve(null),
|
|
307
|
+
bridgeGap(block),
|
|
308
|
+
]);
|
|
309
|
+
reduceAndPublish({ block, feeHistory, txPool: latestMempool }, historicalBlocks);
|
|
242
310
|
};
|
|
243
311
|
// Mempool-event handler. Caches the latest snapshot for the next
|
|
244
312
|
// block reduce + powers `getMempoolSnapshot()` when retention is on.
|
|
@@ -368,19 +436,20 @@ export const createGasOracle = (options) => {
|
|
|
368
436
|
const block = await source.getBlock('latest');
|
|
369
437
|
if (!block)
|
|
370
438
|
return null;
|
|
371
|
-
const [feeHistory, freshMempool] = await Promise.all([
|
|
439
|
+
const [feeHistory, freshMempool, historicalBlocks] = await Promise.all([
|
|
372
440
|
fetchFeeHistoryEnabled
|
|
373
441
|
? source.getFeeHistory(20, [10, 25, 50, 75, 90])
|
|
374
442
|
: Promise.resolve(null),
|
|
375
443
|
fetchMempoolEnabled
|
|
376
444
|
? source.getMempoolSnapshot()
|
|
377
445
|
: Promise.resolve(null),
|
|
446
|
+
bridgeGap(block),
|
|
378
447
|
]);
|
|
379
448
|
latestMempool = freshMempool;
|
|
380
449
|
if (retainMempool) {
|
|
381
450
|
mempoolSnapshot = freshMempool;
|
|
382
451
|
}
|
|
383
|
-
return reduceAndPublish({ block, feeHistory, txPool: freshMempool });
|
|
452
|
+
return reduceAndPublish({ block, feeHistory, txPool: freshMempool }, historicalBlocks);
|
|
384
453
|
},
|
|
385
454
|
subscribe: (cb) => {
|
|
386
455
|
subscribers.add(cb);
|
package/dist/oracle.js.map
CHANGED
|
@@ -1 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AI,OAAO,IAAI,aAAa,IAAI,WAAW,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;gBACvD,IAAI,CAAC,eAAe,IAAI,CAAC,QAAQ,EAAE,EAAE,CAAC;oBACpC,cAAc,EAAE,CAAA;gBAClB,CAAC;YACH,CAAC;YACD,OAAO,GAAG,EAAE;gBACV,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;gBACtB,wDAAwD;gBACxD,wBAAwB;gBACxB,IAAI,OAAO,IAAI,aAAa,IAAI,WAAW,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;oBACvD,kBAAkB,EAAE,CAAA;gBACtB,CAAC;YACH,CAAC,CAAA;QACH,CAAC;KACF,CAAA;AACH,CAAC,CAAA;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,EAAE,OAenC,EAAkC,EAAE;IACnC,MAAM,MAAM,GAAG,MAAM,iBAAiB,CAAC,OAAO,CAAC,MAAM,EAAE;QACrD,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,IAAI,EAAE,OAAO,CAAC,IAAI;KACnB,CAAC,CAAA;IACF,OAAO,gBAAgB,CAAC;QACtB,MAAM;QACN,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,IAAI,EAAE,IAAI;QACV,mBAAmB,EAAE,OAAO,CAAC,mBAAmB;QAChD,aAAa,EAAE,OAAO,CAAC,aAAa;QACpC,qBAAqB,EAAE,OAAO,CAAC,qBAAqB;KACrD,CAAC,CAAA;AACJ,CAAC,CAAA"}
|
package/dist/ring.d.ts
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure ring-buffer maintenance for the gas oracle's block-history window.
|
|
3
|
+
*
|
|
4
|
+
* The ring holds the most recent N `BlockSample`s (oldest → newest).
|
|
5
|
+
* Tier computation samples `state.ring[*].tips` so the percentile
|
|
6
|
+
* distribution reflects multi-block inclusion rather than a single
|
|
7
|
+
* block's accident. The ring also gives tx-tracker its reorg-walk
|
|
8
|
+
* substrate (see `docs/tx-tracker-spec.md` §12.1) when the consumer
|
|
9
|
+
* shares one source between both packages.
|
|
10
|
+
*
|
|
11
|
+
* **Stateful surface, pure module.** The reducer (`oracle.ts`'s
|
|
12
|
+
* `reducePollInputs`) is the only caller that builds the ring across
|
|
13
|
+
* cycles; this module just classifies one transition at a time and
|
|
14
|
+
* returns a new ring shape. No I/O, no closures over time, no mutation
|
|
15
|
+
* of the input ring.
|
|
16
|
+
*
|
|
17
|
+
* **Lifecycle the ring covers:**
|
|
18
|
+
*
|
|
19
|
+
* - **append** — new block continues the chain
|
|
20
|
+
* (`newBlock.parentHash === ring.tip.hash`). Push to tail; trim
|
|
21
|
+
* head if length would exceed `maxWindow`.
|
|
22
|
+
* - **duplicate** — new block already present at the same height with
|
|
23
|
+
* the same hash. No-op; ring returned unchanged.
|
|
24
|
+
* - **reorg** — new block conflicts with a block already in the ring,
|
|
25
|
+
* either by replacing an existing height (same number, different
|
|
26
|
+
* hash) or by extending from a height deeper than the current tip
|
|
27
|
+
* (parentHash matches a non-tip hash). Trim everything from the
|
|
28
|
+
* divergence point forward, append the new block, and emit a
|
|
29
|
+
* `ReorgEvent` describing the dropped tail.
|
|
30
|
+
* - **restart** — no relationship with the prev ring (gap larger
|
|
31
|
+
* than what backfill caught, or completely unrelated chain). Drop
|
|
32
|
+
* the prev ring and return `[newBlock]`.
|
|
33
|
+
*
|
|
34
|
+
* The I/O-driven `bridgeGap` and `clearAndBackfill` behaviors live in
|
|
35
|
+
* `oracle.ts`'s `handleBlock` — they pre-fetch missing blocks via the
|
|
36
|
+
* `ChainSource` and feed them into this module as `historicalBlocks`
|
|
37
|
+
* before the current block. This module never fetches anything.
|
|
38
|
+
*/
|
|
39
|
+
import type { BlockSample } from './types.js';
|
|
40
|
+
/**
|
|
41
|
+
* Description of a tail-trim caused by reorg detection. Consumers
|
|
42
|
+
* surface this on `GasOracleState.lastReorg` so observers know when
|
|
43
|
+
* the oracle dropped historical samples (and at what depth) without
|
|
44
|
+
* subscribing to a separate reorg channel.
|
|
45
|
+
*/
|
|
46
|
+
export interface ReorgEvent {
|
|
47
|
+
/** Block number at which divergence was detected (= `newBlock.number`). */
|
|
48
|
+
blockNumber: bigint;
|
|
49
|
+
/** Number of tail blocks trimmed from the previous ring. */
|
|
50
|
+
depth: bigint;
|
|
51
|
+
/** Hash of the new canonical tip after the trim + append. */
|
|
52
|
+
newTipHash: string;
|
|
53
|
+
/**
|
|
54
|
+
* Hashes of the dropped tail blocks, ordered oldest → newest. Empty
|
|
55
|
+
* tuple is impossible — `depth >= 1` for every reorg event.
|
|
56
|
+
*/
|
|
57
|
+
droppedHashes: readonly string[];
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Result of classifying + applying one ring transition. Pure data.
|
|
61
|
+
*
|
|
62
|
+
* - `ring` — the new ring (always non-empty).
|
|
63
|
+
* - `reorg` — populated iff a tail-trim happened. `null` for clean
|
|
64
|
+
* appends, restarts, and duplicates.
|
|
65
|
+
* - `duplicate` — `true` when the new block was already in the ring at
|
|
66
|
+
* its height with the same hash. The reducer may short-circuit
|
|
67
|
+
* subscriber notification on this signal.
|
|
68
|
+
*/
|
|
69
|
+
export interface RingMutation {
|
|
70
|
+
ring: BlockSample[];
|
|
71
|
+
reorg: ReorgEvent | null;
|
|
72
|
+
duplicate: boolean;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Decide what `prevRing` becomes after observing `newBlock`. Pure: the
|
|
76
|
+
* input ring is never mutated.
|
|
77
|
+
*
|
|
78
|
+
* `maxWindow` caps the ring length — the head (oldest entry) is dropped
|
|
79
|
+
* to make room when an append would exceed it. Callers pass the
|
|
80
|
+
* configured `ringWindowBlocks` (default 20n).
|
|
81
|
+
*
|
|
82
|
+
* Implementation walks the prev ring once from newest → oldest, looking
|
|
83
|
+
* for the first block whose number ≤ `newBlock.number`:
|
|
84
|
+
*
|
|
85
|
+
* 1. If no such block exists (prev ring is empty, or every entry is
|
|
86
|
+
* newer than `newBlock`): restart with `[newBlock]`.
|
|
87
|
+
* 2. If the matched block has the same number and same hash as
|
|
88
|
+
* `newBlock`: duplicate. Return `prevRing` unchanged.
|
|
89
|
+
* 3. If the matched block has the same number but a different hash:
|
|
90
|
+
* reorg at this height. Trim from the matched index forward,
|
|
91
|
+
* append `newBlock`.
|
|
92
|
+
* 4. If the matched block has a smaller number AND its hash matches
|
|
93
|
+
* `newBlock.parentHash`: append after this block (trimming any
|
|
94
|
+
* blocks tail-ward of the matched block — those are now-stale
|
|
95
|
+
* branches if the matched block isn't the tip).
|
|
96
|
+
* 5. Otherwise: gap (parent isn't anywhere in the ring) → restart
|
|
97
|
+
* with `[newBlock]`. The I/O-driven backfill in `oracle.ts` is
|
|
98
|
+
* expected to have filled small gaps before reaching here, so
|
|
99
|
+
* arriving in case 5 means the gap exceeded the window or the
|
|
100
|
+
* backfill was disabled.
|
|
101
|
+
*/
|
|
102
|
+
export declare const incorporateBlock: (prevRing: readonly BlockSample[], newBlock: BlockSample, maxWindow: bigint) => RingMutation;
|
|
103
|
+
//# sourceMappingURL=ring.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ring.d.ts","sourceRoot":"","sources":["../src/ring.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAE7C;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IACzB,2EAA2E;IAC3E,WAAW,EAAE,MAAM,CAAA;IACnB,4DAA4D;IAC5D,KAAK,EAAE,MAAM,CAAA;IACb,6DAA6D;IAC7D,UAAU,EAAE,MAAM,CAAA;IAClB;;;OAGG;IACH,aAAa,EAAE,SAAS,MAAM,EAAE,CAAA;CACjC;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,WAAW,EAAE,CAAA;IACnB,KAAK,EAAE,UAAU,GAAG,IAAI,CAAA;IACxB,SAAS,EAAE,OAAO,CAAA;CACnB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,gBAAgB,GAC3B,UAAU,SAAS,WAAW,EAAE,EAChC,UAAU,WAAW,EACrB,WAAW,MAAM,KAChB,YAkFF,CAAA"}
|
package/dist/ring.js
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure ring-buffer maintenance for the gas oracle's block-history window.
|
|
3
|
+
*
|
|
4
|
+
* The ring holds the most recent N `BlockSample`s (oldest → newest).
|
|
5
|
+
* Tier computation samples `state.ring[*].tips` so the percentile
|
|
6
|
+
* distribution reflects multi-block inclusion rather than a single
|
|
7
|
+
* block's accident. The ring also gives tx-tracker its reorg-walk
|
|
8
|
+
* substrate (see `docs/tx-tracker-spec.md` §12.1) when the consumer
|
|
9
|
+
* shares one source between both packages.
|
|
10
|
+
*
|
|
11
|
+
* **Stateful surface, pure module.** The reducer (`oracle.ts`'s
|
|
12
|
+
* `reducePollInputs`) is the only caller that builds the ring across
|
|
13
|
+
* cycles; this module just classifies one transition at a time and
|
|
14
|
+
* returns a new ring shape. No I/O, no closures over time, no mutation
|
|
15
|
+
* of the input ring.
|
|
16
|
+
*
|
|
17
|
+
* **Lifecycle the ring covers:**
|
|
18
|
+
*
|
|
19
|
+
* - **append** — new block continues the chain
|
|
20
|
+
* (`newBlock.parentHash === ring.tip.hash`). Push to tail; trim
|
|
21
|
+
* head if length would exceed `maxWindow`.
|
|
22
|
+
* - **duplicate** — new block already present at the same height with
|
|
23
|
+
* the same hash. No-op; ring returned unchanged.
|
|
24
|
+
* - **reorg** — new block conflicts with a block already in the ring,
|
|
25
|
+
* either by replacing an existing height (same number, different
|
|
26
|
+
* hash) or by extending from a height deeper than the current tip
|
|
27
|
+
* (parentHash matches a non-tip hash). Trim everything from the
|
|
28
|
+
* divergence point forward, append the new block, and emit a
|
|
29
|
+
* `ReorgEvent` describing the dropped tail.
|
|
30
|
+
* - **restart** — no relationship with the prev ring (gap larger
|
|
31
|
+
* than what backfill caught, or completely unrelated chain). Drop
|
|
32
|
+
* the prev ring and return `[newBlock]`.
|
|
33
|
+
*
|
|
34
|
+
* The I/O-driven `bridgeGap` and `clearAndBackfill` behaviors live in
|
|
35
|
+
* `oracle.ts`'s `handleBlock` — they pre-fetch missing blocks via the
|
|
36
|
+
* `ChainSource` and feed them into this module as `historicalBlocks`
|
|
37
|
+
* before the current block. This module never fetches anything.
|
|
38
|
+
*/
|
|
39
|
+
/**
|
|
40
|
+
* Decide what `prevRing` becomes after observing `newBlock`. Pure: the
|
|
41
|
+
* input ring is never mutated.
|
|
42
|
+
*
|
|
43
|
+
* `maxWindow` caps the ring length — the head (oldest entry) is dropped
|
|
44
|
+
* to make room when an append would exceed it. Callers pass the
|
|
45
|
+
* configured `ringWindowBlocks` (default 20n).
|
|
46
|
+
*
|
|
47
|
+
* Implementation walks the prev ring once from newest → oldest, looking
|
|
48
|
+
* for the first block whose number ≤ `newBlock.number`:
|
|
49
|
+
*
|
|
50
|
+
* 1. If no such block exists (prev ring is empty, or every entry is
|
|
51
|
+
* newer than `newBlock`): restart with `[newBlock]`.
|
|
52
|
+
* 2. If the matched block has the same number and same hash as
|
|
53
|
+
* `newBlock`: duplicate. Return `prevRing` unchanged.
|
|
54
|
+
* 3. If the matched block has the same number but a different hash:
|
|
55
|
+
* reorg at this height. Trim from the matched index forward,
|
|
56
|
+
* append `newBlock`.
|
|
57
|
+
* 4. If the matched block has a smaller number AND its hash matches
|
|
58
|
+
* `newBlock.parentHash`: append after this block (trimming any
|
|
59
|
+
* blocks tail-ward of the matched block — those are now-stale
|
|
60
|
+
* branches if the matched block isn't the tip).
|
|
61
|
+
* 5. Otherwise: gap (parent isn't anywhere in the ring) → restart
|
|
62
|
+
* with `[newBlock]`. The I/O-driven backfill in `oracle.ts` is
|
|
63
|
+
* expected to have filled small gaps before reaching here, so
|
|
64
|
+
* arriving in case 5 means the gap exceeded the window or the
|
|
65
|
+
* backfill was disabled.
|
|
66
|
+
*/
|
|
67
|
+
export const incorporateBlock = (prevRing, newBlock, maxWindow) => {
|
|
68
|
+
if (prevRing.length === 0) {
|
|
69
|
+
return { ring: [newBlock], reorg: null, duplicate: false };
|
|
70
|
+
}
|
|
71
|
+
// Scan from newest → oldest for first entry with number ≤ newBlock.number.
|
|
72
|
+
let matchIndex = -1;
|
|
73
|
+
for (let i = prevRing.length - 1; i >= 0; i -= 1) {
|
|
74
|
+
if (prevRing[i].number <= newBlock.number) {
|
|
75
|
+
matchIndex = i;
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if (matchIndex === -1) {
|
|
80
|
+
// Every entry is newer than newBlock — newBlock is older than the
|
|
81
|
+
// entire window. Treat as restart so we don't propagate a strictly
|
|
82
|
+
// older reading; this case shouldn't happen in normal operation
|
|
83
|
+
// (the source emits monotonically) but the reducer asks for a
|
|
84
|
+
// defensible answer either way.
|
|
85
|
+
return { ring: [newBlock], reorg: null, duplicate: false };
|
|
86
|
+
}
|
|
87
|
+
const matched = prevRing[matchIndex];
|
|
88
|
+
if (matched.number === newBlock.number) {
|
|
89
|
+
if (matched.hash === newBlock.hash) {
|
|
90
|
+
return { ring: prevRing.slice(), reorg: null, duplicate: true };
|
|
91
|
+
}
|
|
92
|
+
// Same height, different hash → reorg replacing matched (and any
|
|
93
|
+
// blocks tail-ward of it, though by construction matchIndex is the
|
|
94
|
+
// newest index ≤ newBlock.number, so there are no tail-ward
|
|
95
|
+
// entries with smaller-or-equal numbers; entries above matchIndex
|
|
96
|
+
// have strictly larger numbers and are also wrong).
|
|
97
|
+
const droppedHashes = prevRing.slice(matchIndex).map((b) => b.hash);
|
|
98
|
+
const trimmed = prevRing.slice(0, matchIndex);
|
|
99
|
+
return {
|
|
100
|
+
ring: capTail([...trimmed, newBlock], maxWindow),
|
|
101
|
+
reorg: {
|
|
102
|
+
blockNumber: newBlock.number,
|
|
103
|
+
depth: BigInt(droppedHashes.length),
|
|
104
|
+
newTipHash: newBlock.hash,
|
|
105
|
+
droppedHashes,
|
|
106
|
+
},
|
|
107
|
+
duplicate: false,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
// matched.number < newBlock.number — newBlock extends the chain
|
|
111
|
+
// from somewhere in the ring (or arrived with a gap).
|
|
112
|
+
if (matched.hash !== newBlock.parentHash) {
|
|
113
|
+
// Parent isn't where we thought it was. Either a gap (and the
|
|
114
|
+
// canonical chain at newBlock.parentHash isn't in our ring), or a
|
|
115
|
+
// deeper reorg the I/O layer didn't catch. Conservative: restart.
|
|
116
|
+
return { ring: [newBlock], reorg: null, duplicate: false };
|
|
117
|
+
}
|
|
118
|
+
// Append after matched. If matched isn't the tip, the entries above
|
|
119
|
+
// matchIndex were on a now-stale branch — drop them and emit a reorg
|
|
120
|
+
// for the dropped tail. (matched.parentHash by construction was OK
|
|
121
|
+
// earlier, but children we recorded above it have been superseded.)
|
|
122
|
+
if (matchIndex < prevRing.length - 1) {
|
|
123
|
+
const droppedHashes = prevRing.slice(matchIndex + 1).map((b) => b.hash);
|
|
124
|
+
const kept = prevRing.slice(0, matchIndex + 1);
|
|
125
|
+
return {
|
|
126
|
+
ring: capTail([...kept, newBlock], maxWindow),
|
|
127
|
+
reorg: {
|
|
128
|
+
blockNumber: newBlock.number,
|
|
129
|
+
depth: BigInt(droppedHashes.length),
|
|
130
|
+
newTipHash: newBlock.hash,
|
|
131
|
+
droppedHashes,
|
|
132
|
+
},
|
|
133
|
+
duplicate: false,
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
// Clean append at the tip.
|
|
137
|
+
return {
|
|
138
|
+
ring: capTail([...prevRing, newBlock], maxWindow),
|
|
139
|
+
reorg: null,
|
|
140
|
+
duplicate: false,
|
|
141
|
+
};
|
|
142
|
+
};
|
|
143
|
+
/**
|
|
144
|
+
* Trim the head (oldest entries) until length ≤ maxWindow. Internal
|
|
145
|
+
* helper; exported only for testing if needed (currently colocated
|
|
146
|
+
* tests use `incorporateBlock` end-to-end).
|
|
147
|
+
*
|
|
148
|
+
* `maxWindow` ≤ 0n is treated as "no cap" so callers can disable the
|
|
149
|
+
* window by passing 0n; that's an unusual configuration but keeps the
|
|
150
|
+
* pure helper from throwing on bad input.
|
|
151
|
+
*/
|
|
152
|
+
const capTail = (ring, maxWindow) => {
|
|
153
|
+
if (maxWindow <= 0n)
|
|
154
|
+
return ring;
|
|
155
|
+
const max = Number(maxWindow);
|
|
156
|
+
if (ring.length <= max)
|
|
157
|
+
return ring;
|
|
158
|
+
return ring.slice(ring.length - max);
|
|
159
|
+
};
|
|
160
|
+
//# sourceMappingURL=ring.js.map
|
package/dist/ring.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ring.js","sourceRoot":"","sources":["../src/ring.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAwCH;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,QAAgC,EAChC,QAAqB,EACrB,SAAiB,EACH,EAAE;IAChB,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC1B,OAAO,EAAE,IAAI,EAAE,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,CAAA;IAC5D,CAAC;IAED,2EAA2E;IAC3E,IAAI,UAAU,GAAG,CAAC,CAAC,CAAA;IACnB,KAAK,IAAI,CAAC,GAAG,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QACjD,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,IAAI,QAAQ,CAAC,MAAM,EAAE,CAAC;YAC1C,UAAU,GAAG,C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AAA;IAChC,MAAM,GAAG,GAAG,MAAM,CAAC,SAAS,CAAC,CAAA;IAC7B,IAAI,IAAI,CAAC,MAAM,IAAI,GAAG;QAAE,OAAO,IAAI,CAAA;IACnC,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC,CAAA;AACtC,CAAC,CAAA"}
|
package/dist/samples.d.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* `transport.ts` (which stays I/O) so tests can fixture the RPC
|
|
9
9
|
* shapes without touching either neighbor.
|
|
10
10
|
*/
|
|
11
|
-
import type { BlockResult, TxPoolContent } from '
|
|
11
|
+
import type { BlockResult, TxPoolContent } from '@valve-tech/chain-source';
|
|
12
12
|
import type { BlockSample, TipSample } from './types.js';
|
|
13
13
|
/**
|
|
14
14
|
* Convert a full block (from `eth_getBlockByNumber(_, true)`) into a
|
package/dist/samples.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"samples.d.ts","sourceRoot":"","sources":["../src/samples.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;
|
|
1
|
+
{"version":3,"file":"samples.d.ts","sourceRoot":"","sources":["../src/samples.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EACV,WAAW,EAEX,aAAa,EACd,MAAM,0BAA0B,CAAA;AAGjC,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AA8BxD;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,GAAI,OAAO,WAAW,KAAG,WAsBlD,CAAA;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,gBAAgB,GAC3B,MAAM,aAAa,GAAG,IAAI,GAAG,SAAS,EACtC,gBAAgB,MAAM,KACrB,SAAS,EAkBX,CAAA"}
|
package/dist/samples.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"samples.js","sourceRoot":"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EAAE,CAAC,GAAG,CAAC;gBACnB,MAAM,EAAE,YAAY,CAAC,EAAE,CAAC,IAAI,CAAC;gBAC7B,IAAI,EAAE,EAAE,CAAC,IAAI;gBACb,OAAO,EAAE,SAAS;gBAClB,KAAK,EAAE,WAAW,CAAC,KAAK,CAAC,IAAI,WAAW,CAAC,EAAE,CAAC,KAAK,CAAC;aACnD,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA"}
|
package/dist/transport.d.ts
CHANGED
|
@@ -21,36 +21,17 @@
|
|
|
21
21
|
* (excessBlobGas, blobGasUsed) that viem currently doesn't surface in
|
|
22
22
|
* its decoded Block type uniformly across versions.
|
|
23
23
|
*/
|
|
24
|
+
import type { BlockResult, FeeHistoryResult, PollOptions, TxPoolContent } from '@valve-tech/chain-source';
|
|
24
25
|
import type { PublicClient } from 'viem';
|
|
25
|
-
import type { PollOptions, RawTx } from './types.js';
|
|
26
|
-
/** Result shape returned by `eth_feeHistory`. */
|
|
27
|
-
export interface FeeHistoryResult {
|
|
28
|
-
baseFeePerGas: string[];
|
|
29
|
-
reward?: string[][];
|
|
30
|
-
gasUsedRatio: number[];
|
|
31
|
-
oldestBlock: string;
|
|
32
|
-
}
|
|
33
26
|
/**
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
27
|
+
* Combined upstream payload one oracle poll cycle consumes. Each field is
|
|
28
|
+
* `null` when its underlying RPC failed or was disabled by `PollOptions`;
|
|
29
|
+
* `reducePollInputs` handles every shape independently.
|
|
30
|
+
*
|
|
31
|
+
* The wire-shape members (`FeeHistoryResult`, `BlockResult`, `TxPoolContent`)
|
|
32
|
+
* are owned by `@valve-tech/chain-source`; this composite shape stays here
|
|
33
|
+
* because it's gas-oracle's call shape, not chain-source's.
|
|
37
34
|
*/
|
|
38
|
-
export interface BlockResult {
|
|
39
|
-
number: string;
|
|
40
|
-
hash?: string;
|
|
41
|
-
parentHash?: string;
|
|
42
|
-
timestamp: string;
|
|
43
|
-
baseFeePerGas: string;
|
|
44
|
-
gasLimit: string;
|
|
45
|
-
gasUsed: string;
|
|
46
|
-
transactions: RawTx[];
|
|
47
|
-
excessBlobGas?: string;
|
|
48
|
-
blobGasUsed?: string;
|
|
49
|
-
}
|
|
50
|
-
export interface TxPoolContent {
|
|
51
|
-
pending: Record<string, Record<string, RawTx>>;
|
|
52
|
-
queued: Record<string, Record<string, RawTx>>;
|
|
53
|
-
}
|
|
54
35
|
export interface OraclePollInputs {
|
|
55
36
|
feeHistory: FeeHistoryResult | null;
|
|
56
37
|
block: BlockResult | null;
|
package/dist/transport.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,gBAAgB,EAChB,WAAW,EACX,aAAa,EACd,MAAM,0BAA0B,CAAA;AACjC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAExC;;;;;;;;GAQG;AACH,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,gBAAgB,GAAG,IAAI,CAAA;IACnC,KAAK,EAAE,WAAW,GAAG,IAAI,CAAA;IACzB,MAAM,EAAE,aAAa,GAAG,IAAI,CAAA;CAC7B;AA2BD;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,GAC/B,QAAQ,YAAY,EACpB,UAAU,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,KAC/B,OAAO,CAAC,MAAM,GAAG,IAAI,CAQvB,CAAA;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,iBAAiB,GAC5B,QAAQ,YAAY,EACpB,UAAS;IACP,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,KAAK,IAAI,CAAA;IAChD,IAAI,CAAC,EAAE,WAAW,CAAA;CACd,KACL,OAAO,CAAC,gBAAgB,CAiC1B,CAAA"}
|
package/dist/transport.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;
|
|
1
|
+
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAyBH;;;;;;;GAOG;AACH,MAAM,WAAW,GAAG,KAAK,EACvB,MAAoB,EACpB,MAAc,EACd,MAAiB,EACjB,OAAgC,EACb,EAAE;IACrB,IAAI,CAAC;QACH,oEAAoE;QACpE,qEAAqE;QACrE,MAAM,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,EAAW,CAAC,CAAM,CAAA;QACvE,OAAO,MAAM,IAAI,IAAI,CAAA;IACvB,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAI,OAAO;YAAE,OAAO,CAAC,GAAG,CAAC,CAAA;QACzB,OAAO,IAAI,CAAA;IACb,CAAC;AACH,CAAC,CAAA;AAED;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,EACvC,MAAoB,EACpB,OAAgC,EACR,EAAE;IAC1B,MAAM,IAAI,GAAG,MAAM,WAAW,CAAS,MAAM,EAAE,iBAAiB,EAAE,EAAE,EAAE,OAAO,CAAC,CAAA;IAC9E,IAAI,IAAI,KAAK,IAAI;QAAE,OAAO,IAAI,CAAA;IAC9B,IAAI,CAAC;QACH,OAAO,MAAM,CAAC,IAAI,CAAC,CAAA;IACrB,CAAC;IAAC,M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AC,CAAA"}
|
package/dist/types.d.ts
CHANGED
|
@@ -6,28 +6,14 @@
|
|
|
6
6
|
* since JSON has no native bigint and `JSON.stringify` will throw on raw
|
|
7
7
|
* bigint values. The caller owns that encoding — this package keeps the
|
|
8
8
|
* canonical numeric form internally.
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* Minimal tx shape extracted from `eth_getBlockByNumber(latest, true)` or
|
|
12
|
-
* `txpool_content`. Fee fields drive tip math; `hash`, `from`, `nonce`
|
|
13
|
-
* support mempool lookups (`findByHash` / `findByAddressNonce`). Other
|
|
14
|
-
* tx fields (to/value/data/etc.) are ignored.
|
|
15
9
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
10
|
+
* Wire-shape types describing raw `eth_*` responses (`RawTx`,
|
|
11
|
+
* `BlockResult`, `FeeHistoryResult`, `TxPoolContent`, `NormalizedMempool`)
|
|
12
|
+
* and the poll-cycle toggle (`PollOptions`) live in
|
|
13
|
+
* `@valve-tech/chain-source`. This package re-exports them from `index.ts`
|
|
14
|
+
* for downstream API stability.
|
|
20
15
|
*/
|
|
21
|
-
|
|
22
|
-
maxPriorityFeePerGas?: string;
|
|
23
|
-
maxFeePerGas?: string;
|
|
24
|
-
gasPrice?: string;
|
|
25
|
-
gas?: string;
|
|
26
|
-
type?: string;
|
|
27
|
-
hash?: string;
|
|
28
|
-
from?: string;
|
|
29
|
-
nonce?: string;
|
|
30
|
-
}
|
|
16
|
+
import type { ReorgEvent } from './ring.js';
|
|
31
17
|
export interface TipPercentiles {
|
|
32
18
|
p10: bigint;
|
|
33
19
|
p25: bigint;
|
|
@@ -140,25 +126,6 @@ export declare const TxType: {
|
|
|
140
126
|
readonly setCodeAuthorization: 4;
|
|
141
127
|
};
|
|
142
128
|
export type TxType = (typeof TxType)[keyof typeof TxType];
|
|
143
|
-
/**
|
|
144
|
-
* Producer-side toggles: which RPCs the oracle calls upstream each cycle.
|
|
145
|
-
*
|
|
146
|
-
* Fields default to true. `eth_getBlockByNumber` is intentionally not
|
|
147
|
-
* toggleable — without a block we can't compute anything.
|
|
148
|
-
*
|
|
149
|
-
* - `feeHistory: false` — drops `eth_feeHistory`. Trend detection falls
|
|
150
|
-
* back to a single-element history (always
|
|
151
|
-
* reports `'stable'`); percentile fallback
|
|
152
|
-
* becomes block-only.
|
|
153
|
-
* - `mempool: false` — drops `txpool_content`. Tiers reflect block
|
|
154
|
-
* inclusion only, not pending pressure. Useful
|
|
155
|
-
* when the upstream provider gates the
|
|
156
|
-
* method (many public RPCs return 405).
|
|
157
|
-
*/
|
|
158
|
-
export interface PollOptions {
|
|
159
|
-
feeHistory?: boolean;
|
|
160
|
-
mempool?: boolean;
|
|
161
|
-
}
|
|
162
129
|
/**
|
|
163
130
|
* One block's worth of state retained in the rolling ring. Per-tx tips
|
|
164
131
|
* + gas are kept so we can re-percentile on each poll without re-fetching
|
|
@@ -191,12 +158,31 @@ export interface GasOracleState {
|
|
|
191
158
|
blob: BlobStats | null;
|
|
192
159
|
tiers: Record<TierName, TierRecommendation>;
|
|
193
160
|
/**
|
|
194
|
-
* Rolling ring of recent blocks (oldest → newest).
|
|
195
|
-
*
|
|
196
|
-
*
|
|
197
|
-
*
|
|
161
|
+
* Rolling ring of recent blocks (oldest → newest). Capacity is
|
|
162
|
+
* controlled by `createGasOracle`'s `ringWindowBlocks` option
|
|
163
|
+
* (default 20n). Producer-local: the relay's `toPublishable` strips
|
|
164
|
+
* it before publishing snapshots over the wire, since downstream
|
|
165
|
+
* consumers receiving a serialized snapshot don't need the per-block
|
|
166
|
+
* sample buffer.
|
|
167
|
+
*
|
|
168
|
+
* Maintained by the pure helper in `ring.ts`. Each new block triggers
|
|
169
|
+
* one of: clean append (with head-trim if the cap would be exceeded),
|
|
170
|
+
* duplicate (no-op), reorg (trim the diverged tail then append), or
|
|
171
|
+
* restart (drop everything and start fresh from this block — fires
|
|
172
|
+
* when the gap exceeds the window or the parent chain isn't
|
|
173
|
+
* recoverable). The poll loop pre-fetches missing blocks via
|
|
174
|
+
* `source.getBlock` to bridge clean gaps before reaching the reducer.
|
|
198
175
|
*/
|
|
199
176
|
ring: BlockSample[];
|
|
177
|
+
/**
|
|
178
|
+
* Most recent reorg observed by the ring lifecycle, or `null` if no
|
|
179
|
+
* reorg has been seen since this oracle instance started. Persists
|
|
180
|
+
* across subsequent clean appends — consumers asking "did a reorg
|
|
181
|
+
* happen on THIS tick?" should compare `lastReorg.blockNumber`
|
|
182
|
+
* against `state.blockNumber`. Producer-local; safe to ship over
|
|
183
|
+
* the wire but not load-bearing.
|
|
184
|
+
*/
|
|
185
|
+
lastReorg: ReorgEvent | null;
|
|
200
186
|
/**
|
|
201
187
|
* Live mempool samples used to compute this snapshot's tiers.
|
|
202
188
|
* Producer-local — wire publishers should strip before serializing
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAE3C,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;CACZ;AAED;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC,oBAAoB,EAAE,MAAM,CAAA;IAC5B,YAAY,EAAE,MAAM,CAAA;IACpB,QAAQ,EAAE,MAAM,CAAA;IAChB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAA;CAChC;AAED,eAAO,MAAM,KAAK;;;;CAIR,CAAA;AACV,MAAM,MAAM,KAAK,GAAG,CAAC,OAAO,K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I,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,SAAS,EAAE,CAAA;CAClB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAA;IACf,WAAW,EAAE,MAAM,CAAA;IACnB,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,MAAM,CAAA;IACf,YAAY,EAAE,KAAK,CAAA;IACnB,cAAc,EAAE,MAAM,EAAE,CAAA;IACxB,OAAO,EAAE,YAAY,CAAA;IACrB,IAAI,EAAE,SAAS,GAAG,IAAI,CAAA;IACtB,KAAK,EAAE,MAAM,CAAC,QAAQ,EAAE,kBAAkB,CAAC,CAAA;IAC3C;;;;;;;;;;;;;;;OAeG;IACH,IAAI,EAAE,WAAW,EAAE,CAAA;IACnB;;;;;;;OAOG;IACH,SAAS,EAAE,UAAU,GAAG,IAAI,CAAA;IAC5B;;;;;;;OAOG;IACH,cAAc,EAAE,SAAS,EAAE,CAAA;IAC3B,iBAAiB,CAAC,EAAE,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;IAC5C,wBAAwB,CAAC,EAAE,MAAM,CAAA;CAClC"}
|
package/dist/types.js
CHANGED
|
@@ -6,6 +6,12 @@
|
|
|
6
6
|
* since JSON has no native bigint and `JSON.stringify` will throw on raw
|
|
7
7
|
* bigint values. The caller owns that encoding — this package keeps the
|
|
8
8
|
* canonical numeric form internally.
|
|
9
|
+
*
|
|
10
|
+
* Wire-shape types describing raw `eth_*` responses (`RawTx`,
|
|
11
|
+
* `BlockResult`, `FeeHistoryResult`, `TxPoolContent`, `NormalizedMempool`)
|
|
12
|
+
* and the poll-cycle toggle (`PollOptions`) live in
|
|
13
|
+
* `@valve-tech/chain-source`. This package re-exports them from `index.ts`
|
|
14
|
+
* for downstream API stability.
|
|
9
15
|
*/
|
|
10
16
|
export const Trend = {
|
|
11
17
|
rising: 'rising',
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAwBH,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,MAAM,EAAE,QAAQ;IAChB,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,QAAQ;CACR,CAAA;AAGV,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,IAAI,EAAE,MAAM;IACZ,QAAQ,EAAE,UAAU;IACpB,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,SAAS;CACV,CAAA;AAGV;;;;;GAKG;AACH,MAAM,CAAC,MAAM,WAAW,GAAwB;IAC9C,QAAQ,CAAC,IAAI;IACb,QAAQ,CAAC,QAAQ;IACjB,QAAQ,CAAC,IAAI;IACb,QAAQ,CAAC,OAAO;CACR,CAAA;AA2CV;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,SAAS;CACV,CAAA;AAGV;;;;GAIG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,MAAM,EAAE,CAAC;IACT,OAAO,EAAE,CAAC;IACV,OAAO,EAAE,CAAC;IACV,IAAI,EAAE,CAAC;IACP,oBAAoB,EAAE,CAAC;CACf,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"viem-actions.d.ts","sourceRoot":"","sources":["../src/viem-actions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAExC,OAAO,EAEL,KAAK,kBAAkB,EACvB,K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map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"viem-actions.js","sourceRoot":"","sources":["../src/viem-actions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAIH,OAAO,EACL,mBAAmB,GAGpB,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"viem-actions.js","sourceRoot":"","sources":["../src/viem-actions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAIH,OAAO,EACL,mBAAmB,GAGpB,MAAM,qBAAqB,CAAA;AAG5B,OAAO,EACL,aAAa,EACb,gBAAgB,GAGjB,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,eAAe,EAA+C,MAAM,aAAa,CAAA;AA+C1F,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,OAAgC,EAAE,EAAE,CACnE,CAAC,MAAoB,EAAoB,EAAE;IACzC,+DAA+D;IAC/D,8DAA8D;IAC9D,gEAAgE;IAChE,4DAA4D;IAC5D,0DAA0D;IAC1D,yBAAyB;IACzB,MAAM,MAAM,GAAc,eAAe,CAAC;QACxC,aAAa,EAAE,KAAK;QACpB,GAAG,OAAO;QACV,MAAM;KACP,CAAC,CAAA;IACF,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,OAAO,CAAA;IAC9C,IAAI,OAAO,GAAG,KAAK,CAAA;IACnB,IAAI,SAAS,KAAK,OAAO,EAAE,CAAC;QAC1B,MAAM,CAAC,KAAK,EAAE,CAAA;QACd,OAAO,GAAG,IAAI,CAAA;IAChB,CAAC;IAED,MAAM,WAAW,GAAG,KAAK,IAA6B,EAAE;QACtD,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,CAAC,KAAK,EAAE,CAAA;YACd,OAAO,GAAG,IAAI,CAAA;QAChB,CAAC;QACD,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAA;QAChC,IAAI,MAAM;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AAM,EAAE,EAAE,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS;4BAC3D,IAAI,EAAE,EAAE,CAAC,IAAI;4BACb,OAAO;4BACP,KAAK;yBACN;qBACF,CAAA;gBACH,CAAC,CAAC,CACH;gBACH,CAAC,CAAC,EAAE,CAAA;YACN,OAAO,mBAAmB,CAAC,CAAC,GAAG,WAAW,EAAE,GAAG,cAAc,CAAC,EAAE,KAAK,CAAC,CAAA;QACxE,CAAC;QACD,aAAa,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE;KACnC,CAAA;AACH,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@valve-tech/gas-oracle",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "Multi-tier gas-fee oracle for EVM chains. Computes slow/standard/fast/instant tier recommendations from block-included tips, mempool pending tips, and base-fee trend, with a configurable downside-decay cap and a chain-aware EIP-1559 priority cutoff. viem-native — pass it a PublicClient and it does the rest. Ships viem-actions and viem-transport subpaths for drop-in client extension and transport-wrapping.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/valve-tech/evm-toolkit/tree/main/packages/gas-oracle#readme",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"prepare": "yarn build"
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@valve-tech/chain-source": "^0.
|
|
62
|
+
"@valve-tech/chain-source": "^0.11.0"
|
|
63
63
|
},
|
|
64
64
|
"peerDependencies": {
|
|
65
65
|
"viem": "^2.0.0"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: gas-oracle-integration
|
|
3
|
-
description: Integrate `@valve-tech/gas-oracle` into an EVM dapp or backend. Use when the user wants gas-tier recommendations (`slow` / `standard` / `fast` / `instant`), needs to set `maxPriorityFeePerGas` and `maxFeePerGas` for a transaction,
|
|
3
|
+
description: Integrate `@valve-tech/gas-oracle` into an EVM dapp or backend. Use when the user wants gas-tier recommendations (`slow` / `standard` / `fast` / `instant`), needs to set `maxPriorityFeePerGas` and `maxFeePerGas` for a transaction, asks "how do I price a transaction" against a viem `PublicClient`, or wants to bump a stuck tx (`recommendBumpTier` / `bumpForReplacement`). Also use when seeing imports from `@valve-tech/gas-oracle` and the user asks for help configuring it per chain (Ethereum, Base, Arbitrum, OP, PulseChain), or asks about `priorityFeeDecayCap`, `priorityModel`, `tipForBlockPosition`, `classifyTip`, `chainPresets`, viem-actions, or viem-transport. Also fires when the user asks about composing the oracle with `@valve-tech/tx-tracker` over a shared `ChainSource` — but actual per-tx tracking work belongs in the tx-tracker skill, not here. Skip when the user only wants per-tx state (delegate to tx-tracker-integration), only wants the raw block/mempool stream with no gas math (delegate to chain-source-integration), or is doing simple `eth_gasPrice` queries that don't need multi-tier reasoning (vanilla viem suffices).
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Integrating `@valve-tech/gas-oracle`
|