Skip to content
This repository has been archived by the owner on Jan 29, 2025. It is now read-only.

Commit

Permalink
chore: support for passing file contents for sourcemaps; puya/teal ed…
Browse files Browse the repository at this point in the history
…ge cases (#1)

* chore: hiding locals on non puya sourcemaps; adding puya and teal example

* chore: no tmpl vars offset edge case fix

* chore: rel path for example on puya + teal

* chore: workaround on skipping syntentic refs that does not require async file exists

* feat: support direct file or encoded content for sourcemaps

* refactor: make programSourcesDescription an object instead of JSON

* chore: adding more edge cases

* chore(src/common): Add program source entry file and type

Added 'ProgramSourceEntryFile' and 'ProgramSourceEntry' to the common module.
These types are used for parsing program source files.

* chore: add support for 'null' sourcemap paths when user prefers ignores

* chore: add mocharc file for global timeouts

Also fixing a few tests

* fix: move program forward call after inner transaction processing

* chore: further refine puya example with third parties

* feat: integrating Locals with existing expand avm methods

* chore: adding puya unit test; moving process unit into program replay

---------

Co-authored-by: Daniel McGregor <[email protected]>
  • Loading branch information
aorumbayev and daniel-makerx authored Oct 9, 2024
1 parent beeef25 commit 067bae8
Show file tree
Hide file tree
Showing 43 changed files with 179,927 additions and 6,825 deletions.
4 changes: 4 additions & 0 deletions .mocharc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// .mocharc.js
module.exports = {
timeout: 30000, // 30 seconds
};
3 changes: 2 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
"type": "extensionHost",
"request": "launch",
"args": [
"--disable-extensions",
"--extensionDevelopmentPath=${workspaceFolder}/extension",
"${workspaceFolder}/sampleWorkspace"
],
"outFiles": ["${workspaceFolder}/extension/dist/**/*.js"],
"preLaunchTask": "npm: extension watch"
"preLaunchTask": "npm: extension:build"
},
{
"name": "Server",
Expand Down
3 changes: 3 additions & 0 deletions extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@
"breakpoints": [
{
"language": "teal"
},
{
"language": "python"
}
],
"debuggers": [
Expand Down
19 changes: 16 additions & 3 deletions extension/src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export class AvmDebugConfigProvider
implements vscode.DebugConfigurationProvider
{
/**
* Massage a debug configuration just before a debug session is being launched,
* Message a debug configuration just before a debug session is being launched,
* e.g. add all missing attributes to the debug configuration.
*/
resolveDebugConfiguration(
Expand All @@ -26,9 +26,22 @@ export class AvmDebugConfigProvider
return null;
}

if (!config.programSourcesDescriptionFile) {
if (
config.programSourcesDescription &&
!config.programSourcesDescriptionFolder
) {
vscode.window.showErrorMessage(
'Missing property "programSourcesDescriptionFile" in debug config',
'Missing property "programSourcesDescriptionFolder" in debug config',
);
return null;
}

if (
!config.programSourcesDescriptionFile &&
!config.programSourcesDescription
) {
vscode.window.showErrorMessage(
'Either "programSourcesDescriptionFile" or "programSourcesDescription" + "programSourcesDescriptionFolder" must be provided in debug config',
);
return null;
}
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@
"extension:publish": "vsce publish",
"extension:publish-pre-release": "vsce publish --pre-release",
"test": "ts-mocha -p tsconfig.json 'tests/**/*test.ts' --timeout 30s --diff false",
"test:coverage": "nyc npm run test"
"test:coverage": "nyc npm run test",
"pre-commit": "npm run lint && npm run typecheck && npm run format"
},
"dependencies": {
"@vscode/debugadapter": "^1.64.0",
Expand Down
80 changes: 45 additions & 35 deletions sampleWorkspace/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,171 +8,181 @@
"type": "avm",
"request": "launch",
"name": "Debug App Box State Changes",

"simulateTraceFile": "${workspaceFolder}/app-state-changes/box-simulate-response.json",
"programSourcesDescriptionFile": "${workspaceFolder}/app-state-changes/sources.json",

"stopOnEntry": true
},
{
"type": "avm",
"request": "launch",
"name": "Debug App Global State Changes",

"simulateTraceFile": "${workspaceFolder}/app-state-changes/global-simulate-response.json",
"programSourcesDescriptionFile": "${workspaceFolder}/app-state-changes/sources.json",

"stopOnEntry": true
},
{
"type": "avm",
"request": "launch",
"name": "Debug App Local State Changes",

"simulateTraceFile": "${workspaceFolder}/app-state-changes/local-simulate-response.json",
"programSourcesDescriptionFile": "${workspaceFolder}/app-state-changes/sources.json",

"stopOnEntry": true
},
{
"type": "avm",
"request": "launch",
"name": "Debug Recursive App",

"simulateTraceFile": "${workspaceFolder}/recursive-app/simulate-response.json",
"programSourcesDescriptionFile": "${workspaceFolder}/recursive-app/sources.json",

"stopOnEntry": true
},
{
"type": "avm",
"request": "launch",
"name": "Debug Slot Machine",

"simulateTraceFile": "${workspaceFolder}/slot-machine/simulate-response.json",
"programSourcesDescriptionFile": "${workspaceFolder}/slot-machine/sources.json",

"stopOnEntry": true
},
{
"type": "avm",
"request": "launch",
"name": "Debug Sourcemap Test",

"simulateTraceFile": "${workspaceFolder}/sourcemap-test/simulate-response.json",
"programSourcesDescriptionFile": "${workspaceFolder}/sourcemap-test/sources.json",

"stopOnEntry": true
},
{
"type": "avm",
"request": "launch",
"name": "Debug Stack Scratch",

"simulateTraceFile": "${workspaceFolder}/stack-scratch/simulate-response.json",
"programSourcesDescriptionFile": "${workspaceFolder}/stack-scratch/sources.json",

"stopOnEntry": true
},
{
"type": "avm",
"request": "launch",
"name": "Debug Stepping Test",

"simulateTraceFile": "${workspaceFolder}/stepping-test/simulate-response.json",
"programSourcesDescriptionFile": "${workspaceFolder}/stepping-test/sources.json",

"stopOnEntry": true
},
{
"type": "avm",
"request": "launch",
"name": "Debug App Error",

"simulateTraceFile": "${workspaceFolder}/errors/app/simulate-response.json",
"programSourcesDescriptionFile": "${workspaceFolder}/errors/app/sources.json",

"stopOnEntry": true
},
{
"type": "avm",
"request": "launch",
"name": "Debug App from LogicSig Error",

"simulateTraceFile": "${workspaceFolder}/errors/app-from-logicsig/simulate-response.json",
"programSourcesDescriptionFile": "${workspaceFolder}/errors/app-from-logicsig/sources.json",

"stopOnEntry": true
},
{
"type": "avm",
"request": "launch",
"name": "Debug Inner App Error (App Reject)",

"simulateTraceFile": "${workspaceFolder}/errors/inner-app/app-reject-simulate-response.json",
"programSourcesDescriptionFile": "${workspaceFolder}/errors/inner-app/sources.json",

"stopOnEntry": true
},
{
"type": "avm",
"request": "launch",
"name": "Debug Inner App Error (Overspend)",

"simulateTraceFile": "${workspaceFolder}/errors/inner-app/overspend-simulate-response.json",
"programSourcesDescriptionFile": "${workspaceFolder}/errors/inner-app/sources.json",

"stopOnEntry": true
},
{
"type": "avm",
"request": "launch",
"name": "Debug LogicSig Error",

"simulateTraceFile": "${workspaceFolder}/errors/logicsig/simulate-response.json",
"programSourcesDescriptionFile": "${workspaceFolder}/errors/logicsig/sources.json",

"stopOnEntry": true
},
{
"type": "avm",
"request": "launch",
"name": "Debug Error Before LogicSig",

"simulateTraceFile": "${workspaceFolder}/errors/logicsig-after-error/simulate-response.json",
"programSourcesDescriptionFile": "${workspaceFolder}/errors/logicsig-after-error/sources.json",

"stopOnEntry": true
},
{
"type": "avm",
"request": "launch",
"name": "Clear State Rejection",

"simulateTraceFile": "${workspaceFolder}/errors/clear-state/rejection-response.json",
"programSourcesDescriptionFile": "${workspaceFolder}/errors/clear-state/sources.json",

"stopOnEntry": true
},
{
"type": "avm",
"request": "launch",
"name": "Clear State Error",

"simulateTraceFile": "${workspaceFolder}/errors/clear-state/error-response.json",
"programSourcesDescriptionFile": "${workspaceFolder}/errors/clear-state/sources.json",

"stopOnEntry": true
},
{
"type": "avm",
"request": "launch",
"name": "Debug Puya",

"simulateTraceFile": "${workspaceFolder}/puya/contract.simulate.json",
"simulateTraceFile": "${workspaceFolder}/puya/simulate-response.json",
"programSourcesDescriptionFile": "${workspaceFolder}/puya/sources.json",

"stopOnEntry": true
},
{
"type": "avm",
"request": "launch",
"name": "Debug Puya & Teal",
"simulateTraceFile": "${workspaceFolder}/puya_and_teal/simulate-response.json",
"programSourcesDescription": {
"txn-group-sources": [
{
"sourcemap-location": "first_app/approval.teal.tok.map",
"hash": "+M4WXURFSOFzatfICt2miBHDfm5qylmm279/3bZtKjI="
},
{
"sourcemap-location": "second_app/contract_approval.puya.map",
"hash": "Vg0dtzIh0CIFZN/+hJG/L+6gSSPPyjuzE0wDqGt0zyU="
},
{
"sourcemap-location": "delegated_lsig/lsig.puya.map",
"hash": "8Y7ddIVDDdijOZcTKzMOxqa3RpJOjUGswRdND/Hdddg="
}
]
},
"programSourcesDescriptionFolder": "${workspaceFolder}/puya_and_teal/",
"stopOnEntry": true
},
{
"type": "avm",
"request": "launch",
"name": "Debug Puya with Third Party export",
"simulateTraceFile": "${workspaceFolder}/puya_third_parties/simulate-response.json",
"programSourcesDescription": {
"txn-group-sources": [
{
"sourcemap-location": "RSATester.approval.puya.map",
"hash": "sHHTmOJCdECH2FtRp7ukCKBX/bhw3MhiwEVLw5lakig="
},
{
"sourcemap-location": ".algokit/sources/opup/approval.teal.map",
"hash": "p0zHRDBy7V/S2TDcAaXYEd2OF8KSxV/1y0ceYEL6qxU="
}
]
},
"programSourcesDescriptionFolder": "${workspaceFolder}/puya_third_parties/",
"stopOnEntry": true
}
]
}
13 changes: 13 additions & 0 deletions sampleWorkspace/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
## How to navigate examples?

This folder contains sample workspaces representing various debugger use cases:

- Simulate traces, TEAL sources and sourcemaps (e.g. `stack-scratch`, `stepping-test`, `app-state-changes`, `errors`). Various examples of using the debugger with TEAL sourcemaps and sources.
- Simulate traces, [Puya](https://github.com/algorandfoundation/puya) sources and sourcemaps (e.g. `puya`, `puya_third_parties`). Showcasing various ways to simulate traces with puya sourcemaps and sources.
- Simulate traces, TEAL sources & sourcemaps and Puya sources & sourcemaps (e.g. `puya_and_teal`). Showcasing the ability to mix and match TEAL and Puya frontend languages within the same debug session.

> **Note:** The frontend language for Puya compiler scenarios is [Algorand Python](https://pypi.org/project/algorand-python/).
### Launching sample workspaces

Refer to the [launch.json](.vscode/launch.json) file to launch sample workspaces from VSCode. Keep the marketplace-based AlgoKit AVM Debugger extension disabled (if installed).
Loading

0 comments on commit 067bae8

Please sign in to comment.