ton-bug-triage
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseTON Bug Triage
TON Bug排查
Use this skill when the job is to prove something on a local network, not just to launch validators.
tontesterTypical triggers:
- deploy a contract and trigger a bug with an internal message
- compare baseline and probing validator builds
- verify a crash, liveness failure, malformed-packet path, or compatibility claim
- collect maintainer-ready evidence for a local TON repro
The standard is: choose the smallest topology that answers the question, define the success condition before running, and collect enough evidence that the result is interpretable.
仅当需要在本地网络上验证某些问题时使用此技能,而不只是启动验证器。
tontester典型触发场景:
- 部署合约并通过内部消息触发Bug
- 对比基准版本与测试版本的验证器构建
- 验证崩溃、活性故障、畸形数据包路径或兼容性声明
- 收集可提交给维护者的本地TON复现证据
标准流程:选择能解答问题的最小拓扑结构,在运行前定义成功条件,并收集足够的证据以确保结果可解释。
Working Model
工作模型
Keep these paths distinct:
- Skill scripts: files under this skill directory, such as
scripts/run_basic_network.py - Source tree: the real TON checkout passed as
--repo-root - Build directory: binaries and libraries such as ,
validator-engine,create-state, andtonlibjsontolk - Work directory: per-run state, logs, configs, and emitted artifacts
Do not assume the skill directory and the repo are the same thing. The scripts live in the skill. They operate on the repo and build you pass in.
wallet-env.txtThese helpers depend on internals and private APIs. If changes, expect to adjust helper behavior, generated bindings, or command assumptions.
tontestertontester请区分以下路径:
- 技能脚本:此技能目录下的文件,例如
scripts/run_basic_network.py - 源码树:通过传入的真实TON代码仓库
--repo-root - 构建目录:二进制文件和库,如、
validator-engine、create-state和tonlibjsontolk - 工作目录:每次运行的状态、日志、配置和生成的产物
不要假设技能目录与代码仓库是同一目录。脚本存放在技能目录中,它们会对传入的代码仓库和构建版本进行操作。
wallet-env.txt这些辅助工具依赖的内部实现和私有API。如果发生变更,需要调整辅助工具的行为、生成的绑定或命令假设。
tontestertontesterWorkflow Selection
工作流选择
Choose one workflow before running anything:
-
Use this when the bug is reached by deploying a contract, sending an internal message, or delivering a malformed/custom payload to a contract account.
Workflow A — trigger via transaction -
Use this when the bug requires patched validator code, mixed builds, consensus interference, malformed protocol packets, reordered traffic, or deliberately invalid block behavior.
Workflow B — trigger via validator behavior
If a repro touches both, ask one question first: can you trigger it on an unmodified network after a normal deploy/send path? If yes, start with Workflow A. If no, treat it as Workflow B.
在运行任何操作前选择一个工作流:
-
当Bug需要通过部署合约、发送内部消息或向合约账户传递畸形/自定义负载来触发时使用此工作流。
工作流A — 通过交易触发 -
当Bug需要已打补丁的验证器代码、混合构建版本、共识干扰、畸形协议数据包、重排流量或故意的无效区块行为来触发时使用此工作流。
工作流B — 通过验证器行为触发
如果某个复现场景同时涉及两种情况,请先回答一个问题:在未修改的网络中,通过常规部署/发送流程能否触发该Bug?如果可以,从工作流A开始;如果不行,则按工作流B处理。
Core Rules
核心规则
-
Start with the smallest network that can answer the question. Use one validator unless the path needs peers, consensus, or mixed builds.
-
Prefer ordinary deploy/send flow over zerostate edits. If the bug only reproduces after zerostate mutation, say that clearly.
-
Keep baseline and probing builds separate. Usuallyis baseline and
vanilla-build/orbuild/is the modified build.build-probing/ -
Decide the success condition before running. Examples: target, explicit crash marker, process death, active contract account, inspected transaction, or honest-node rejection of a malformed packet.
mc_seqno -
For Workflow B, make the probing node self-immune. Operational meaning: the probing node may emit malformed or adversarial behavior, but it must stay alive until the target effect is observed on the honest nodes. A run is invalid if the probing node dies first and that death could explain the outcome.
-
Record enough evidence to rerun the exact scenario. Keep the run directory, the build directories, the commands, the relevant addresses, and the exported artifacts.
-
Before calling something maintainer-ready, rerun it from a clean checkout or detached worktree with only the intended artifacts.
-
从能解答问题的最小网络规模开始。 除非场景需要节点对等、共识或混合构建版本,否则仅使用一个验证器。
-
优先使用常规部署/发送流程,而非零状态编辑。 如果Bug仅能在零状态修改后复现,请明确说明这一点。
-
分开存放基准版本与测试版本的构建产物。 通常为基准版本,
vanilla-build/或build/为修改后的版本。build-probing/ -
在运行前定义成功条件。 示例:目标、明确的崩溃标记、进程终止、活跃的合约账户、已检查的交易、诚实节点拒绝畸形数据包等。
mc_seqno -
对于工作流B,确保测试节点具备自我免疫能力。 操作层面的含义:测试节点可能会产生畸形或对抗性行为,但必须在诚实节点观察到目标效果前保持存活。如果测试节点先死亡,且该死亡可能影响结果,则本次运行无效。
-
记录足够的证据以重新运行完全相同的场景。 保留运行目录、构建目录、命令、相关地址和导出的产物。
-
在将证据提交给维护者前,从干净的代码检出或独立工作树中重新运行,仅保留必要的产物。
Core Scripts
核心脚本
Prefer the bundled scripts over one-off shell sequences.
-
Launch one or more validators from a single build. Supports
scripts/run_basic_network.py,--emit-wallet-env,--base-port, and--validators.--keep-alive -
Launch baseline and probing validators from different build directories. Use this for malicious-vs-honest experiments, log-based crash detection, and probing-node survival checks.
scripts/run_mixed_network.py -
Compile a
scripts/compile_tolk.pysource to.tolkand materialize the contract code BoC. It hard-fails if the.fifbinary is stale relative to repotolk.HEAD -
Build a deployable
scripts/build_stateinit.pyBoC from code plus optional data and library-dictionary BoCs.StateInit -
Run a
scripts/run_fift_script.pyscript with the correct include paths..fif -
Build and optionally send a wallet-signed message. Use
scripts/wallet_send.pyfor deployment and--init-bocfor arbitrary internal payloads.--body-boc -
Send a prebuilt serialized external message BoC through tonlib without rebuilding it via
scripts/send_boc.py.wallet_send.py -
Normalize and inspect raw and friendly TON address forms when helper inputs need to be cross-checked.
scripts/address_info.py -
Fetch raw account state and dump code/data BoCs for inspection.
scripts/account_state.py -
Run a get-method through tonlib and print JSON.
scripts/get_method.py -
Fetch the latest account transaction, export raw transaction data, and save message body/init-state BoCs when tonlib returns them as
scripts/inspect_latest_transaction.py.msg.dataRaw -
Run a
scripts/run_liteclient.pycommand usinglite-clientor explicit repo/build/config inputs.wallet-env.txt -
Print a BoC cell tree through Fift. Use this for payloads,
scripts/dump_boc.py, exported transaction data, and dumped account code/data.StateInit -
Summarize node liveness and crash markers for a finished or live run directory.
scripts/summarize_run.py -
Known-good end-to-end verifier for the simple wallet path.
scripts/demo_wallet_flow.py
优先使用捆绑脚本而非一次性shell命令序列。
-
从单个构建版本启动一个或多个验证器。支持
scripts/run_basic_network.py、--emit-wallet-env、--base-port和--validators参数。--keep-alive -
从不同的构建目录启动基准版本和测试版本的验证器。用于恶意节点与诚实节点的对比实验、基于日志的崩溃检测和测试节点存活检查。
scripts/run_mixed_network.py -
将
scripts/compile_tolk.py源码编译为.tolk并生成合约代码BoC。如果.fif二进制文件相对于代码仓库tolk版本过期,会直接执行失败。HEAD -
从代码(可选包含数据和库字典BoC)构建可部署的
scripts/build_stateinit.pyBoC。StateInit -
使用正确的包含路径运行
scripts/run_fift_script.py脚本。.fif -
构建并可选发送钱包签名的消息。使用
scripts/wallet_send.py进行部署,使用--init-boc发送任意内部负载。--body-boc -
通过tonlib发送预构建的序列化外部消息BoC,无需通过
scripts/send_boc.py重新构建。wallet_send.py -
当需要交叉检查辅助工具的输入时,标准化并检查原始和友好格式的TON地址。
scripts/address_info.py -
获取原始账户状态并导出代码/数据BoC以供检查。
scripts/account_state.py -
通过tonlib运行get方法并打印JSON结果。
scripts/get_method.py -
获取账户的最新交易,导出原始交易数据,并在tonlib返回
scripts/inspect_latest_transaction.py时保存消息体/初始状态BoC。msg.dataRaw -
使用
scripts/run_liteclient.py或显式的代码仓库/构建/配置输入运行wallet-env.txt命令。lite-client -
通过Fift打印BoC单元格树。用于负载、
scripts/dump_boc.py、导出的交易数据和导出的账户代码/数据。StateInit -
对已完成或正在运行的目录中的节点活性和崩溃标记进行汇总。
scripts/summarize_run.py -
针对简单钱包流程的已知可用端到端验证工具。
scripts/demo_wallet_flow.py
Workflow A
工作流A
Use Workflow A when the trigger is “deploy contract, then send message”.
- Launch a small network with .
--emit-wallet-env - Compile your contract with , or provide a hand-built code BoC from Fift assembly if you are not using Tolk.
scripts/compile_tolk.py - Build deployable with
StateInit. Passscripts/build_stateinit.pyand--data-boconly when the contract actually needs them.--library-boc - Deploy from the funded built-in with
main-wallet. A deploy message that usesscripts/wallet_send.py --init-bocmay also invoke the contract's internal message handler. Check whether the deploy transaction itself changed contract state before sending a separate trigger.--init-boc - Wait for activation.
Prefer plus a contract-specific get-method over assuming one masterchain advance is enough.
account_state.py - Build the trigger body as a BoC when the payload is custom or binary.
is the easiest way to emit a one-off
run_fift_script.py.body.boc - Send the trigger with .
scripts/wallet_send.py --body-bocis the authoritative payload path and overrides--body-boc. If you already have a signed external message BoC, use--commentinstead of rebuilding it withscripts/send_boc.py --boc.wallet_send.pyproves the network is alive. It does NOT prove the transaction succeeded, the deploy activated, or the contract state changed. Always inspect the target account directly.--wait-mc-advance - Observe with and
inspect_latest_transaction.py --out-dir. The exporteddump_boc.pyandtransaction-data.bocare the starting point for cell-level debugging. If the tonlib-based helpers crash (common symptom:in-msg-body.boc), useKeyError: '@extra'as the fallback for all observation steps. Seerun_liteclient.py.references/liteclient_fallback.md
For the full worked sequence, read .
references/contract_deploy_flow.mdFor the simple wallet smoke path only, read .
references/wallet_and_deploy_helpers.md当触发条件为“部署合约,然后发送消息”时使用工作流A。
- 使用启动一个小型网络。
--emit-wallet-env - 使用编译合约,若不使用Tolk,则提供通过Fift汇编手工构建的代码BoC。
scripts/compile_tolk.py - 使用构建可部署的
scripts/build_stateinit.py。 仅当合约确实需要时才传入StateInit和--data-boc参数。--library-boc - 使用从内置的已资助
scripts/wallet_send.py --init-boc进行部署。 使用main-wallet的部署消息也可能调用合约的内部消息处理程序。在发送单独的触发消息前,检查部署交易本身是否已更改合约状态。--init-boc - 等待激活完成。
优先使用加上合约特定的get方法,而非假设主链一次推进就足够。
account_state.py - 当负载为自定义或二进制格式时,将触发消息体构建为BoC。
是生成一次性
run_fift_script.py的最简单方式。body.boc - 使用发送触发消息。
scripts/wallet_send.py --body-boc是权威的负载路径,会覆盖--body-boc参数。 若已有签名的外部消息BoC,请使用--comment而非通过scripts/send_boc.py --boc重新构建。wallet_send.py仅用于证明网络处于活跃状态,不能证明交易成功、部署已激活或合约状态已更改。请始终直接检查目标账户。--wait-mc-advance - 使用和
inspect_latest_transaction.py --out-dir进行观察。 导出的dump_boc.py和transaction-data.boc是单元格级调试的起点。 若基于tonlib的辅助工具崩溃(常见症状:in-msg-body.boc),请使用KeyError: '@extra'作为所有观察步骤的备选方案。详见run_liteclient.py。references/liteclient_fallback.md
完整的操作流程请参阅。
references/contract_deploy_flow.md仅针对简单钱包冒烟测试流程,请参阅。
references/wallet_and_deploy_helpers.mdWorkflow B
工作流B
Use Workflow B when the trigger is “modify validator behavior, then observe honest-node reaction”.
- Snapshot the baseline build before probing changes.
- Patch the probing build only, and gate every behavioral change behind explicit environment variables.
TON_PROBING_* - Choose a mixed topology and explicit success and failure conditions.
Use ,
--success-log,--failure-log, and--require-node-alivedeliberately.--require-node-dead - Run the mixed network with .
scripts/run_mixed_network.py - Confirm both sides of the claim: probing markers were hit, and the honest-node effect happened or did not happen.
- Summarize the run with , then inspect specific logs manually only where the summary points.
scripts/summarize_run.py
For common patch shapes, read .
references/probing_patterns.mdFor an end-to-end example, read .
references/bug_hunt_example.md当触发条件为“修改验证器行为,然后观察诚实节点的反应”时使用工作流B。
- 在进行测试修改前,对基准版本的构建产物创建快照。
- 仅修改测试版本的构建产物,并将所有行为变更通过显式的环境变量进行控制。
TON_PROBING_* - 选择混合拓扑结构,并明确成功和失败条件。
有意使用、
--success-log、--failure-log和--require-node-alive参数。--require-node-dead - 使用启动混合网络。
scripts/run_mixed_network.py - 验证声明的正反两面: 测试标记已触发,且诚实节点的效果已发生或未发生。
- 使用汇总运行结果,仅在汇总结果指向的位置手动检查特定日志。
scripts/summarize_run.py
常见的补丁形式请参阅。
references/probing_patterns.md端到端示例请参阅。
references/bug_hunt_example.mdNegative Result
阴性结果
A valid “did not reproduce” is still useful evidence. Treat a run as a real negative result only if all of the following are true:
- the selected workflow actually executed its trigger path
- the relevant probing or trigger markers were present
- the network stayed healthy enough that the absence of the bug is meaningful
- the observation step looked at the right account, transaction, or node logs
- the timeout or seqno target was reached without the target effect
Stop iterating and report a negative result when a clean rerun gives the same outcome and the remaining changes are only minor parameter churn.
有效的“未复现”结果也是有用的证据。仅当满足以下所有条件时,才将某次运行视为真实的阴性结果:
- 所选工作流已实际执行其触发路径
- 相关的测试或触发标记已存在
- 网络保持足够健康,Bug未出现的结果具备意义
- 观察步骤已检查正确的账户、交易或节点日志
- 已达到超时或seqno目标,但未出现预期效果
当干净的重新运行给出相同结果,且剩余变更仅为次要参数调整时,停止迭代并报告阴性结果。
Iteration And Debugging
迭代与调试
-
Iffails with a stale-build error, rebuild
compile_tolk.pyfirst. The exact fix is usuallytolk.ninja -C <build-dir> tolk -
If a deploy appears to succeed but the destination still looks empty, check too-early observation first. Wait for activation instead of assuming the deploy path is broken.
-
If a contract is active but the expected get-method fails, verify the method id and the initial data layout before changing the network topology.
-
Ifshows the wrong payload, dump both the original trigger BoC and the exported
inspect_latest_transaction.pyand compare their cell trees.in-msg-body.boc -
If probing markers are missing in Workflow B, the environment variables did not reach the node or the patched code path never executed.
-
If the probing node dies before the target effect is observed, the run is invalid.
-
若因构建过期错误失败,请先重新构建
compile_tolk.py。 通常的修复命令是tolk。ninja -C <build-dir> tolk -
若部署看似成功,但目标账户仍为空,请首先检查是否观察过早。 等待激活完成,而非假设部署流程存在问题。
-
若合约已激活,但预期的get方法执行失败,请先验证方法ID和初始数据布局,再更改网络拓扑结构。
-
若显示错误的负载,请导出原始触发BoC和导出的
inspect_latest_transaction.py并对比它们的单元格树。in-msg-body.boc -
若工作流B中测试标记缺失,说明环境变量未传递到节点,或补丁代码路径从未执行。
-
若测试节点在观察到目标效果前死亡,则本次运行无效。
Evidence Standard
证据标准
Record enough to support the claim:
- exact run directory
- build directories used
- success condition used
- relevant launcher and helper commands
- target addresses or node names
- exported transaction and BoC artifacts for Workflow A
- node liveness and log markers for Workflow B
For Workflow A, remember that is only a liveness hint; confirm success from the target account or transaction.
--wait-mc-advance记录足够的信息以支持声明:
- 精确的运行目录
- 使用的构建目录
- 使用的成功条件
- 相关的启动器和辅助工具命令
- 目标地址或节点名称
- 工作流A的导出交易和BoC产物
- 工作流B的节点活性和日志标记
对于工作流A,请记住仅为活性提示;需从目标账户或交易确认是否成功。
--wait-mc-advanceTroubleshooting
故障排除
- If is missing, use
python.python3 - If bindings are missing, the helpers usually generate them from
tonapi.test/tontester/generate_tl.py - If a helper is copied outside the repo, keep passing the real repo as ; includes and generated artifacts come from the repo, not the skill folder.
--repo-root - If tonlib-based scripts (,
account_state.py,get_method.py,inspect_latest_transaction.py) crash withwallet_send.py --auto-seqnoor similar tonlib wrapper errors, the local tonlib build has a compatibility issue. Fall back toKeyError: '@extra'for inspection and uselite-clientwith manualwallet_send.pyinstead of--seqno. See--auto-seqnofor the shared fallback flow.references/liteclient_fallback.md - If points at
vanilla-build/CMakeCache.txt, treatbuild/as invalid and recreate it. Do not trust a build tree that reconfigures into the wrong directory.vanilla-build - Do not assume is present in the passed build directory. Some checkouts only have
lite-client,create-state, andtonlibjsonbuilt.tolk - If disk is full, clear old directories before retrying.
run-*
- 若缺少命令,请使用
python。python3 - 若缺少绑定,辅助工具通常会从
tonapi生成它们。test/tontester/generate_tl.py - 若辅助工具被复制到代码仓库外,请继续传入真实的代码仓库路径作为;包含文件和生成的产物来自代码仓库,而非技能目录。
--repo-root - 若基于tonlib的脚本(、
account_state.py、get_method.py、inspect_latest_transaction.py)因wallet_send.py --auto-seqno或类似的tonlib包装器错误崩溃,说明本地tonlib构建存在兼容性问题。请改用KeyError: '@extra'进行检查,并使用lite-client的手动wallet_send.py参数而非--seqno。 共享的备选流程请参阅--auto-seqno。references/liteclient_fallback.md - 若指向
vanilla-build/CMakeCache.txt,则build/视为无效,需重新创建。不要信任配置到错误目录的构建树。vanilla-build - 不要假设传入的构建目录中存在。部分代码仓库仅构建了
lite-client、create-state和tonlibjson。tolk - 若磁盘已满,请在重试前清理旧的目录。
run-*
References
参考文档
-
Read this for the proven simple-wallet smoke path.
references/wallet_and_deploy_helpers.md -
Read this for the generic Workflow A compile, deploy, trigger, inspect path.
references/contract_deploy_flow.md -
Read this when tonlib-based helpers fail and Workflow A needs
references/liteclient_fallback.mdinspection or manual wallet seqno handling.lite-client -
Read this when designing Workflow B code changes.
references/probing_patterns.md -
Read this when a run completed but the outcome is unclear.
references/diagnostic_checklist.md -
Read this for a concrete mixed-network negative-result example.
references/bug_hunt_example.md
-
针对已验证的简单钱包冒烟测试流程的文档。
references/wallet_and_deploy_helpers.md -
通用工作流A的编译、部署、触发、检查流程文档。
references/contract_deploy_flow.md -
当基于tonlib的辅助工具失败时,工作流A使用
references/liteclient_fallback.md进行检查和手动钱包seqno处理的备选流程文档。lite-client -
设计工作流B代码变更时的参考文档。
references/probing_patterns.md -
当运行完成但结果不明确时的参考文档。
references/diagnostic_checklist.md -
混合网络阴性结果的具体示例文档。
references/bug_hunt_example.md