Yaci Viewer Script Lab: inspect, re-run and debug Plutus scripts with the julc WASM engine (umbrella)

未关闭
#207 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
28/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
活跃
技术栈
javascript, playwright, wasm

调研方向

Start with PR 9 and the viewer transaction-decoder entry points, using existing replay and debugger code as integration points. Run the Playwright Script Lab coverage with PW_CHANNEL=chrome; the supplied issue does not name the PR 9 files or decoder tests. Done means pasted signed or unsigned transaction CBOR is decoded, its spent inputs are resolved, and every redeemer runs against chain state with an explanation of submission failures.

由索引模型根据 Issue 内容生成。

描述

enhancement

Goal

Make Yaci Viewer a debugger for the chain: any Plutus script execution, on a local devnet or on Mainnet, can be inspected, re-run, stepped through, changed and shared as a link, in the browser.

Two things make this possible:

  • Engine: the julc WebAssembly engine, a Plutus VM with a step debugger that runs in a web worker.
  • Data: Yaci Store already holds everything needed to rebuild a past transaction: spent UTxOs, scripts, datums, redeemers, and each epoch's cost models and protocol parameters.

Principles

  • julc is never built here. The release is pinned with its SHA-256 (applications/viewer/julc.lock.json) and installed at build time.
  • Nothing loads until the user asks. No page downloads the engine until someone clicks decode or run (or opts in to automatic runs).
  • Honest results. Every run says what couldn't be reproduced, so a mismatch is never mistaken for a script bug.

Spike results (Mainnet, 17 Oct 2026)

We rebuilt 16 recent Mainnet redeemers from Yaci Store data alone, with no tx CBOR, and ran them in the browser:

