Skip to content

Commit 45af90c

Browse files
authored
Merge pull request #8 from aztec-labs-eng/gj/fix_typecheck
test
2 parents 6155ebf + fb05951 commit 45af90c

14 files changed

Lines changed: 148 additions & 32 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,14 @@ jobs:
158158
# PRs → development. `vercel build` has no "development" target, so for
159159
# PR pulls we rename the dropped .env.development.local to .env.preview.local
160160
# so the subsequent preview build picks it up.
161+
#
162+
# We ALSO override Vercel's git ref detection for PR deploys. Without
163+
# this, Vercel reads CI env vars on `pull_request_target` and decides
164+
# the deployment's branch from the PR base (`next`), then routes the
165+
# build through its `next`-branch preview alias and pulls Preview-scope
166+
# env vars server-side — the very thing we're trying to avoid. Pinning
167+
# `VERCEL_GIT_COMMIT_REF` to a per-PR string detaches the deployment
168+
# from any branch alias and gives each PR its own unique preview URL.
161169
- name: Resolve Vercel environment slot
162170
run: |
163171
if [ "${{ github.event_name }}" == "push" ] && [ "${{ github.ref }}" == "refs/heads/main" ]; then
@@ -169,6 +177,10 @@ jobs:
169177
else
170178
echo "VERCEL_ENV_SLOT=development" >> "$GITHUB_ENV"
171179
fi
180+
if [ "${{ github.event_name }}" == "pull_request_target" ]; then
181+
echo "VERCEL_GIT_COMMIT_REF=pr-${{ github.event.pull_request.number }}" >> "$GITHUB_ENV"
182+
echo "VERCEL_GIT_COMMIT_SHA=${{ github.event.pull_request.head.sha }}" >> "$GITHUB_ENV"
183+
fi
172184
173185
# ── Bridge deployment ──────────────────────────────────────────────
174186
- name: Pull Vercel Environment (Bridge)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "nextnet",
33
"name": "Aztec Nextnet (Sepolia)",
4-
"aztecNodeUrl": "https://aztec-nextnet.alexghr.me",
4+
"aztecNodeUrl": "https://nextnet.aztec-labs.com",
55
"l1RpcUrl": "https://sepolia.drpc.org",
66
"l1ChainId": 11155111
77
}

