-
Notifications
You must be signed in to change notification settings - Fork 2
[NONEVM-2624] TON Trace Explorer #227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
3ecbb11
to
114c118
Compare
9439517
to
1f5bc38
Compare
e305b02
to
a3b4789
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a comprehensive trace explorer for TON blockchain transactions with multiple visualization options and enhanced debugging capabilities. The changes include message decoding infrastructure, visualization frameworks, and dependency updates.
Key changes:
- New trace explorer CLI tool with tree and sequence diagram visualization
- Message decoding framework with support for jetton and CCIP contracts
- Refactored jetton package structure with separate wallet/minter packages
- Updated dependencies and removed obsolete code
Reviewed Changes
Copilot reviewed 45 out of 49 changed files in this pull request and generated 4 comments.
Show a summary per file
File | Description |
---|---|
pkg/ton/debug/explorer/explorer.go | Core explorer implementation with network connection and trace visualization |
pkg/ton/debug/pretty_print.go | Message decoding and debugging framework |
pkg/ton/debug/visualizations/sequence/sequence_diagram.go | Sequence diagram visualization using Mermaid |
pkg/ton/debug/visualizations/tree/tree_diagram.go | Tree-based trace visualization |
pkg/ton/tracetracking/message.go | Added SrcAddr/DstAddr fields to OutgoingExternalMessages |
pkg/bindings/jetton/wallet/codec.go | New jetton wallet message codecs and structures |
pkg/bindings/jetton/minter/codec.go | New jetton minter message codecs and structures |
integration-tests/jetton/jetton_test.go | Updated tests to use new debugger and package structure |
go.mod | Dependency updates including new visualization library |
staging-messaging-test/go.mod | Dependency version updates |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have some general comments.
- Have you considered any mechanisms to ensure this debugger framework continues to work even when contracts or bindings are modified (e.g., debugger unit or integration tests)?
- It seems that each contract binding is kept as a pure off-chain representation(good), but a “codec” file has been added. Could you explain why that's separated into individual files? In some cases, the opcodes are defined in the original files, while in others, they appear in the codec files.
pkg/ton/codec/builder.go
Outdated
@@ -0,0 +1,31 @@ | |||
package codec |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems this file is wrapping tlb.LoadFromCell
. Could you clarify why this wrapper is necessary? We should also confirm whether there’s been alignment with the team that originally developed the binding. The concept of a "codec" already exists in our system. cc. @archseer @huangzhen1997
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TBH, it is not really necesary for the explorer, but I consider it makes for a more idiomatic usage, with an api similar to what we are doing in TS bindings. Still, I will remove this from this PR and put it in a separate branch so it doesn't distract from the explorer stuff.
return n.description + "\n" + strings.Join(n.toTreeLines(""), "\n") | ||
} | ||
|
||
func (n treeNode) toTreeLines(prefix string) []string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I remember something similar in tracetracker, why do we need a duplicated implementations?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was removed from the trace tracker. The pretty printing functionality of the trace tracker was moved to this debug pkg.
pkg/ton/debug/explorer/explorer.go
Outdated
func (c *client) tryMatchByCodeHash(ctx context.Context, block *ton.BlockIDExt, addr *address.Address, knownActors map[string]deployment.TypeAndVersion) error { | ||
account, err := c.connection.GetAccount(ctx, block, addr) | ||
if err != nil { | ||
return fmt.Errorf("get account: %w", err) | ||
} | ||
code := account.Code.ToBOC() | ||
codeHex := hex.EncodeToString(code) | ||
switch codeHex { | ||
case "b5ee9c7241021001000228000114ff00f4a413f4bcf2c80b01020120020d02014803040078d020d74bc00101c060b0915be101d0d3030171b0915be0fa4030f828c705b39130e0d31f018210ae42e5a4ba9d8040d721d74cf82a01ed55fb04e030020120050a02027306070011adce76a2686b85ffc00201200809001aabb6ed44d0810122d721d70b3f0018aa3bed44d08307d721d70b1f0201200b0c001bb9a6eed44d0810162d721d70b15800e5b8bf2eda2edfb21ab09028409b0ed44d0810120d721f404f404d33fd315d1058e1bf82325a15210b99f326df82305aa0015a112b992306dde923033e2923033e25230800df40f6fa19ed021d721d70a00955f037fdb31e09130e259800df40f6fa19cd001d721d70a00937fdb31e0915be270801f6f2d48308d718d121f900ed44d0d3ffd31ff404f404d33fd315d1f82321a15220b98e12336df82324aa00a112b9926d32de58f82301de541675f910f2a106d0d31fd4d307d30cd309d33fd315d15168baf2a2515abaf2a6f8232aa15250bcf2a304f823bbf2a35304800df40f6fa199d024d721d70a00f2649130e20e01fe5309800df40f6fa18e13d05004d718d20001f264c858cf16cf8301cf168e1030c824cf40cf8384095005a1a514cf40e2f800c94039800df41704c8cbff13cb1ff40012f40012cb3f12cb15c9ed54f80f21d0d30001f265d3020171b0925f03e0fa4001d70b01c000f2a5fa4031fa0031f401fa0031fa00318060d721d300010f0020f265d2000193d431d19130e272b1fb00b585bf03": // https://github.com/ton-blockchain/highload-wallet-contract-v3/blob/main/build/HighloadWalletV3.compiled.json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we externalize these codeHex?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing this for now as it was not working propperly.
// emitted by contracts to communicate with external systems. | ||
func (m *ReceivedMessage) AppendEvent(outMsg *tlb.ExternalMessageOut) { | ||
e := OutgoingExternalMessages{outMsg.CreatedAt, outMsg.CreatedLT, outMsg.Body} | ||
e := OutgoingExternalMessages{outMsg.SrcAddr, outMsg.DstAddr, outMsg.CreatedAt, outMsg.CreatedLT, outMsg.Body} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how's the external message's topic is resolved? Is it extracted inside of trace tracker vs handled outside?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is currently handled outside in the bindings. See the onramp debug decoder for an example.
8b6c2d5
to
7bf0bb4
Compare
NONEVM-2624
This pull request introduces a new TON Explorer command-line tool, adds developer and user documentation for it, and updates/adds new contract bindings. The main focus is on providing an extensible, documented explorer utility for analyzing TON blockchain message traces, with guidance for extending contract decoding support.
TON Explorer Tool and Documentation
main.go
entrypoint incmd/explorer
that wires up the explorer command.Smart Contract Updates
code()
andcodeHash()
getter functions toccipsend_executor
and bumpedCONTRACT_VERSION
to "0.0.4". [1] [2]