Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added debug_proof to prover_cli #2052

Merged
merged 7 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
43 changes: 23 additions & 20 deletions prover/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions prover/prover_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,8 @@ strum.workspace = true
colored.workspace = true
sqlx.workspace = true
circuit_definitions.workspace = true
zkevm_test_harness = { workspace = true, optional = true, features = ["verbose_circuits"] }

[features]
# enable verbose circuits, if you want to use debug_circuit command (as it is quite heavy dependency).
verbose_circuits = ["zkevm_test_harness"]
30 changes: 30 additions & 0 deletions prover/prover_cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,36 @@ TODO

TODO

### `prover_cli debug-proof`

Debug proof is an advanced feature that can be used to debug failing circuit proofs. It will re-run the proving circuit
for a given proof file - and print detailed debug logs.

**WARNING** - it does require compilation with `--release --features verbose_circuits` enabled (which includes all the
necessary dependencies).

Example output

```
cargo run --release --features verbose_circuits -- debug-proof --file ~/prover_jobs_23_05.bin

[call_ret_impl/far_call.rs:1012:13] max_passable.witness_hook(&*cs)().unwrap() = 535437
[call_ret_impl/far_call.rs:1024:13] leftover.witness_hook(&*cs)().unwrap() = 8518
[call_ret_impl/far_call.rs:1025:13] ergs_to_pass.witness_hook(&*cs)().unwrap() = 544211
[call_ret_impl/far_call.rs:1036:13] remaining_from_max_passable.witness_hook(&*cs)().unwrap() = 4294958522
[call_ret_impl/far_call.rs:1037:13] leftover_and_remaining_if_no_uf.witness_hook(&*cs)().unwrap() = 4294967040
[call_ret_impl/far_call.rs:1047:13] ergs_to_pass.witness_hook(&*cs)().unwrap() = 535437
[call_ret_impl/far_call.rs:1048:13] remaining_for_this_context.witness_hook(&*cs)().unwrap() = 8518
[call_ret_impl/far_call.rs:1049:13] extra_ergs_from_caller_to_callee.witness_hook(&*cs)().unwrap() = 0
[call_ret_impl/far_call.rs:1050:13] callee_stipend.witness_hook(&*cs)().unwrap() = 0
New frame as a result of FAR CALL: Some(ExecutionContextRecordWitness { this: 0x263eb3945d7cee723110c69da5fabc3c6d5a802f, caller: 0x973a7a18f29699b5b976a5026d795f5169cb3348, code_address: 0x0000000000000000000000000000000000000000, code_page: 2416, base_page: 3075968, heap_upper_bound: 4096, aux_heap_upper_bound: 4096, reverted_queue_head: [0x1d06f395ca74bd80, 0x3c3099adfd7d31cb, 0x119db3dd58b4aca6, 0xb8d2f7bd2c1b5e48], reverted_queue_tail: [0x1d06f395ca74bd80, 0x3c3099adfd7d31cb, 0x119db3dd58b4aca6, 0xb8d2f7bd2c1b5e48], reverted_queue_segment_len: 0, pc: 0, sp: 0, exception_handler_loc: 176, ergs_remaining: 535437, is_static_execution: false, is_kernel_mode: false, this_shard_id: 0, caller_shard_id: 0, code_shard_id: 0, context_u128_value_composite: [0, 0, 0, 0], is_local_call: false, total_pubdata_spent: 0, stipend: 0 })
thread 'main' panicked at circuit_definitions/src/aux_definitions/witness_oracle.rs:506:13:
assertion `left == right` failed
left: 2097152
right: 4096
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```

## Development Status

| **Command** | **Subcommand** | **Flags** | **Status** |
Expand Down
4 changes: 3 additions & 1 deletion prover/prover_cli/src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use clap::{command, Args, Parser, Subcommand};
use zksync_types::url::SensitiveUrl;

use crate::commands::{self, delete, get_file_info, requeue, restart};
use crate::commands::{self, debug_proof, delete, get_file_info, requeue, restart};

pub const VERSION_STRING: &str = env!("CARGO_PKG_VERSION");

Expand All @@ -28,6 +28,7 @@ pub struct ProverCLIConfig {

#[derive(Subcommand)]
enum ProverCommand {
DebugProof(debug_proof::Args),
FileInfo(get_file_info::Args),
Delete(delete::Args),
#[command(subcommand)]
Expand All @@ -44,6 +45,7 @@ pub async fn start() -> anyhow::Result<()> {
ProverCommand::Status(cmd) => cmd.run(config).await?,
ProverCommand::Requeue(args) => requeue::run(args, config).await?,
ProverCommand::Restart(args) => restart::run(args).await?,
ProverCommand::DebugProof(args) => debug_proof::run(args).await?,
};

Ok(())
Expand Down
19 changes: 19 additions & 0 deletions prover/prover_cli/src/commands/debug_proof.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use clap::Args as ClapArgs;

#[derive(ClapArgs)]
pub(crate) struct Args {
/// File with the basic proof.
#[clap(short, long)]
file: String,
}

pub(crate) async fn run(_args: Args) -> anyhow::Result<()> {
#[cfg(not(feature = "verbose_circuits"))]
anyhow::bail!("Please compile with verbose_circuits feature");
#[cfg(feature = "verbose_circuits")]
{
let buffer = std::fs::read(_args.file).unwrap();
zkevm_test_harness::debug::debug_basic_circuit(&buffer);
Ok(())
}
}
2 changes: 1 addition & 1 deletion prover/prover_cli/src/commands/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pub(crate) mod debug_proof;
pub(crate) mod delete;
pub(crate) mod get_file_info;
pub(crate) mod requeue;
pub(crate) mod restart;
pub(crate) mod status;

pub(crate) use status::StatusCommand;
Loading