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

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.

Timidanand 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.
CopilotAI review requested due to automatic review settings June 1, 2026 10:30

@chatgpt-codex-connectorchatgpt-codex-connectorBot left a comment

Copy link
Copy Markdown

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 threadpackage.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 👍 / 👎.

CopilotAI left a comment

Copy link
Copy Markdown

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

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

Comment threadvite.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 threadvite.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 threadpackage.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 threadvite.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 threadvite.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 threadpackage.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 freeto 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

@Timidan