diff --git a/.vscode/launch.json b/.vscode/launch.json index 0f2fdc9..f44f852 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -17,6 +17,23 @@ ], "preLaunchTask": "${defaultBuildTask}", "debugWebviews": true, + }, + { + "name": "Simbolik: Client (Tests)", + "type": "extensionHost", + "request": "launch", + "args": [ + "--extensionDevelopmentPath=${workspaceFolder}", + "${workspaceFolder}/../simbolik/src/tests/data/foundry" + ], + "outFiles": [ + "${workspaceFolder}/build/*.js", + "${workspaceFolder}/build/**/*.js", + "${workspaceFolder}/build-web/*.js", + "${workspaceFolder}/build-web/**/*.js", + ], + "preLaunchTask": "${defaultBuildTask}", + "debugWebviews": true, } ] } diff --git a/package.json b/package.json index e8eb799..141c6d9 100644 --- a/package.json +++ b/package.json @@ -55,101 +55,59 @@ "description": "The websocket URL where the simbolik server is listening. Do not change this unless you are running your own simbolik server.", "order": 1 }, - "simbolik.json-rpc-url": { - "type": "string", - "default": "http://localhost:8545", - "description": "The URL of the JSON-RPC server. Notice, that the JSON RPC server must be reachable from the simbolik server. `localhost` here refers to the machine where the simbolik server is running.", - "order": 2 - }, "simbolik.forge-path": { "type": "string", "default": "forge", "description": "The path to the forge executable. Simbolik uses forge to compile the smart contracts. If forge is not in the PATH, you can set the path here.", - "order": 23 + "order": 2 }, "simbolik.autobuild": { "type": "boolean", "default": true, "description": "If set to true, the debugger will automatically build the project before starting the debugger.", - "order": 4 + "order": 3 }, "simbolik.incremental-build": { "type": "boolean", "default": false, "description": "If autobuild is eanbled and incremental-build is set to true, the debugger will use incremental builds. Notice, that the support for incremental builds is experimental and sometimes leads to unexpected behavior.", - "order": 5 + "order": 4 }, "simbolik.stop-at-first-opcode": { "type": "boolean", "description": "If set to true, the debugger will stop at the first opcode. Otherwise it will stop at the function entry. Disabling this option is experimental and may lead to unexpected behavior.", "default": true, - "order": 6 - }, - "simbolik.simbolik-autostart": { - "type": "boolean", - "default": false, - "description": "If set to true, the debugger will start the simbolik server automatically with VSCode. This option can only be used if you have the simbolik server installed on your machine.", - "order": 7 - }, - "simbolik.simbolik-path": { - "type": "string", - "default": "simbolik", - "description": "The path to the simbolik executable. If simbolik-autostart is set to true, the debugger will start the simbolik server with this executable. If simbolik is not in the PATH, you can set the path here.", - "order": 8 - }, - "simbolik.anvil-autostart": { - "type": "boolean", - "default": false, - "description": "If set to true, the debugger will start the anvil server for every debugging session. Only set this to true if you are running your own simbolik server.", - "order": 9 - }, - "simbolik.anvil-path": { - "type": "string", - "default": "anvil", - "description": "The path to the anvil executable. If anvil-autostart is set to true, the debugger will start the anvil server with this executable. If anvil is not in the PATH, you can set the path here.", - "order": 10 + "order": 5 }, "simbolik.enable-parameters": { "type": "boolean", "default": false, "description": "If set to true, the debugger will show a debug button above functions with parameters. Notice, that this requires a backend that supports parameter debugging. The default Foundry backend does not support parameter debugging.", - "order": 11 + "order": 6 }, "simbolik.show-sourcemaps": { "type": "boolean", "default": false, "description": "If set to true, the debugger will include sourcemaps in the disassembly view. This is useful when debugging sourcemaps.", - "order": 12 - }, - "simbolik.bmc-depth": { - "type": "integer", - "description": "Signals the backend that it should only unroll loops up to this depth. This parameter is only relevant for symbolic execution backends.", - "default": 3, - "order": 13 + "order": 7 }, "simbolik.auto-open-disassembly-view": { "type": "boolean", "description": "If set to true, the debugger will automatically open the disassembly view when starting a debugging session.", "default": true, - "order": 14 - }, - "simbolik.sourcify-autostart": { - "type": "boolean", - "description": "If set to true, the debugger will start the sourcify server for every debugging session. Only set this to true if you are running your own simbolik server.", - "default": false, - "order": 15 + "order": 8 }, - "simbolik.sourcify-solc-repo": { + "simbolik.json-rpc-url": { "type": "string", - "description": "The folder containing different solidity compiler versions.", - "default": "~/.local/bin", - "order": 16 + "default": "http://localhost:8545", + "description": "Attach requests use this URL as the JSON-RPC endpoint. Notice, that the JSON RPC server must be reachable from the simbolik server. `localhost` here refers to the machine where the simbolik server is running.", + "order": 9 }, "simbolik.sourcify-url": { "type": "string", - "description": "The URL of the Sourcify server. This is only relevant if you are running your own Sourcify server.", + "description": "Attach requests use this Sourcify endpoint to download the source code of the debugged transaction.", "default": "http://localhost:5555", - "order": 17 + "order": 10 } } }, diff --git a/src/DebugAdapter.ts b/src/DebugAdapter.ts index 97a791f..dd38a03 100644 --- a/src/DebugAdapter.ts +++ b/src/DebugAdapter.ts @@ -14,7 +14,7 @@ export class SolidityDebugAdapterDescriptorFactory executable: vscode.DebugAdapterExecutable | undefined ): Promise> { return new Promise((resolve, reject) => { - const server = getConfigValue('server', 'ws://localhost:6789'); + const server = getConfigValue('server', 'ws://beta.simbolik.runtimeverification.com:3000'); const websocket = new WebSocket(server); websocket.once('open', () => { const websocketAdapter = new WebsocketDebugAdapter(websocket, session.configuration); diff --git a/src/DebugAdapter.web.ts b/src/DebugAdapter.web.ts index 2f58a1f..6ae8e0a 100644 --- a/src/DebugAdapter.web.ts +++ b/src/DebugAdapter.web.ts @@ -12,7 +12,7 @@ export class SolidityDebugAdapterDescriptorFactory executable: vscode.DebugAdapterExecutable | undefined ): Promise> { return new Promise((resolve, reject) => { - const server = getConfigValue('server', 'ws://localhost:6789'); + const server = getConfigValue('server', 'ws://beta.simbolik.runtimeverification.com:3000'); const websocket = new WebSocket(server); websocket.onopen = () => { const websocketAdapter = new WebsocketDebugAdapter(websocket); diff --git a/src/extension.ts b/src/extension.ts index 59bac37..38e93a9 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -5,9 +5,7 @@ import {CodelensProvider} from './CodelensProvider'; import {SolidityDebugAdapterDescriptorFactory} from './DebugAdapter'; import {startDebugging} from './startDebugging'; import {KastProvider, viewKast} from './KastProvider'; -import {Supervisor} from './supevervisor'; import {getConfigValue} from './utils'; -import { debug } from 'console'; const outputChannel = vscode.window.createOutputChannel( 'Simbolik Solidity Debugger', @@ -23,12 +21,6 @@ export function activate(context: vscode.ExtensionContext) { let disposable: vscode.Disposable; - const supervisor = new Supervisor(); - if (getConfigValue('simbolik-autostart', true)) { - supervisor.simbolik(); - } - context.subscriptions.push(supervisor); - const codelensProvider = new CodelensProvider(); disposable = vscode.languages.registerCodeLensProvider( 'solidity', @@ -45,7 +37,7 @@ export function activate(context: vscode.ExtensionContext) { disposable = vscode.commands.registerCommand( 'simbolik.startDebugging', - (contract, method) => startDebugging(supervisor, contract, method), + (contract, method) => startDebugging(contract, method), ); context.subscriptions.push(disposable); @@ -101,7 +93,6 @@ export function activate(context: vscode.ExtensionContext) { }); vscode.debug.onDidTerminateDebugSession(session => { - supervisor.anvilTerminate(); outputChannel.info(`Debug session ended: ${session.id}`); }); diff --git a/src/startDebugging.ts b/src/startDebugging.ts index e7449a0..4332c84 100644 --- a/src/startDebugging.ts +++ b/src/startDebugging.ts @@ -6,19 +6,12 @@ import { } from '@solidity-parser/parser/dist/src/ast-types'; import * as vscode from 'vscode'; import { getConfigValue } from './utils'; -import { Supervisor } from './supevervisor'; import { forgeBuildTask, foundryRoot, loadBuildInfo } from './foundry'; export async function startDebugging( - supervisor: Supervisor, contract: ContractDefinition, method: FunctionDefinition ) { - if (getConfigValue('anvil-autostart', true)) { - supervisor.anvilTerminate(); - supervisor.anvil(); - } - const activeTextEditor = vscode.window.activeTextEditor; if (!activeTextEditor) { throw new Error('No active text editor.'); @@ -57,7 +50,7 @@ export async function startDebugging( const file = activeTextEditor.document.uri.toString(); const contractName = contract['name']; const methodSignature = `${method['name']}(${parameters.join(',')})`; - const stopAtFirstOpcode = getConfigValue('stop-at-first-opcode', false); + const stopAtFirstOpcode = getConfigValue('stop-at-first-opcode', true); const showSourcemaps = getConfigValue('show-sourcemaps', false); const debugConfigName = `${contractName}.${methodSignature}`; const jsonRpcUrl = getConfigValue('json-rpc-url', 'http://localhost:8545'); diff --git a/src/supevervisor.ts b/src/supevervisor.ts deleted file mode 100644 index 6bebb92..0000000 --- a/src/supevervisor.ts +++ /dev/null @@ -1,112 +0,0 @@ -import * as vscode from 'vscode'; -import {getConfigValue} from './utils'; - -export class Supervisor { - private _simbolik: vscode.TaskExecution | undefined; - private _anvil: vscode.TaskExecution | undefined; - - public async anvil(): Promise { - this._anvil = await vscode.tasks.executeTask(anvilTask()); - if (this._anvil === undefined) { - vscode.window.showErrorMessage('Anvil failed to start'); - } - vscode.tasks.onDidEndTaskProcess(async e => { - if (e.execution === this._anvil && e.exitCode !== undefined) { - this._anvil?.terminate(); - this._anvil = undefined; - const action = await vscode.window.showErrorMessage( - 'Anvil terminated unexpectedly', - 'Open Settings', - 'Try Again' - ); - if (action === 'Open Settings') { - vscode.commands.executeCommand( - 'workbench.action.openSettings', - 'simbolik.anvil-port' - ); - } - if (action === 'Try Again') { - this.anvil(); - } - } - }); - } - - public async simbolik(): Promise { - this._simbolik = await vscode.tasks.executeTask(simbolikTask()); - if (this._simbolik === undefined) { - vscode.window.showErrorMessage('Simbolik failed to start'); - } - vscode.tasks.onDidEndTaskProcess(async e => { - if (e.execution === this._simbolik) { - this._simbolik?.terminate(); - this._simbolik = undefined; - const action = await vscode.window.showErrorMessage( - 'Simbolik terminated unexpectedly', - 'Open Settings', - 'Try Again' - ); - if (action === 'Open Settings') { - await vscode.commands.executeCommand( - 'workbench.action.openSettings', - 'simbolik.server' - ); - } else if (action === 'Try Again') { - this.simbolik(); - } - } - }); - } - - public dispose(): void { - this._anvil?.terminate(); - this._simbolik?.terminate(); - } - - public anvilTerminate(): void { - this._anvil?.terminate(); - } -} - -function anvilTask() { - const port = getConfigValue('anvil-port', 8545); - const anvilPath = getConfigValue('anvil-path', 'anvil'); - const task = new vscode.Task( - { - label: 'anvil', - type: 'shell', - }, - vscode.TaskScope.Workspace, - 'anvil', - 'simbolik', - new vscode.ShellExecution(anvilPath, [ - '--steps-tracing', - '--port', - `${port}`, - '--code-size-limit', - `${2n ** 64n - 1n}`, - ]) - ); - task.isBackground = true; - task.presentationOptions.reveal = vscode.TaskRevealKind.Never; - return task; -} - -function simbolikTask() { - const server = getConfigValue('server', 'ws://localhost:6789'); - const simbolikPath = getConfigValue('simbolik-path', 'simbolik'); - const port = server.split(':')[2]; - const task = new vscode.Task( - { - label: 'simbolik', - type: 'shell', - }, - vscode.TaskScope.Workspace, - 'simbolik', - 'simbolik', - new vscode.ShellExecution(simbolikPath, ['--port', port.toString()]) - ); - task.isBackground = true; - task.presentationOptions.reveal = vscode.TaskRevealKind.Never; - return task; -}