Skip to content

Starknet simulator bootstrap#26

Open
Timidan wants to merge 9 commits into
masterfrom
feat/starknet-sim-bootstrap
Open

Starknet simulator bootstrap#26
Timidan wants to merge 9 commits into
masterfrom
feat/starknet-sim-bootstrap

Conversation

@Timidan
Copy link
Copy Markdown
Owner

@Timidan Timidan commented Jun 1, 2026

Bootstraps the Starknet simulation engine and wires it into the toolkit.

  • Mounts the starknet-sim engine as a gitlink; proxy + dev-server config
  • Browser simulator client + types; /starknet/simulations route; footer SN-SIM status
  • RPC v0.10 env pattern; EVM/SVM earn adapters with context providers

9 commits. Note: may overlap with #17 (Starknet simulator integration, WIP) — worth reviewing together.

Timidan and others added 9 commits April 24, 2026 23:13
…rver

Branched from feat/phase4-wallet-gate so all Starknet wallet work is
already in place. Engine repo Timidan/starknet-sim is consumed as a
bare gitlink at starknet-sim/ (matching edb/), with no .gitmodules
entry; the gitlink SHA is the contract.

- vercel.json: /api/starknet-sim and /api/starknet-sim/:path* route
  to api/starknet-sim-proxy.ts
- api/starknet-sim-proxy.ts: fork of api/edb-proxy.ts with the
  STARKNET_SIM_BRIDGE_URL / STARKNET_SIM_API_KEY /
  STARKNET_SIM_CORS_ALLOWED_ORIGINS env surface, upstream header
  allowlist, 50 MB body cap, SSE pass-through, no etherscan-key
  injection
- vite.config.ts: injectBridgeCsp now splices both
  VITE_SIMULATOR_BRIDGE_URL and VITE_STARKNET_SIM_BRIDGE_URL origins;
  new /api/starknet-sim dev proxy rewrites to :5790 and injects
  X-API-Key server-side
- src/utils/env.ts: getStarknetSimBridgeUrl() helper mirrors
  getSimulatorBridgeUrl()
- package.json: starknet-sim:build and starknet-sim:server scripts
- .env.example: documents the four new env vars
- starknet-sim/ gitlink at engine commit 1497f0d46cae (initial scaffold)
- src/chains/starknet/simulatorTypes.ts: canonical type mirrors of
  the bridge JSON schemas (SimulateRequest/Response,
  FunctionInvocation recursive tree, FeeEstimate, StateDiff,
  BridgeErrorEnvelope, health/version shapes)
- src/chains/starknet/simulatorClient.ts: StarknetSimulator class
  with health/version/simulate/trace/estimate-fee; AbortController
  timeouts (60s default, 3s for /health), bridge-envelope error
  mapping, self-disable when VITE_STARKNET_SIM_BRIDGE_URL=disabled
- src/components/StarknetSimBridgeStatus.tsx: footer dot polling
  /health every 12s with a 3s timeout, reuses existing
  .edb-status-indicator CSS classes; surfaces git_sha in tooltip
- starknet-sim gitlink bumped to c2e0ae4 (auth middleware, rate
  limiter, route skeleton returning NOT_IMPLEMENTED for §2/§3
  endpoints)

The footer component is not yet mounted in the layout; the active
phase4 wallet work owns the footer container and isn't on origin
yet. Mounting is a one-line drop-in next to EdbBridgeStatus once
phase4 merges.
Engine commits since the previous bump:
- 678d022 feat(§12): Prometheus metrics exporter, API and operations docs
- c2e0ae4 feat(§1,§4): auth middleware, rate limiter, route skeleton

Metrics exporter binds to METRICS_BIND_ADDR (default 127.0.0.1:9090) —
a new env var the deploy runbook (starknet-sim/docs/OPERATIONS.md)
documents; no web-toolkit config change required.
- src/App.tsx: StarknetSimBridgeStatus mounts next to EdbBridgeStatus
  in the footer
- src/chains/capabilities.ts: starknet capability set now includes
  'simulation' and 'tx-replay' so PersistentTools resolves
  /starknet/simulations (capability filter was previously empty)
- src/components/PersistentTools.tsx: lazy-load StarknetSimulationsPage;
  new SimulationsDispatch wrapper routes the 'simulations' tool entry
  by family (starknet → trace view backed by starknet-sim bridge,
  evm → existing SimulationHistoryPage)
