Skip to content

feat: enable TX debugging#1883

Closed
djolertrk wants to merge 14 commits into0xMiden:release/v0.14.0-betafrom
walnuthq:pr/enable-tx-debugging-clean
Closed

feat: enable TX debugging#1883
djolertrk wants to merge 14 commits into0xMiden:release/v0.14.0-betafrom
walnuthq:pr/enable-tx-debugging-clean

Conversation

@djolertrk
Copy link
Copy Markdown

@djolertrk djolertrk commented Mar 10, 2026

Enable transaction debugging with Debugger Adapter Protocol.

@djolertrk djolertrk force-pushed the pr/enable-tx-debugging-clean branch from e502fbb to ec3fa67 Compare March 10, 2026 17:08
@djolertrk
Copy link
Copy Markdown
Author

Rebased on top of next now, since the PR for migration to new VM is merged.

Comment thread Cargo.toml Outdated
Comment on lines +83 to +87
[patch.crates-io]
miden-protocol = { path = "../protocol/crates/miden-protocol" }
miden-standards = { path = "../protocol/crates/miden-standards" }
miden-testing = { path = "../protocol/crates/miden-testing" }
miden-tx = { path = "../protocol/crates/miden-tx" }
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be removed

Comment thread Cargo.toml Outdated
miden-node-ntx-builder = { version = "=0.14.0-alpha.4" }
miden-node-proto = { version = "=0.14.0-alpha.4" }
miden-node-proto-build = { default-features = false, version = "=0.14.0-alpha.4" }
miden-node-proto-build = { default-features = false, path = "../node/proto", version = "=0.14.0-alpha.1" }
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also needs to be fixed.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, sure. I should have marked this as a draft.

@juan518munoz
Copy link
Copy Markdown
Collaborator

Could you provide a more detailed description like screenshots and a sample debug flow?

@djolertrk
Copy link
Copy Markdown
Author

Could you provide a more detailed description like screenshots and a sample debug flow?

Hi @juan518munoz, thanks for taking a look.

The main idea is to enhance debugger with support to debug programs executed under the transaction kernel, instead of only debugging standalone VM programs.

Please check:

0xMiden/miden-debug#29

0xMiden/miden-debug#41
0xMiden/protocol#2574

Within 0xMiden/miden-debug#29, I have described one of possible use cases, but I was able to add even an "offline" mode to this dap execution, so you just do:

run

# terminal 1

$  miden-client init --local --network localhost
$ miden-client new-wallet --offline
$ miden-client exec \
    --script-path /tmp/miden-no-node-client/nop.masm \
    --start-debug-adapter localhost:4711

and run debugger as:

# terminal 2
miden-debug --dap-connect localhost:4711

so, it starts the debugger in TUI mode, and you can step through the execution, and whenever you execute a command via DAP, it will be logged with the client -- see picture attached.

Screenshot 2026-03-11 at 20 58 43

@djolertrk djolertrk marked this pull request as draft March 13, 2026 10:47
Copy link
Copy Markdown
Collaborator

@juan518munoz juan518munoz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's update the branch so we can run the CI

Comment thread bin/miden-cli/src/commands/exec.rs Outdated
Comment on lines 105 to 113
client
.execute_program(account_id, tx_script, advice_inputs, BTreeSet::new())
.await
};

#[cfg(not(feature = "dap"))]
let result = client
.execute_program(account_id, tx_script, advice_inputs, BTreeSet::new())
.await;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is duplicated code. Maybe the best approach is not to split between feature = "dap" or not.

Comment thread bin/miden-cli/Cargo.toml Outdated
path = "src/main.rs"

[features]
dap = ["miden-client/dap", "dep:miden-debug"]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we gate behind a feature? Or have connection depend on an Optional argument?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved the CLI behavior toward the optional-argument model. The --start-debug-adapter is now always part of the CLI surface, and if the binary is built without DAP support it returns a clear runtime error. Furthermore, I kept the actual debugger wiring behind the dap feature because miden-debug currently requires a newer Rust version than the rest of the client workspace. So making it unconditional would raise the default build/toolchain requirements for miden-client. If that constraint goes away, we can simplify further and drop the feature gate.

use crate::store::{BlockRelevance, StoreError};
use crate::{Client, ClientError};

const OFFLINE_NATIVE_ASSET_FAUCET_ID: u128 = 0xab00_0000_0000_cd20_0000_ac00_0000_de00;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's doc this

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The whole diff of this part seems to be caused due to not being on track with next. As we should already have solved them here.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now rebased on top of next.

