Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"react-helmet-async": "^2.0.5",
"react-icons": "^5.5.0",
"react-markdown": "^10.1.0",
"ton-assembly": "0.2.4",
"ton-assembly": "0.5.0",
"txtracer-core": "^0.3.1"
},
"devDependencies": {
Expand Down
13 changes: 8 additions & 5 deletions src/features/godbolt/lib/func/compilation.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {Cell} from "@ton/core"
import {runtime as i, text, trace} from "ton-assembly"
import type {InstructionInfo} from "ton-source-map"

import {FUNC_STDLIB} from "@features/godbolt/lib/func/stdlib.ts"
import {funcCompile} from "@features/godbolt/lib/func/func-wasm/func-compile.ts"
Expand All @@ -10,7 +11,7 @@ export interface FuncCompilationResult {
readonly code: string
readonly assembly: string
readonly sourceMap?: trace.FuncMapping
readonly mapping: Map<number, trace.InstructionInfo[]>
readonly mapping: Map<number, InstructionInfo[]>
}

export class FuncCompilationError extends Error {
Expand Down Expand Up @@ -51,12 +52,14 @@ export const compileFuncCode = async (code: string): Promise<FuncCompilationResu
return cell?.instructions ?? []
})

const debugSectionToInstructions = new Map<number, trace.InstructionInfo[]>()
const debugSectionToInstructions = new Map<number, InstructionInfo[]>()

for (const instr of allInstructions) {
const arr = debugSectionToInstructions.get(instr.debugSection) ?? []
arr.push(instr)
debugSectionToInstructions.set(instr.debugSection, arr)
for (const debugSection of instr.debugSections) {
const arr = debugSectionToInstructions.get(debugSection) ?? []
arr.push(instr)
debugSectionToInstructions.set(debugSection, arr)
}
}

return {
Expand Down
11 changes: 7 additions & 4 deletions src/features/godbolt/lib/tolk/compilation.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {Cell} from "@ton/core"
import {runtime as i, text, trace} from "ton-assembly"
import type {InstructionInfo} from "ton-source-map"

import {runTolkCompiler} from "@ton/tolk-js"

Expand Down Expand Up @@ -27,12 +28,14 @@ export const compileTolkCode = async (code: string): Promise<TolkCompilationResu
return cell?.instructions ?? []
})

const debugSectionToInstructions = new Map<number, trace.InstructionInfo[]>()
const debugSectionToInstructions = new Map<number, InstructionInfo[]>()

for (const instr of allInstructions) {
const arr = debugSectionToInstructions.get(instr.debugSection) ?? []
arr.push(instr)
debugSectionToInstructions.set(instr.debugSection, arr)
for (const debugSection of instr.debugSections) {
const arr = debugSectionToInstructions.get(debugSection) ?? []
arr.push(instr)
debugSectionToInstructions.set(debugSection, arr)
}
}