apps/bridge/vite.config.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ export default defineConfig(({ mode }) => {
2828
),
2929
},
3030
},
31+
// Pin the port + fail rather than auto-bump. OPFS storage is keyed by
32+
// origin (scheme+host+port); a drifting port means the wallet writes a
33+
// sqlite OPFS file under :5173 one session and tries to read it under
34+
// :5174 the next, ending up with stale or unreadable stores. `strictPort`
35+
// makes Vite refuse to start on a taken port instead of silently picking
36+
// another one.
37+
server: { port: 5173, strictPort: true },
3138
plugins: [aztecVitePlugin(), react({ jsxImportSource: "@emotion/react" })],
3239
define: {
3340
"process.env": JSON.stringify({

apps/fpc-operator/src/components/SetupWizard.tsx

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ interface SetupWizardProps {
2525
}
2626

2727
export function SetupWizard({ onComplete, onFpcAddressComputed }: SetupWizardProps) {
28-
const { status, wallet, address, node } = useWallet();
28+
const { status, wallet, address, node, error: walletError } = useWallet();
2929
const { activeNetwork } = useNetwork();
3030
const [activeStep, setActiveStep] = useState(0);
3131
const [fpcAddress, setFpcAddress] = useState<string | null>(null);
@@ -122,7 +122,26 @@ export function SetupWizard({ onComplete, onFpcAddressComputed }: SetupWizardPro
122122
{status === "loading" ? "Creating embedded wallet..." : "Computing FPC address..."}
123123
</Typography>
124124
</Box>
125-
{status === "error" && <Alert severity="error">Failed to initialize wallet</Alert>}
125+
{status === "error" && (
126+
<Alert severity="error">
127+
Failed to initialize wallet
128+
{walletError && (
129+
<Box
130+
component="pre"
131+
sx={{
132+
mt: 1,
133+
mb: 0,
134+
whiteSpace: "pre-wrap",
135+
wordBreak: "break-word",
136+
fontSize: "0.75rem",
137+
fontFamily: "monospace",
138+
}}
139+
>
140+
{walletError}
141+
</Box>
142+
)}
143+
</Alert>
144+
)}
126145
</StepContent>
127146
</Step>
128147

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "nextnet",
33
"name": "Aztec Nextnet (Sepolia)",
4-
"aztecNodeUrl": "https://aztec-nextnet.alexghr.me",
4+
"aztecNodeUrl": "https://nextnet.aztec-labs.com",
55
"l1RpcUrl": "https://sepolia.drpc.org",
66
"l1ChainId": 11155111
77
}

apps/fpc-operator/vite.config.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@ export default defineConfig(({ mode }) => {
88
return {
99
base: "./",
1010
logLevel: process.env.CI ? "error" : undefined,
11-
server: { port: 5174 },
11+
// Pin the port + fail rather than auto-bump. OPFS storage is keyed by
12+
// origin (scheme+host+port); a drifting port means the wallet writes a
13+
// sqlite OPFS file under :5174 one session and tries to read it under
14+
// :5175 the next, ending up with stale or unreadable stores. `strictPort`
15+
// makes Vite refuse to start on a taken port instead of silently picking
16+
// another one.
17+
server: { port: 5174, strictPort: true },
1218
resolve: {
1319
alias: {
1420
"@aztec-kit/embedded-wallet/ui": resolve(

apps/swap/scripts/register-fpc-signups.ts

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import {
4242
fetchFeeStats,
4343
computeMaxFeeFromP75,
4444
computeMaxFeeFromCurrent,
45+
fetchMaxBlockGasFees,
4546
} from "@aztec-kit/common/fees";
4647

4748
import {
@@ -62,12 +63,14 @@ import type { EmbeddedWallet } from "@aztec/wallets/embedded";
6263
const P75_BLOCK_RANGE = 2000;
6364
const P75_MULTIPLIER = 2;
6465
/**
65-
* Multiplier applied when we fall back to the node's current min fees (clustec
66-
* indexer unavailable). The P75 already accounts for historical spread so 2×
67-
* is enough; current min fees are the floor right now with no headroom, so we
68-
* need a much wider buffer. Matches the 10× used by the e2e local flow.
66+
* Range and multiplier for the node-walked historical fallback used when no
67+
* clustec indexer is available (e.g. nextnet). We take the `max` of
68+
* `header.globalVariables.gasFees` across the last N blocks as a proxy for
69+
* the worst-case `maxFeesPerGas` the wallet will commit. `× 2` matches the
70+
* testnet P75 multiplier — start small, bump if the assertion still fires.
6971
*/
70-
const CURRENT_FEE_FALLBACK_MULTIPLIER = 10;
72+
const HISTORICAL_BLOCK_RANGE = 1000;
73+
const HISTORICAL_FEE_MULTIPLIER = 2;
7174

7275
/** Default sponsorship policy; individual specs can override any field. */
7376
const SIGNUP_POLICY = {
@@ -411,15 +414,18 @@ async function pickSignupParams(params: {
411414
} catch (err) {
412415
const reason = err instanceof Error ? err.message : String(err);
413416
console.error(
414-
` clustec P75 fetch failed (${reason}); falling back to node min fees × ${CURRENT_FEE_FALLBACK_MULTIPLIER}`,
417+
` clustec fetch failed (${reason}); falling back to node-walked max block gasFees over last ${HISTORICAL_BLOCK_RANGE} blocks × ${HISTORICAL_FEE_MULTIPLIER}`,
418+
);
419+
const peak = await fetchMaxBlockGasFees(node, HISTORICAL_BLOCK_RANGE);
420+
console.error(
421+
` peak gasFees over blocks ${peak.fromBlock}..${peak.toBlock} (n=${peak.sampleSize}): feePerDaGas=${peak.feePerDaGas} feePerL2Gas=${peak.feePerL2Gas}`,
415422
);
416-
const minFees = await node.getCurrentMinFees();
417423
maxFee = computeMaxFeeFromCurrent(
418424
subscribeGas,
419425
zeroTeardown,
420-
BigInt(minFees.feePerDaGas),
421-
BigInt(minFees.feePerL2Gas),
422-
CURRENT_FEE_FALLBACK_MULTIPLIER,
426+
peak.feePerDaGas,
427+
peak.feePerL2Gas,
428+
HISTORICAL_FEE_MULTIPLIER,
423429
);
424430
}
425431
}

apps/swap/src/config/networks/nextnet.json

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
{
22
"id": "nextnet",
3-
"nodeUrl": "https://aztec-nextnet.alexghr.me",
3+
"nodeUrl": "https://nextnet.aztec-labs.com",
44
"chainId": "11155111",
55
"rollupVersion": "960120478",
66
"contracts": {
7-
"goCoin": "0x14845fb4ebed07e994f2e245ed945dcdf72dd1cf29188f047b1d65dbb02ac5c5",
8-
"goCoinPremium": "0x24f7125f34ea6ec014a87ccdf40317fe0df0983d7499f91a024f6f655b232cce",
9-
"amm": "0x018d8e0f8ff1e173b754a4e987b5ba31f99302157197fb196110f032ae20189a",
10-
"liquidityToken": "0x2c0f747dca1b89aaa37ac38ff506f8f56832f405cce941372d639a7f569bd3e5",
11-
"pop": "0x09c264ef8a38484646049258f1010ef25cc00856d347d08445432600ffc15cd0",
7+
"goCoin": "0x2176092c60b28822d821aae00b6a9c452d12684bc8585c9d12255260e33a2d93",
8+
"goCoinPremium": "0x0f9a9271ec8a5a9f9d2adfc443d09701f2de9066c92c4935347ea5db973d79e2",
9+
"amm": "0x204d93123d73aa464511f81392f708614a7ccdb6fdf602d0a0f4006bc163c2dd",
10+
"liquidityToken": "0x2db813553ef42d961a7cffd011f9b7976cbcf597d576e4260d7d8cc6a0627de4",
11+
"pop": "0x1878d43be1109f18345a648763eda61669938a8be2965f693258efa9aae148a2",
1212
"sponsoredFPC": "0x1114a201e7b0680b2b75bc47be3abebbc54caf83f471e12b66c8a1abfa4478dd",
13-
"salt": "0x0000000000000000000000000000000000000000000000000000000000000000"
13+
"salt": "0x000000000000000000000000000000000000000000000000000000000000007b"
1414
},
1515
"deployer": {
16-
"address": "0x092c879b37132316e01570ee32911e17c543d48c2e3d9eca5e7a1fea4846a7da"
16+
"address": "0x255d5ebb7dc80fa97a9849935852de9d9984bca5e53a69ba9439b5ebe925f875"
1717
},
18-
"deployedAt": "2026-05-19T09:06:49.754Z",
18+
"deployedAt": "2026-05-20T13:27:46.845Z",
1919
"subscriptionFPC": {
20-
"address": "0x0b70cef299b052b950147adeafbabd3d9e30835bdec28428812eed6f3cc2aa25",
20+
"address": "0x041f6084335f0e0c0849d6e32ab0b051c0599a9c5e4752a9b622ac500e396df8",
2121
"secretKey": "0x000000000000000000000000000000000000000000000000000000000000002c",
2222
"functions": {
23-
"0x09c264ef8a38484646049258f1010ef25cc00856d347d08445432600ffc15cd0": {
23+
"0x1878d43be1109f18345a648763eda61669938a8be2965f693258efa9aae148a2": {
2424
"0xa539bd29": {
2525
"configIndex": 0,
2626
"gasLimits": {
@@ -30,7 +30,7 @@
3030
"hasPublicCall": true
3131
}
3232
},
33-
"0x018d8e0f8ff1e173b754a4e987b5ba31f99302157197fb196110f032ae20189a": {
33+
"0x204d93123d73aa464511f81392f708614a7ccdb6fdf602d0a0f4006bc163c2dd": {
3434
"0xfd228669": {
3535
"configIndex": 0,
3636
"gasLimits": {
@@ -40,7 +40,7 @@
4040
"hasPublicCall": true
4141
}
4242
},
43-
"0x14845fb4ebed07e994f2e245ed945dcdf72dd1cf29188f047b1d65dbb02ac5c5": {
43+
"0x2176092c60b28822d821aae00b6a9c452d12684bc8585c9d12255260e33a2d93": {
4444
"0x859e4f61": {
4545
"configIndex": 0,
4646
"gasLimits": {
@@ -50,7 +50,7 @@
5050
"hasPublicCall": false
5151
}
5252
},
53-
"0x24f7125f34ea6ec014a87ccdf40317fe0df0983d7499f91a024f6f655b232cce": {
53+
"0x0f9a9271ec8a5a9f9d2adfc443d09701f2de9066c92c4935347ea5db973d79e2": {
5454
"0x859e4f61": {
5555
"configIndex": 0,
5656
"gasLimits": {

apps/swap/vite.config.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,13 @@ export default defineConfig(({ command, mode }) => {
6969
),
7070
},
7171
},
72+
// Pin the port + fail rather than auto-bump. OPFS storage is keyed by
73+
// origin (scheme+host+port); a drifting port means the wallet writes a
74+
// sqlite OPFS file under :5175 one session and tries to read it under
75+
// :5176 the next, ending up with stale or unreadable stores. `strictPort`
76+
// makes Vite refuse to start on a taken port instead of silently picking
77+
// another one.
78+
server: { port: 5175, strictPort: true },
7279
plugins: [
7380
aztecVitePlugin({ es2016: isDev }),
7481
react({ jsxImportSource: "@emotion/react" }),
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/**
2+
* Historical block-base-fee aggregator for networks without a clustec
3+
* indexer (e.g. nextnet). Walks the last `blocks` block headers from the
4+
* node and returns the highest per-gas fees observed across the window.
5+
*
6+
* Why max instead of a percentile: the wallet at runtime commits
7+
* `predicted(Limit) × 1.5` as its `maxFeesPerGas`. The protocol's predicted
8+
* value tracks current activity, so a long-running app's worst-case
9+
* commit is bounded by the historical peak base fee × (predicted/base
10+
* ratio ≈ 1.15) × 1.5. Using the observed `max` here gives the FPC's
11+
* `max_fee` calibration a stable upper bound that survives quiet
12+
* periods, when a snapshot-based calibration would otherwise lock in a
13+
* floor value and reject any subsequent busy-slot tx.
14+
*
15+
* Cheap: the node caps `getBlocks` at 50 per call, so 1000 blocks = 20
16+
* RPC round-trips. Headers only, no tx bodies.
17+
*/
18+
19+
import type { AztecNode } from "@aztec/aztec.js/node";
20+
import { BlockNumber } from "@aztec/foundation/branded-types";
21+
22+
export interface PeakGasFees {
23+
feePerDaGas: bigint;
24+
feePerL2Gas: bigint;
25+
/** Block range actually walked (clamped to chain tip). */
26+
fromBlock: number;
27+
toBlock: number;
28+
/** Number of blocks read. */
29+
sampleSize: number;
30+
}
31+
32+
const NODE_GET_BLOCKS_LIMIT = 50;
33+
34+
export async function fetchMaxBlockGasFees(node: AztecNode, blocks: number): Promise<PeakGasFees> {
35+
const tip = await node.getBlockNumber();
36+
const fromBlock = Math.max(1, tip - blocks + 1);
37+
const toBlock = tip;
38+
39+
let maxDa = 0n;
40+
let maxL2 = 0n;
41+
let sampleSize = 0;
42+
43+
for (let start = fromBlock; start <= toBlock; start += NODE_GET_BLOCKS_LIMIT) {
44+
const limit = Math.min(NODE_GET_BLOCKS_LIMIT, toBlock - start + 1);
45+
const batch = await node.getBlocks(BlockNumber(start), limit);
46+
for (const block of batch) {
47+
const fees = block.header.globalVariables.gasFees;
48+
if (fees.feePerDaGas > maxDa) maxDa = fees.feePerDaGas;
49+
if (fees.feePerL2Gas > maxL2) maxL2 = fees.feePerL2Gas;
50+
sampleSize += 1;
51+
}
52+
}
53+
54+
return { feePerDaGas: maxDa, feePerL2Gas: maxL2, fromBlock, toBlock, sampleSize };
55+
}

0 commit comments

Comments
 (0)