@juan518munoz juan518munoz changed the title Enable TX debugging feat: enable TX debugging Mar 16, 2026
@djolertrk
Copy link
Copy Markdown
Author

Let's update the branch so we can run the CI

protocol part 0xMiden/protocol#2574 -- went in, but I think we would need 0xMiden/miden-debug#41 (debugger part) to be merged, so we can get rid of ../miden-debug dependency...

@djolertrk djolertrk force-pushed the pr/enable-tx-debugging-clean branch from f33d10b to 5c75028 Compare March 19, 2026 12:25
@juan518munoz
Copy link
Copy Markdown
Collaborator

@djolertrk I've enabled CI runs on this PR. Let's wait for 0xMiden/miden-debug#41 as you said and update to it. Once it's done and the CI passes feel free to re-request reviews so we can merge this.

@djolertrk djolertrk force-pushed the pr/enable-tx-debugging-clean branch from c310c9c to 4a3fbf6 Compare March 26, 2026 18:51
@djolertrk djolertrk marked this pull request as ready for review March 26, 2026 19:33
@djolertrk
Copy link
Copy Markdown
Author

hey @juan518munoz, the PR in miden-debug (0xMiden/miden-debug#41) is merged! we can enable CI now. Thanks!

@djolertrk djolertrk changed the base branch from next to release/v0.14.0-beta March 26, 2026 19:34
@djolertrk
Copy link
Copy Markdown
Author

cc @bitwalker

Copy link
Copy Markdown
Collaborator

@juan518munoz juan518munoz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for updating the PR! Looks like it won't be hard to merge as there is no breaking change, but there are still some comments that need to be addressed.

Comment thread bin/miden-cli/Cargo.toml Outdated
path = "src/main.rs"

[features]
# Keep debugger integration optional while `miden-debug` requires a newer Rust version than the
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure by this is mandatory, why does one require a higher version than the other?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not the case anymore, the compiler is the same. Will remove the stale comment.

Comment thread Cargo.toml
should_panic_without_expect = "allow" # We don't care about the specific panic message.
# End of pedantic lints.

[patch.crates-io]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This patches need to be removed before merging

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In order to do it, we will need to wait for this to be published to creates.io

Comment thread Cargo.toml
miden-utils-diagnostics = { git = "https://github.com/0xMiden/miden-vm.git", rev = "1b60fa4b54e60075cad7a761b593d5c00c6aaf46" }
miden-utils-indexing = { git = "https://github.com/0xMiden/miden-vm.git", rev = "1b60fa4b54e60075cad7a761b593d5c00c6aaf46" }

[patch."https://github.com/0xMiden/miden-base"]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This as well

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

@djolertrk
Copy link
Copy Markdown
Author

Thanks for updating the PR! Looks like it won't be hard to merge as there is no breaking change, but there are still some comments that need to be addressed.

Thanks a lot for the comments!

@djolertrk djolertrk force-pushed the pr/enable-tx-debugging-clean branch from 74204f3 to c5b6c4a Compare March 30, 2026 11:18
/// Executes the provided transaction script with a DAP debug adapter listening for
/// connections, allowing interactive debugging via any DAP-compatible client.
#[cfg(feature = "dap")]
pub async fn execute_program_with_dap(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is almost to execute_program, can't we generalize it?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, good point, thank you

Comment thread crates/sqlite-store/src/account/tests.rs Outdated
}
}

fn synthetic_offline_genesis_header() -> BlockHeader {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct me if wrong, but this functions seems redundant as we can achieve the same with MockChainBuilder

MockChainBuilder::new()
    .native_asset_id(some_id)
    .verification_base_fee(500)
    .build()
    .expect("mock chain build should be valid")
    .genesis_block_header()

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, but we would need to mark the miden-testing a non-optional dependency

}

#[test]
fn synthetic_offline_genesis_header_matches_empty_chain_state() {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the other comment applies, we should remove this.

@djolertrk djolertrk force-pushed the pr/enable-tx-debugging-clean branch from c5b6c4a to f5ed3a7 Compare April 1, 2026 13:01
@igamigo igamigo deleted the branch 0xMiden:release/v0.14.0-beta April 4, 2026 02:29
@igamigo igamigo closed this Apr 4, 2026
@djolertrk
Copy link
Copy Markdown
Author

djolertrk commented Apr 4, 2026

Why did we delete the release/v0.14.0-beta?

Btw, we are waiting for the crates for miden-vm and debugger to be published, so we can update this PR not to rely to these dependencies by GitHub SHA. This is the last piece to enable real transaction debugging with our miden-debug debugger.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants