ton-bug-triage
Original:🇺🇸 English
Translated
19 scripts
Reproduce TON bugs on a local tontester network. Use only when the task involves launching tontester validators, deploying contracts to a local network, or comparing patched validator builds — not for general TON development or testnet interaction.
3installs
Added on
NPX Install
npx skill4agent add ton-blockchain/ton-triage-skill ton-bug-triageTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →TON Bug Triage
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.
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.
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.
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.
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
Workflow 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.mdWorkflow 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.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.
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.
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-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-*
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