- src/components/starknet/StarknetSimulationsPage.tsx: two-tab shell
  (Trace | Synthetic — Sprint 2)
- src/components/starknet/TxTraceView.tsx: felt-validated hash input,
  trace button, summary card (fee/resources/version), invocation tree,
  state diff tabs; surfaces StarknetSimulatorBridgeError codes; shows
  an 'sim disabled' hint when VITE_STARKNET_SIM_BRIDGE_URL=disabled
- src/components/starknet/InvocationTree.tsx: recursive collapsible
  tree with MAX_DEPTH=256 clamp, short-addr and short-selector
  helpers, decodedEntryPoint preferred over raw selector when
  enrichment is present
- src/components/starknet/StateDiffTabs.tsx: storage | nonces |
  classes; counts in tab labels; empty-hint fallbacks
- gitlink bumped to 3ebbc7d (engine): /version now self-reports RPC
  v0.10 and docs point at the Alchemy v0_10 URL shape
- .env.example: documents STARKNET_RPC_URL/_SEPOLIA_URL/_FALLBACK_URL
  with the v0_10 path so operators paste the right shape

The real API key lives only in the droplet env file (and each
developer's local .env, which is gitignored).
Engine at 4803136: RPC client + BlockPin + v0.10 Alchemy integration.

- /health now returns chain_id, spec_version, fork_head (block
  number/hash/timestamp/l1 gas prices), rpc_latency_ms
- /block/:id resolves 'latest', 0x-hex hash, or decimal number;
  rejects 'pending' with 400
- MSRV bumped from 1.85 to 1.86 (reqwest transitives need icu_*
  crates at 1.86); rust-toolchain.toml and CI pinned

No web-toolkit code change beyond the gitlink.
Engine at 91f185e: RpcForkStateReader satisfies blockifier's
StateReader trait (blockifier 0.18.0-rc.1). Verified live against
Alchemy mainnet — reads class hash, storage, nonce; caches
per-session. Sierra→CASM compilation (get_compiled_class) stays
stubbed until §3 executor integration.

MSRV bumped to 1.89 — required by blockifier's transitive
cairo-lang-*/apollo crates. No web-toolkit code change beyond the
gitlink.
Engine at 3c932f4: get_compiled_class now succeeds for legacy
(pre-Sierra) mainnet contracts. Cairo 1 still gates on §3
executor integration.
Copilot AI review requested due to automatic review settings June 1, 2026 10:30
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 09e10805b3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread package.json
"qa:live:matrix": "node scripts/perf/live-qa-matrix.mjs",
"probe:testnets": "node scripts/testnet-probe.js",
"simulator:server": "node scripts/simulator-bridge.mjs",
"starknet-sim:build": "cargo build --release --manifest-path starknet-sim/Cargo.toml",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Add submodule metadata before wiring build scripts

This script depends on starknet-sim/Cargo.toml, but the commit only adds starknet-sim as a gitlink and there is no .gitmodules entry for it (in this checkout git submodule status reports no mapping, and the directory has no Cargo.toml). In a fresh clone or CI checkout the simulator source will not be populated, so npm run starknet-sim:build fails before anyone can build or run the new bridge. Please add the submodule mapping or vendor the simulator source alongside the script.

Useful? React with 👍 / 👎.

// (Timidan/starknet-sim gitlink) is the backing executor. `wallet` stays
// off here — wallet connection for Starknet is owned by the
// bridges/StarknetBridge picker, not the generic capability gate.
starknet: new Set<ChainCapability>(["simulation", "tx-replay"]),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Do not expose EVM builder via Starknet simulation capability

Giving Starknet the generic simulation capability also passes the /builder registry entry because TOOL_REGISTRY assigns both /builder and /simulations to that same capability. As a result, navigating to /starknet/builder (or using the Starknet nav tab) renders the EVM TransactionBuilderHub under the Starknet family instead of being blocked/redirected to the Starknet trace page. Split the capabilities or gate the builder by an EVM-only capability so Starknet only enables /starknet/simulations.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Bootstraps a multi-chain (EVM/Starknet/Solana) app shell with a Starknet simulator bridge, new family-scoped routing, and adapter-based wallet/earn abstractions so Starknet/SVM features can land without pulling EVM SDKs into the generic shell.

Changes:

  • Adds Starknet simulator client UI (/starknet/simulations), plus Vite/Vercel proxying and CSP wiring for the starknet-sim bridge.
  • Introduces chain-family routing utilities and capability-gated tool navigation (/evm/*, /starknet/*, /solana/*) with legacy EVM path redirects.
  • Refactors LI.FI Earn to route via a new EarnAdapter boundary and adds global multi-wallet management with per-family bridges.

Reviewed changes

Copilot reviewed 106 out of 107 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
vite.config.ts Adds wasm support, ethers v5/v6 split routing for starkzap/avnu, CSP injection, and a Starknet sim dev proxy.
vercel.json Routes /api/starknet-sim/* to a new Vercel proxy function.
src/utils/env.ts Adds getStarknetSimBridgeUrl() with disabled/off semantics.
src/types/chain.ts Extends legacy Chain shape with chainFamily + chainKey for EVM routing.
src/shims/tongo-sdk.ts Provides a stub @fatsolutions/tongo-sdk export for starkzap optional paths.
src/services/SimulationHistoryService.ts Bumps IndexedDB schema to v3 and backfills chain family/key metadata.
src/routes/familyRoutes.ts Adds family prefixes, legacy path redirect resolver, and prefix helpers.
src/main.tsx Splits QueryClient from wagmi/RainbowKit to avoid loading EVM stack globally.
src/hooks/useActiveChainFamily.ts Derives active chain family from the URL.
src/hooks/useActiveChainDescriptor.ts Returns an active chain descriptor (EVM mainnet default; null for others).
src/features/earn/shell/UnsupportedFamilyCard.tsx Adds “unsupported family” UI for Earn on non-EVM families.
src/features/earn/shared/normalizeEarnVault.ts Normalizes Earn vaults to canonical chainKey.
src/features/earn/shared/formatUnits.ts Adds a local bigint→decimal formatter to avoid family SDK coupling.
src/features/earn/routes/EarnFeatureRoute.tsx Routes Earn per family and mounts the appropriate adapter provider.
src/features/earn/context/EarnAdapterContext.tsx Adds Earn adapter context with a safe no-provider fallback.
src/features/earn/adapters/svm/SvmEarnAdapterProvider.tsx Adds an SVM Earn adapter provider stub wiring.
src/features/earn/adapters/svm/svmEarnAdapter.stub.ts Implements a non-functional SVM adapter stub with explicit errors.
src/features/earn/adapters/evm/idleScan.ts Adds EVM multicall-based idle balance scanner for Earn concierge.
src/features/earn/adapters/evm/evmSubmit.ts Adds adapter submit/wait helpers built on @wagmi/core.
src/features/earn/adapters/evm/evmReads.ts Adds async ERC20/native balance + allowance reads via ethers v5.
src/features/earn/adapters/evm/evmPrepare.ts Prepares Composer deposit/withdraw steps and optional approvals.
src/features/earn/adapters/evm/evmExplorer.ts Adds explorer URL resolution for EVM txs via chain registry.
src/features/earn/adapters/evm/EvmEarnAdapterProvider.tsx Injects wagmi config/account into the EVM Earn adapter.
src/features/earn/adapters/evm/evmEarnAdapter.ts Implements the EVM Earn adapter against the new adapter interface.
src/features/earn/adapter/types.ts Introduces the SDK-neutral Earn adapter contract and typed envelopes.
src/contexts/WalletManager.tsx Adds global, SDK-free wallet state manager and bridge handle registry.
src/contexts/SimulationContext.tsx Scaffolds cross-family simulation context types and backfills EVM fields.
src/contexts/NetworkConfigContext.tsx Exposes Starknet/Solana RPC resolution + persistence APIs.
src/config/queryClient.ts New shared QueryClient module to avoid EVM dependency fan-out.
src/components/wallet/SolanaWalletConnect.tsx Adds a Solana wallet connect button wrapper.
src/components/wallet/GlobalWalletPicker.tsx Adds a global multi-family wallet picker UI (SDK-free).
src/components/wallet/bridges/StarknetBridge.tsx Adds Starknet bridge/picker that forwards connection state to manager.
src/components/wallet/bridges/SolanaBridge.tsx Adds Solana bridge that toggles wallet-adapter modal + forwards state.
src/components/wallet/bridges/EvmBridge.tsx Adds EVM bridge that opens RainbowKit modal + forwards connection state.
src/components/transaction-builder/types.ts Ensures mapped EVM chains include chainFamily + chainKey.
src/components/transaction-builder/TransactionReplayView.tsx Stamps replay contexts with chainFamily/chainKey.
src/components/TopBar.tsx Replaces RainbowKit-only wallet button with global picker + family selector.
src/components/StarknetSimBridgeStatus.tsx Adds footer/status indicator polling Starknet sim bridge health.
src/components/starknet/TxTraceView.tsx Adds Starknet tx-hash trace UI powered by the simulator bridge.
src/components/starknet/StateDiffTabs.tsx Adds Starknet state diff presentation tabs.
src/components/starknet/StarknetSimulationsPage.tsx Adds Starknet simulations page with tab scaffolding.
src/components/starknet/InvocationTree.tsx Adds invocation tree renderer with depth clamping.
src/components/smart-decoder/useDecodeHandlers.ts Ensures fallback EVM chain objects include family/key fields.
src/components/smart-decoder/DecoderDialogs.tsx Ensures fallback EVM chain objects include family/key fields.
src/components/SimulationResultsPage.tsx Updates history navigation path to /evm/simulations.
src/components/SimulationHistoryPage.tsx Updates “new simulation” navigation path to /evm/builder.
src/components/simulation-results/useSimulationPageState.ts Updates navigation paths to /evm/builder for resim/back actions.
src/components/simple-grid/layout/ContractColumn.tsx Updates simulation history link to /evm/simulations.
src/components/simple-grid/hooks/useSimulationState.tsx Stamps saved simulation contexts with chainFamily/chainKey.
src/components/shared/NetworkSelector.tsx Renames ExtendedChain icon mapping to iconKey (avoids chainKey clash).
src/components/shared/FamilySelector.tsx Adds chain-family switcher for the app chrome.
src/components/RpcSettingsStarknetPanel.tsx Adds Starknet RPC settings UI and persistence.
src/components/RpcSettingsSolanaPanel.tsx Adds Solana RPC settings UI and persistence.
src/components/RpcSettingsModal.tsx Adds family tabs and embeds Starknet/Solana settings panels.
src/components/PersistentTools.tsx Capability-gates tool routing by family and adds Starknet simulations dispatch.
src/components/Navigation.tsx Capability-gates navigation by active family and prefixes routes.
src/components/MobileDrawer.tsx Capability-gates drawer tools by family and prefixes routes.
src/components/integrations/lifi-earn/WithdrawFlow.tsx Starts routing tx submission through the EVM Earn adapter in execution path.
src/components/integrations/lifi-earn/types.ts Adds canonical chainKey to EarnVault type.
src/components/integrations/lifi-earn/PositionsView.tsx Reads wallet connection from EarnAdapter context instead of wagmi.
src/components/integrations/lifi-earn/LifiEarnPage.tsx Reads wallet connection from EarnAdapter context instead of wagmi.
src/components/integrations/lifi-earn/IdleYieldBanner.tsx Reads wallet connection from EarnAdapter context instead of wagmi.
src/components/integrations/lifi-earn/hooks/useTokenBalance.ts Refactors balance reads to EVM adapter read helpers.
src/components/integrations/lifi-earn/hooks/useTokenAllowance.ts Refactors allowance reads to EVM adapter read helpers.
src/components/integrations/lifi-earn/earnApi.ts Normalizes Earn vaults from proxy response to include chainKey.
src/components/integrations/lifi-earn/DepositFlow.tsx Starts routing tx submission through the EVM Earn adapter in execution path.
src/components/integrations/lifi-earn/concierge/intent/IntentPanel.tsx Reads wallet connection from EarnAdapter context instead of wagmi.
src/components/integrations/lifi-earn/concierge/IdleSweepPanel.tsx Reads wallet connection from EarnAdapter context and updates chain icon key usage.
src/components/integrations/lifi-earn/concierge/IdleAssetsTable.tsx Switches formatting helper to local formatUnits.
src/components/integrations/lifi-earn/concierge/hooks/useVaultRecommendations.ts Switches formatting helper to local formatUnits.
src/components/integrations/lifi-earn/concierge/hooks/useIdleBalances.ts Reuses shared EVM idle scan implementation.
src/components/integrations/lifi-earn/concierge/hooks/fetchAssetPrices.ts Switches formatting helper to local formatUnits.
src/components/integrations/IntegrationsHub.tsx Routes LI.FI Earn via the family-aware Earn feature route.
src/components/HomePage.tsx Updates quick actions to EVM-prefixed routes.
src/components/contract/ContractAddressInput.tsx Ensures derived chains include EVM family/key fields.
src/chains/types/svm.ts Adds branded Solana types and parsing helpers.
src/chains/types/starknet.ts Adds branded Starknet types and parsing helpers.
src/chains/types/index.ts Adds cross-family chain descriptor/types barrel and key utilities.
src/chains/types/evm.ts Adds branded EVM types and parsing helpers.
src/chains/toolRegistry.ts Adds canonical tool registry with capability gates.
src/chains/starknet/starkzapClient.ts Adds singleton Starkzap client wrapper for Starknet wallets.
src/chains/starknet/simulatorTypes.ts Adds typed bridge schema mirrors for starknet-sim responses/requests.
src/chains/starknet/simulatorClient.ts Adds Starknet simulator HTTP client with typed errors/timeouts.
src/chains/registry.ts Stamps legacy chain registry with chainFamily + chainKey and adds lookup by key.
src/chains/providers/StarknetFamilyProviders.tsx Adds Starknet family provider wrapper (pass-through).
src/chains/providers/SolanaFamilyProviders.tsx Adds Solana wallet-adapter provider stack using resolved RPC endpoint.
src/chains/providers/EvmFamilyProviders.tsx Adds EVM provider wrapper to scope wagmi/RainbowKit under /evm/*.
src/chains/evm/wallet.ts Adds EVM wallet session builder for adapter boundary.
src/chains/evm/simulation.ts Re-exports EVM simulation functions behind a family facade.
src/chains/evm/rpc.ts Adds EVM RPC client wrapper around existing provider pool.
src/chains/evm/index.ts Adds EVM family barrel exports.
src/chains/evm/explorer.ts Adds EVM explorer client wrapper using legacy registry helpers.
src/chains/capabilities.ts Adds default per-family capability sets used for UI/tool gating.
src/chains/adapters/types.ts Defines chain adapter boundary types and wallet session typing.
src/chains/adapters/index.ts Adds adapter registry and support checks.
src/chains/adapters/evmAdapter.ts Implements the EVM adapter’s address parsing/formatting.
scripts/check-family-imports.mjs Adds CI/dev guard to prevent importing family SDKs from generic shell code.
package.json Adds Starknet/Solana deps, ethers v6 alias, simulator scripts, and family-import check script.
index.html Extends CSP connect-src/frame-src for Cartridge/Solana/Starknet RPCs and bridge connectivity.
api/starknet-sim-proxy.ts Adds Vercel proxy for Starknet simulator bridge with CORS + SSE support.
.env.example Documents Starknet simulator bridge env vars and proxy configuration.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread vite.config.ts
Comment on lines +219 to +223
// wasm() handles @cartridge/controller's WASM module. Do NOT add
// vite-plugin-top-level-await — its transform rewrites `export
// function foo()` to an assignment without reordering preceding
// `foo.something = ...` statements, breaking wagmi's `injected.type`
// pattern at runtime. Native TLA support via `build.target: esnext`.
Comment thread vite.config.ts
Comment on lines +263 to +266
build.onResolve({ filter: /^ethers$/ }, async (args) => {
if (!args.importer.includes("/@avnu/avnu-sdk/")) return;
const resolved = await build.resolve("ethers-v6", {
resolveDir: args.resolveDir,
Comment thread package.json
Comment on lines 97 to +99
"vite": "^5.4.19",
"vite-plugin-top-level-await": "^1.6.0",
"vite-plugin-wasm": "^3.6.0",
Comment thread vite.config.ts
Comment on lines +219 to +223
// wasm() handles @cartridge/controller's WASM module. Do NOT add
// vite-plugin-top-level-await — its transform rewrites `export
// function foo()` to an assignment without reordering preceding
// `foo.something = ...` statements, breaking wagmi's `injected.type`
// pattern at runtime. Native TLA support via `build.target: esnext`.
Comment thread vite.config.ts
Comment on lines +263 to +266
build.onResolve({ filter: /^ethers$/ }, async (args) => {
if (!args.importer.includes("/@avnu/avnu-sdk/")) return;
const resolved = await build.resolve("ethers-v6", {
resolveDir: args.resolveDir,
Comment thread package.json
Comment on lines 97 to +99
"vite": "^5.4.19",
"vite-plugin-top-level-await": "^1.6.0",
"vite-plugin-wasm": "^3.6.0",
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants