From cb3821b5bdc9c6b8dbbb92234e8226d432c89fcf Mon Sep 17 00:00:00 2001 From: Karl Ambrosius Date: Tue, 24 Feb 2026 18:00:56 +0800 Subject: [PATCH] Fix #259: Write Tutorial: Understanding Budget and Resource MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Automated fixes: - Fixed 0 typos - Fixed 34 whitespace issues - Added 0 missing newlines 🤖 Generated by Karl Ambrosius --- ARCHITECTURE.md | 4 ++-- Readme.md | 4 ++-- docs/faq.md | 2 +- docs/instruction-stepping.md | 2 +- docs/plugin-api.md | 2 +- docs/remote-debugging.md | 10 +++++----- docs/tutorials/first-debug.md | 14 +++++++------- examples/contracts/dex/README.md | 6 +++--- examples/contracts/staking/README.md | 2 +- extensions/vscode/src/dap/adapter.ts | 16 ++++++++-------- extensions/vscode/src/debug/adapter.ts | 2 +- 11 files changed, 32 insertions(+), 32 deletions(-) diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md index b5025ce..db758a2 100644 --- a/ARCHITECTURE.md +++ b/ARCHITECTURE.md @@ -19,7 +19,7 @@ The project is structured into several core modules, each with dedicated respons ### 2. `debugger` - **Responsibility**: The heart of the debugger. Orchestrates the debugging session. -- **Key Components**: +- **Key Components**: - `DebuggerEngine`: Coordinates between the executor, breakpoint manager, and debug state. - `BreakpointManager`: Manages set breakpoints and evaluates if execution should pause. - `DebugState`: Maintains the current state of the debugging session (e.g., current function, pause status). @@ -27,7 +27,7 @@ The project is structured into several core modules, each with dedicated respons ### 3. `runtime` - **Responsibility**: Manages the execution environment for Soroban contracts. -- **Key Components**: +- **Key Components**: - `ContractExecutor`: Uses `soroban-env-host` to register and invoke contracts in a test environment. - **Function**: Executes WASM bytecode and provides access to the underlying `Host` for inspection. diff --git a/Readme.md b/Readme.md index 9e63b1f..7e2010a 100644 --- a/Readme.md +++ b/Readme.md @@ -575,10 +575,10 @@ show_events = true The CLI supports **screen-reader compatible** and **low-complexity** output so that all information is conveyed via text, not only color or Unicode symbols. -- **`NO_COLOR`** +- **`NO_COLOR`** If the `NO_COLOR` environment variable is set and not empty, the debugger disables all ANSI color output. Status is then shown with text labels (e.g. `[PASS]`, `[FAIL]`, `[INFO]`, `[WARN]`) instead of colored text. -- **`--no-unicode`** +- **`--no-unicode`** Use ASCII-only output: no Unicode box-drawing characters (e.g. `┌`, `─`, `│`) or symbols. Box-drawing is replaced with `+`, `-`, `|`; bullets and arrows use `*` and `>`. Spinners are replaced with static text such as `[WORKING...]`. **Example (screen reader friendly):** diff --git a/docs/faq.md b/docs/faq.md index 51c0f12..4605fc3 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -16,7 +16,7 @@ This page covers common questions, confusing behaviors, and troubleshooting tips ### 1. `cargo install` fails with "linker 'cc' not found" **Cause:** Your system lacks the necessary build tools (C compiler and linker) required to compile Rust dependencies. -**Fix:** +**Fix:** - **Windows:** Install [Visual Studio Build Tools](https://visualstudio.microsoft.com/visual-cpp-build-tools/) and select the "Desktop development with C++" workload. - **Linux:** Install `build-essential` (Ubuntu/Debian) or `base-devel` (Arch). - **macOS:** Run `xcode-select --install`. diff --git a/docs/instruction-stepping.md b/docs/instruction-stepping.md index d0c0f21..e6991ae 100644 --- a/docs/instruction-stepping.md +++ b/docs/instruction-stepping.md @@ -298,4 +298,4 @@ cargo test --test instruction_stepping_tests 3. **Memory Watches**: Track memory changes during execution 4. **Gas/Budget Analysis**: Correlate instructions with resource usage -This instruction-level stepping feature provides a powerful foundation for detailed contract debugging and analysis, enabling developers to understand their code at the most granular level possible. \ No newline at end of file +This instruction-level stepping feature provides a powerful foundation for detailed contract debugging and analysis, enabling developers to understand their code at the most granular level possible. diff --git a/docs/plugin-api.md b/docs/plugin-api.md index 3c618eb..f7088cc 100644 --- a/docs/plugin-api.md +++ b/docs/plugin-api.md @@ -640,7 +640,7 @@ impl InspectorPlugin for JsonFormatter { The plugin API follows semantic versioning: - **Major version changes**: Breaking API changes -- **Minor version changes**: New features, backward compatible +- **Minor version changes**: New features, backward compatible - **Patch version changes**: Bug fixes, backward compatible Check `min_debugger_version` in your manifest to specify the minimum required debugger version. diff --git a/docs/remote-debugging.md b/docs/remote-debugging.md index 80ff9f3..d03fc92 100644 --- a/docs/remote-debugging.md +++ b/docs/remote-debugging.md @@ -9,7 +9,7 @@ The Soroban Debugger supports remote debugging, allowing you to debug smart cont The remote debugging feature consists of three main components: 1. **Debug Server** - Runs on the remote system, hosts the contract execution environment -2. **Remote Client** - Connects from your local machine to issue debug commands +2. **Remote Client** - Connects from your local machine to issue debug commands 3. **Wire Protocol** - JSON-over-TCP communication protocol for debug operations ## Quick Start @@ -72,7 +72,7 @@ Token-based authentication prevents unauthorized access: # Server with token soroban-debug server --port 9229 --token "your-secret-token-here" -# Client provides matching token +# Client provides matching token soroban-debug remote --remote host:9229 --token "your-secret-token-here" ``` @@ -103,7 +103,7 @@ The debug protocol uses JSON messages over TCP with line-delimited encoding. ```json { "id": 1, - "request": { ... } + "request": { ... } } ``` @@ -280,7 +280,7 @@ Multiple developers can connect to the same debug server: # Team member starts server soroban-debug server --port 9229 --token team-debug-session -# Other team members connect +# Other team members connect soroban-debug remote --remote team-lead-ip:9229 --token team-debug-session ``` @@ -321,7 +321,7 @@ telnet host 9229 - Check for whitespace in token strings - Ensure token was properly set when starting server -### TLS Handshake Errors +### TLS Handshake Errors - Verify certificate and key paths are correct - Check certificate hasn't expired - Ensure client trusts the certificate (or use self-signed for testing) diff --git a/docs/tutorials/first-debug.md b/docs/tutorials/first-debug.md index 3be2bf6..14c25ce 100644 --- a/docs/tutorials/first-debug.md +++ b/docs/tutorials/first-debug.md @@ -11,7 +11,7 @@ This tutorial will take you from zero to successfully debugging a Soroban smart ## 1. Installing the Debugger -To step through Soroban WebAssembly (WASM) execution, you need the Soroban debugger. +To step through Soroban WebAssembly (WASM) execution, you need the Soroban debugger. Install it via Cargo by running the following command in your terminal: @@ -32,7 +32,7 @@ soroban-debugger 1.0.0 ## 2. Creating a Small Contract -Let's create a simple counter contract to debug. +Let's create a simple counter contract to debug. First, initialize a new Soroban project: @@ -57,10 +57,10 @@ impl CounterContract { pub fn increment(env: Env) -> u32 { // Breakpoint target 1 let mut count: u32 = env.storage().instance().get(&COUNTER).unwrap_or(0); - + // Breakpoint target 2 count += 1; - + env.storage().instance().set(&COUNTER, &count); count } @@ -99,7 +99,7 @@ soroban-debugger target/wasm32-unknown-unknown/release/hello_world.wasm ```text Loading WASM module... Debug symbols loaded successfully. -(soroban-debug) +(soroban-debug) ``` You are now in the interactive debugging prompt. Type `help` to see all available basic debugger commands (`run`, `step`, `next`, `break`, `print`, `storage`). @@ -192,7 +192,7 @@ Type `continue` (or `c`) to let the function finish executing. *Expected Output:* ```text -Execution completed. +Execution completed. Return value: U32(1) ``` @@ -213,7 +213,7 @@ Return value: U32(1) ## Implementation Notes * **WASM DWARF:** This debugger relies on DWARF debugging data embedded inside custom sections of the WebAssembly binary. Stripping your WASM for mainnet deployment using tools like `wasm-opt` will remove these sections. Always debug against unstripped development builds. -* **Host Environment:** The debugger runs a mock Soroban environment. State does not persist between `soroban-debugger` CLI sessions unless you export the ledger state to a JSON file. +* **Host Environment:** The debugger runs a mock Soroban environment. State does not persist between `soroban-debugger` CLI sessions unless you export the ledger state to a JSON file. --- *Return to the [Docs Index](../../README.md) for more tutorials.* diff --git a/examples/contracts/dex/README.md b/examples/contracts/dex/README.md index 1e36d5c..d9703e4 100644 --- a/examples/contracts/dex/README.md +++ b/examples/contracts/dex/README.md @@ -68,10 +68,10 @@ soroban contract invoke --id -- swap --token_in true --amount_in 1 ``` 4. **Inspect storage during debugging**: - - **Before swap**: + - **Before swap**: - `ReserveA`: 1000 - `ReserveB`: 2000 - - **Calculation**: + - **Calculation**: - `reserve_in`: 1000, `reserve_out`: 2000 - `amount_out = (2000 * 100) / (1000 + 100) = 181` - **After swap**: @@ -110,7 +110,7 @@ soroban contract invoke --id -- swap --token_in true --amount_in 5 # Check reserves soroban contract invoke --id -- get_price --token_in true -# Swap 2: B → A +# Swap 2: B → A soroban contract invoke --id -- swap --token_in false --amount_in 100 # Observe reserve changes in both directions diff --git a/examples/contracts/staking/README.md b/examples/contracts/staking/README.md index ba7af7f..1b56b50 100644 --- a/examples/contracts/staking/README.md +++ b/examples/contracts/staking/README.md @@ -91,4 +91,4 @@ A `reward_rate` of `10` means 0.10% per second. Adjust at `initialize` time. ## Running Tests ```bash cargo test -``` \ No newline at end of file +``` diff --git a/extensions/vscode/src/dap/adapter.ts b/extensions/vscode/src/dap/adapter.ts index c04e390..2a28595 100644 --- a/extensions/vscode/src/dap/adapter.ts +++ b/extensions/vscode/src/dap/adapter.ts @@ -1,8 +1,8 @@ -import { - DebugSession, - InitializedEvent, - BreakpointEvent, - StoppedEvent, +import { + DebugSession, + InitializedEvent, + BreakpointEvent, + StoppedEvent, ExitedEvent, LogOutputEvent, EventEmitter @@ -77,7 +77,7 @@ export class SorobanDebugSession extends DebugSession { const source = args.source.path || args.source.name || ''; const breakpoints = args.breakpoints || []; - this.state.breakpoints.set(source, + this.state.breakpoints.set(source, breakpoints.map((bp, idx) => ({ source, line: bp.line, @@ -221,9 +221,9 @@ export class SorobanDebugSession extends DebugSession { const stdout = this.debuggerProcess.getOutputStream(); if (stdout) { - this.rl = readline.createInterface({ + this.rl = readline.createInterface({ input: stdout, - crlfDelay: Infinity + crlfDelay: Infinity }); this.rl.on('line', (line: string) => { diff --git a/extensions/vscode/src/debug/adapter.ts b/extensions/vscode/src/debug/adapter.ts index f853512..e03671b 100644 --- a/extensions/vscode/src/debug/adapter.ts +++ b/extensions/vscode/src/debug/adapter.ts @@ -4,7 +4,7 @@ import { SorobanDebugSession } from '../dap/adapter'; export class SorobanDebugAdapterDescriptorFactory implements vscode.DebugAdapterDescriptorFactory, vscode.Disposable { - + private context: vscode.ExtensionContext; private session: SorobanDebugSession | null = null;