Outcome Redeemers
Matched the on-chain budget exactly 7
Passed within the declared budget 5
Passed, slightly above the declared budget 1
Failed (all "withdraw-zero" scripts; see julc#244, U1) 3

Each run took 5–35 ms, and the engine loads in under 1 s.

Stacked PRs

Each PR is stacked on the previous one. They depend on the viewer redesign (#204).

PR 1 – Foundation and script code view: #206 (in review)
  • julc.lock.json and scripts/fetch-julc.mjs: download the pinned release, verify its SHA-256, unpack safely; JULC_SKIP / JULC_ARCHIVE
  • Docker, Earthly and npm builds include the engine, served compressed (about 5.5 MB brotli)
  • $lib/julc/engine: lazy shared worker client that restarts after timeouts; WasmGC and exnref checked before any download
  • Script page Code panel:
    • readable UPLC with search, wrap, copy and download
    • builtins used (click to find them)
    • size, terms, Plutus Core version, parameters applied
    • hash verification
  • Virtualised code view, for very large scripts
  • Tests: untar safety, highlighting, Playwright script-lab.spec.ts (PW_CHANNEL=chrome)
  • Decompiled Java view: dropped, because julc's decompiler output isn't idiomatic Java
PR 2 – Re-run a transaction's scripts: #208 (in review)
  • Rebuild the transaction from Yaci Store data:
    • inputs and reference inputs in ledger order
    • inline and hashed datums
    • redeemer data
    • withdrawals, mint, signers, votes
    • validity range (slot → POSIX time; Mainnet, preprod and preview constants; devnet /genesis)
  • Use the epoch's own cost model (cost_models_raw), protocol version and tx limits
  • Script runs on the transaction page: every redeemer re-run in the browser, showing:
    • status
    • CPU and memory against the declared ex-units
    • a Reproduced exactly badge, or reproduced with the builder's margin
    • traces, the error and the last builtins
  • What the validator saw: the ScriptContext as a tree, JSON or CBOR
  • Failed (phase-2 invalid) transactions flagged up front
  • Fidelity notes per run (what the viewer corrected, and known gaps)
  • One "Run Script Lab automatically" preference, shared with decode
  • Viewer-side workarounds for julc context gaps (U1, U7–U10 in bloxbean/julc#244): value order, the complete redeemer map, datums given by hash, V1 list shapes
  • Tests: the transaction rebuild against recorded Mainnet fixtures, context fixes, the CBOR encoder, Playwright with a tx hash
  • A devnet script-transaction test (the local devnet only had a proposal script)
  • Mainnet results: 108/108 recent runs pass (80 exact, 5 with margin); 2023 Plutus V1 history is partly reproduced (8/17)
PR 3 – Time-travel debugger: #209 (in review)
  • Debugger page /transactions/{hash}/debug/{purpose}/{index}, replaying the run with the same corrected context as the Scripts tab
    • step, over, out, continue, back, start and end; keyboard shortcuts
    • timeline scrubber (click or drag) with trace and failure markers
    • breakpoints on lines (click a line number), builtins, traces and failure
    • now (phase, term, value, why it stopped), budget per step against the run and declared, environment, frames, traces
  • Current term highlighted in the UPLC and followed vertically and horizontally
  • Shareable step links (?step=N, "Link to this step")
  • "Debug the failure" (?at=failure) from failed re-runs; Debug links on every re-run
  • Failed script transactions list: moved to the Yaci Store asks (no endpoint for phase-2 failures)
PR 4 – What-if lab (fork a transaction): #210 (in review)
  • Fork this transaction (/transactions/{hash}/fork): edit the redeemers, spent datums (JSON or CBOR), signers, validity range, outputs, mint, withdrawals and fee; every script re-runs as you type
  • Compare against the original run: status, CPU/memory change, "now passes / now fails"
  • Protocol and cost model comparison: another epoch's cost model, protocol 10 or 11 (with a note when an old cost model is shorter)
  • Export as test fixture: JSON with script, target, cost model, VM arguments, ScriptContext CBOR, expected result and the fork's edits
  • Debug forked runs inline
  • julc testkit (Java) snippet in the export: deferred, as loading a script from CBOR spans julc modules
PR 5 – Devnet powers and script insights: #211 (in review)
  • Live script monitor (/scripts/monitor): re-run new script transactions as their blocks arrive (all on devnets, sampled on public networks), with budget chips, the share of the tx limits and a flag near them; links to the debugger and fork lab
  • Script activity on the script page: recent executions, median and peak budgets, a CPU chart, redeemer variants with examples, Debug links
  • Blueprint-typed data: attach a CIP-57 plutus.json (kept in the browser); datums and redeemers get a Typed view with type, variant and field names, and activity names redeemer variants
  • Auto-load blueprints for devnet projects (needs a way to point the viewer at a project folder)
PR 6 – Guardrail check: #212 (in review)
  • Guardrail check (/governance/guardrail): draft a parameter change or treasury withdrawal and run the constitution's guardrail on it as you type; per-parameter verdicts, debugger, shareable link, any script (hash or pasted CBOR)
  • Proposal pages: proposed changes against current values, and the proposal's guardrail run
  • Proposing scripts replayed on the Scripts tab, debugger and fork lab: the viewer encodes the governance action (julc pre18 leaves a parameter change empty)
  • Mainnet results: 49/49 guardrail runs pass (25 exact, 1 with margin); protocol 10 runs use ~31k more CPU than declared (memory exact), apparently protocol 10 builtin costing that julc doesn't apply
PR 7 – Validator lab: #213 (in review)
  • Run my validator against chain state (/scripts/lab): Java compiled in the browser (diagnostics, parameters, UPLC, plutus.json), a pasted compiled script, or one on chain; spend a real UTxO as if locked at it, mint, or withdraw; redeemer and datum templates, typed views, signers, validity, withdrawals, outputs
  • Live verdict, budget and traces; a rejected Java validator shows the line it failed on; UPLC debugger, experimental Java source debugger, test fixture export
  • Mainnet: a batcher run on the UTxO it really spent reproduces its on-chain budget exactly
  • Richer Java source debugging (line stepping, locals) as julc's source-debug build matures
PR 8 – Replays from stored transaction CBOR: #214 (in review)
  • Transaction decoder (Alonzo to Conway): body, witnesses, outputs, certificates, votes, proposals, redeemers, metadata; ids and hashes from the exact bytes
  • Replays (Scripts tab, debugger, fork lab, monitor) use the stored CBOR when the store has it (/txs/{hash}/cbor/hex), else rebuild from JSON; every replay shows its source
  • CBOR tab on transaction pages when the store saved the bytes (hash check, field tree, download)
  • Mainnet: 14 transactions replay from CBOR; a V2 mint with a 2^63−1 quantity (rounded in the store's JSON) now reproduces exactly
PR 9 – Transaction decoder and pre-submit check
  • Decode pasted transaction CBOR (unsigned or signed), with spent inputs resolved from the chain
  • "Why won't my tx submit?": run every redeemer of a pasted transaction against chain state before submitting
Busy addresses on a large Yaci Store: #215 (in review)

Not Script Lab, but stacked here so the public viewer gets it. Address and stake pages render at once and stream their slow parts. There are no /amounts calls: the balance is summed from UTxOs, as a lower bound for busy addresses. A server-side guard skips endpoints that timed out, shares requests in flight and caps slow calls, so a busy address no longer piles up runaway queries on the store (bloxbean/yaci-store#1269).

Yaci Store analytics for busy stake accounts: #216 (in review)

This applies where the store has the analytics query API; the devkit's store returns 404, so nothing changes there. A busy stake account's controlled stake, pool and rewards come from analytics when the regular endpoints are too slow. Address pages don't use analytics: the answers would be partial, and DuckDB isn't meant to serve page views.

Analytics charts: #217 (in review)

Where the store has analytics:

  • Dashboard: transactions, script runs, script CPU and fees per day; treasury and reserves; pools making blocks; the most-run scripts.
  • Governance: DRep voting power.
  • Script pages: usage over 90 days.
  • Pool and stake pages: history over 50 epochs.

Answers are cached on the viewer's server and served while they refresh.

Names on Mainnet: #218 (in review)

On Mainnet only (nothing is fetched on the devkit or testnets):

  • dApp labels for scripts, from Strica's and Cardano Fans' registries.
  • DRep names, pool tickers and governance action titles, from their own metadata. A name is kept only when its document matches the hash on chain.
  • Token tickers and decimals, from the Cardano token registry.

Names load in the background, are saved to JSON so a restart has them at once, and refresh on a schedule.

Address pages on the Blockfrost-compatible API: #219 (in review)

Where the store has the Blockfrost-compatible API (not the devkit's store), address pages read their balance, UTxOs and transactions from it. Its queries stop after 15 s on the store, so a busy address leaves nothing running. Addresses with more than 500 UTxOs now show an exact balance.

Blocked on julc (bloxbean/julc#244)
  • Faithful replay of multi-validator transactions (withdraw-zero): worked around in the viewer (#208); U1 would remove the workaround
  • Ledger-exact contexts from julc (U7–U10: value order, datums given with a hash, V1 list shapes, witness datums), so the viewer can drop its patching
  • Better Plutus V1 (pre-2023) replay: julc V1/V2 translation fixes after 0.1.0-pre18
  • "Why won't my tx submit?": moved to PR 9 (the viewer decodes the CBOR itself, so U2 isn't needed)
  • Byte-exact replay from stored tx CBOR: done in the viewer (#214), no julc change needed
  • Budget heat map: CPU and memory by builtin and code region; needs a profiling API (U3)
  • More certificate kinds in replays (U4)
  • "Open in julc playground" deep link (U6)
  • Protocol 10 builtin costing (U11, julc#244 comment): protocol 10 replays use ~31k more CPU than the ledger

Dependencies outside this repo

  • DevKit stores tx CBOR on devnets: #205
  • Mainnet playground store: enable store.transaction.save-cbor
  • Yaci Store: speed up /blockfrost/scripts/{hash}/redeemers on Mainnet (it times out; script activity needs it)
  • Yaci Store: list phase-2 failed transactions (invalid = true), for a "Failed script transactions" page in the viewer
  • Yaci Store: CORS on /blockfrost/* endpoints of the devnet store (the viewer calls them from the browser)

Notes

  • Browser support: julc is a GraalVM Web Image, so it needs WasmGC and exnref: current Chrome, Edge, Firefox or Safari. Playwright's bundled Chromium 128 is too old, so Script Lab browser tests run with PW_CHANNEL=chrome.
  • Upgrading julc: change tag, version, file and sha256 together in julc.lock.json.
主要语言
Java
星标
70
派生
21
PR 合并指标
30 天内没有已合并 PR

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

bloxbean/yaci-devkit 的其他 Issue

查看 bloxbean/yaci-devkit 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。