return {
Expand Down
5 changes: 3 additions & 2 deletions src/features/godbolt/lib/tolk/types.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import {runtime as i, trace} from "ton-assembly"
import {runtime as i} from "ton-assembly"
import type {InstructionInfo} from "ton-source-map"

export interface TolkCompilationResult {
readonly lang: "tolk"
readonly instructions: i.Instr[]
readonly code: string
readonly assembly: string
readonly mapping: Map<number, trace.InstructionInfo[]>
readonly mapping: Map<number, InstructionInfo[]>
}

export class TolkCompilationError extends Error {
Expand Down
129 changes: 129 additions & 0 deletions src/features/spec/gen/tvm-specification.json
Original file line number Diff line number Diff line change
Expand Up @@ -67960,6 +67960,135 @@
"line_number": 176,
"function_name": "exec_get_var_in_msg_param"
}
},
"BTOS": {
"category": "cell",
"sub_category": "cell_deserialize",
"description": {
"short": "Converts a _Builder_ into a _Slice_.",
"long": "This instruction is equivalent to `ENDC`, `CTOS` without extra gas for intermediate Cell creation.",
"tags": [],
"operands": [],
"exit_codes": [],
"other_implementations": [
{
"exact": true,
"instructions": ["ENDC", "CTOS"]
}
],
"gas": [
{
"value": 26,
"description": "Base gas consumption"
}
]
},
"layout": {
"min": 13586432,
"max": 13586688,
"checkLen": 16,
"skipLen": 16,
"args": {
"$": "simpleArgs",
"children": []
},
"exec": "exec_builder_to_slice",
"version": 12,
"kind": "simple",
"prefix": 53072,
"prefix_str": "CF50"
},
"signature": {
"stack_string": "b:Builder -> s:Slice",
"inputs": {
"stack": [
{
"type": "simple",
"name": "b",
"value_types": ["Builder"]
}
]
},
"outputs": {
"stack": [
{
"type": "simple",
"name": "s",
"value_types": ["Slice"]
}
]
}
},
"implementation": {
"commit_hash": "4ebd7412c52248360464c2df5f434c8aaa3edfe1",
"file_path": "crypto/vm/cellops.cpp",
"line_number": 767,
"function_name": "exec_builder_to_slice"
}
},
"HASHBU": {
"category": "crypto",
"sub_category": "crypto_common",
"description": {
"short": "",
"long": "Computes the hash of a _Builder_ `b` and returns it as a 256-bit unsigned integer `hash`. The result is the same as if an ordinary cell containing only data and references from `b` had been created and its hash computed by `HASHCU`.",
"tags": [],
"operands": [],
"other_implementations": [
{
"exact": true,
"instructions": ["ENDC", "HASHCU"]
}
],
"gas": [
{
"value": 26,
"description": "Base gas consumption"
}
]
},
"layout": {
"min": 16324096,
"max": 16324352,
"checkLen": 16,
"skipLen": 16,
"args": {
"$": "simpleArgs",
"children": []
},
"exec": "exec_compute_hash",
"version": 12,
"kind": "simple",
"prefix": 63766,
"prefix_str": "F916"
},
"signature": {
"stack_string": "b:Builder -> hash:Int",
"inputs": {
"stack": [
{
"type": "simple",
"name": "b",
"value_types": ["Builder"]
}
]
},
"outputs": {
"stack": [
{
"type": "simple",
"name": "hash",
"value_types": ["Int"]
}
]
}
},
"implementation": {
"commit_hash": "4ebd7412c52248360464c2df5f434c8aaa3edfe1",
"file_path": "crypto/vm/tonops.cpp",
"line_number": 612,
"function_name": "exec_compute_hash"
}
}
},
"fift_instructions": {
Expand Down
5 changes: 3 additions & 2 deletions src/features/tasm/lib/executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import type {Address, Contract, ContractProvider, Sender, StateInit, TupleReader
import {Cell, contractAddress, toNano, TupleBuilder} from "@ton/core"
import {GetMethodError, type SandboxContract, type TreasuryContract} from "@ton/sandbox"
import {Blockchain} from "@ton/sandbox"
import {createMappingInfo, type MappingInfo} from "ton-assembly/dist/trace/mapping"
import {createMappingInfo} from "ton-assembly/dist/trace/mapping"
import type {AssemblyMapping} from "ton-source-map"
import type {StackElement} from "ton-assembly/dist/trace"

import {type ExitCode, findExitCode} from "@features/txTrace/lib/traceTx.ts"
Expand Down Expand Up @@ -112,7 +113,7 @@ export interface AssemblyExecutionResult {
readonly vmLogs: string
readonly instructions: i.Instr[]
readonly code: string
readonly mappingInfo: MappingInfo | null
readonly mappingInfo: AssemblyMapping | null
readonly exitCode: ExitCode | undefined
readonly traceInfo: trace.TraceInfo | undefined
}
Expand Down
3 changes: 2 additions & 1 deletion src/features/txTrace/hooks/useFuncLineStepper.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import {useCallback, useEffect, useMemo, useState} from "react"
import {trace} from "ton-assembly"
import type {InstructionInfo} from "ton-source-map"

import type {UseTraceStepperReturn} from "./useTraceStepper"

export interface CompilationResult {
readonly mapping?: Map<number, trace.InstructionInfo[]>
readonly mapping?: Map<number, InstructionInfo[]>
readonly assembly?: string
readonly funcSourceMap?: trace.FuncMapping
}
Expand Down
5 changes: 2 additions & 3 deletions src/features/txTrace/lib/traceTx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import type {TraceResult} from "txtracer-core/dist/types"
import {compileCellWithMapping, decompileCell} from "ton-assembly/dist/runtime/instr"
import {
createMappingInfo,
type InstructionInfo,
type MappingInfo,
} from "ton-assembly/dist/trace/mapping"
import {type Step, type TraceInfo} from "ton-assembly/dist/trace"
import {createTraceInfoPerTransaction, findInstructionInfo} from "ton-assembly/dist/trace/trace"
Expand All @@ -29,6 +27,7 @@ import {
TxNotFoundError,
TxTraceError,
} from "./errors"
import type {AssemblyMapping, InstructionInfo} from "ton-source-map"

export type ExitCode = {
readonly num: number
Expand Down Expand Up @@ -135,7 +134,7 @@ export function findException(reversedEntries: l.VmLine[]) {
return mapped.find(it => it !== undefined)
}

export function findExitCode(vmLogs: string, mappingInfo: MappingInfo) {
export function findExitCode(vmLogs: string, mappingInfo: AssemblyMapping) {
const res = l.parse(vmLogs)
const reversedEntries = [...res].reverse()
const description = findException(reversedEntries)
Expand Down
3 changes: 2 additions & 1 deletion src/pages/GodboltPage/hooks/useSourceMapHighlight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type * as monaco from "monaco-editor"
import {trace} from "ton-assembly"

import type {HighlightGroup, HighlightRange} from "@shared/ui/CodeEditor"
import type {InstructionInfo} from "ton-source-map"

export interface UseSourceMapHighlightReturn {
readonly funcHighlightGroups: readonly HighlightGroup[]
Expand Down Expand Up @@ -78,7 +79,7 @@ const COLORS = [

export function useSourceMapHighlight(
sourceMap: trace.FuncMapping | undefined,
debugSectionToInstructions?: Map<number, trace.InstructionInfo[]>,
debugSectionToInstructions?: Map<number, InstructionInfo[]>,
funcEditorRef?: React.RefObject<monaco.editor.IStandaloneCodeEditor | null>,
asmEditorRef?: React.RefObject<monaco.editor.IStandaloneCodeEditor | null>,
originalAsmCode?: string,
Expand Down
24 changes: 17 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11586,20 +11586,30 @@ __metadata:
languageName: node
linkType: hard

"ton-assembly@npm:0.2.4":
version: 0.2.4
resolution: "ton-assembly@npm:0.2.4"
"ton-assembly@npm:0.5.0":
version: 0.5.0
resolution: "ton-assembly@npm:0.5.0"
dependencies:
"@ton/core": "npm:^0.60.1"
"@tonstudio/parser-runtime": "npm:^0.0.1"
cac: "npm:^6.7.14"
ton-source-map: "npm:^0.2.2"
peerDependencies:
"@ton/core": ">=0.60.1"
"@ton/core": ">=0.61.0"
peerDependenciesMeta:
"@ton/core":
optional: false
bin:
tasm: dist/cli/assembler.js
tdisasm: dist/cli/disassembler.js
tfift: dist/cli/fift-compiler.js
checksum: 10c0/453042e3776ba9cf72dd1186643f5c79ce6c4dc88daadd56ee7eceeb68e0d20c1e70e7e2bab529288398eea2d2ddc41408e59e07d1bffe8699aaed09eab8badd
checksum: 10c0/f35e598c835c852eda6d71b6bf8a791b5015fda77f6ca3896902aac4057f11a62663d7f1dda9aa013c5420dabc818a33d028d20c4a058df16d5b2706bfddef21
languageName: node
linkType: hard

"ton-source-map@npm:^0.2.2":
version: 0.2.2
resolution: "ton-source-map@npm:0.2.2"
checksum: 10c0/c1e0413983f589a1dfcbb53aa35d04f42244e88d75899eb4c04a3733ac37d2a915063dc91a726409b0239e4a039059d860e1069efb9c8faa6580d06c8b88f3a0
languageName: node
linkType: hard

Expand Down Expand Up @@ -11822,7 +11832,7 @@ __metadata:
stylelint: "npm:^16.24.0"
stylelint-config-css-modules: "npm:^4.5.1"
stylelint-config-standard: "npm:^39.0.0"
ton-assembly: "npm:0.2.4"
ton-assembly: "npm:0.5.0"
ts-node: "npm:^10.9.1"
txtracer-core: "npm:^0.3.1"
typescript: "npm:~5.8.3"
Expand Down
Loading