refactor: move GUEST_BIN_REL_PATH to constants to avoid duplication#45
refactor: move GUEST_BIN_REL_PATH to constants to avoid duplication#45teyrebaz33 wants to merge 2 commits into
Conversation
| let binaries_root = project.root.join(GUEST_BIN_REL_PATH); | ||
|
|
||
| preflight_sequencer_reachability(&sequencer_addr)?; | ||
| preflight_sequencer_reachability(&sequencer_addr, json)?; |
There was a problem hiding this comment.
doesnt seem related to the changes and not documented in PR description
There was a problem hiding this comment.
Good catch! That change (preflight_sequencer_reachability gaining a json parameter) was leftover from an unrelated experiment and shouldn't have been here. I've removed it in the latest commit — the PR now only moves GUEST_BIN_REL_PATH to src/constants.rs.
|
Addressed the review feedback: the unrelated |
|
same here, @teyrebaz33 , please, sign commits |
There was a problem hiding this comment.
Pull request overview
This PR aims to eliminate duplication of GUEST_BIN_REL_PATH by moving it into src/constants.rs and reusing it from both the deploy and report commands.
Changes:
- Added
GUEST_BIN_REL_PATHtosrc/constants.rsand removed duplicate local consts. - Updated
deployandreportcommands to import the shared constant. - (Also included) Adjusted
deploycommand output behavior when--jsonis enabled (JSON summary + suppressed human-readable prints).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/constants.rs | Introduces shared GUEST_BIN_REL_PATH constant for reuse across commands. |
| src/commands/deploy.rs | Switches to shared constant; also modifies deploy output behavior for JSON mode and guards several prints behind !json. |
| src/commands/report.rs | Switches to shared constant for guest binary path resolution. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if !json { | ||
| println!("FAIL {program} deployment failed"); | ||
| println!(" Error: {summary}"); | ||
| } |
There was a problem hiding this comment.
There is a redundant nested if !json block here (if !json { if !json { ... } }). This adds noise and makes the control flow harder to follow; it should be collapsed to a single conditional guarding the prints.
| if !json { | |
| println!("FAIL {program} deployment failed"); | |
| println!(" Error: {summary}"); | |
| } | |
| println!("FAIL {program} deployment failed"); | |
| println!(" Error: {summary}"); |
There was a problem hiding this comment.
Fixed in the latest commit — the redundant nested if-not-json block and all other unrelated deploy output changes have been removed. The PR now only contains the GUEST_BIN_REL_PATH constant move.
| if json { | ||
| let json_results: Vec<serde_json::Value> = results | ||
| .iter() | ||
| .map(|r| { | ||
| serde_json::json!({ | ||
| "program": r.program, | ||
| "status": r.status.label(), | ||
| "detail": r.detail, | ||
| "tx": r.tx, | ||
| }) | ||
| }) | ||
| .collect(); | ||
| println!( | ||
| "{}", | ||
| serde_json::to_string_pretty(&serde_json::json!({ | ||
| "succeeded": success_count, | ||
| "failed": failed_count, | ||
| "results": json_results, | ||
| }))? | ||
| ); |
There was a problem hiding this comment.
This PR is described as only moving GUEST_BIN_REL_PATH into constants.rs, but this hunk also changes deploy behavior by adding JSON output formatting and suppressing human-readable output when --json is set. Please update the PR description (or split into a separate PR) so reviewers/users can track this behavioral change explicitly.
There was a problem hiding this comment.
Fixed — the unrelated deploy output behavior changes have been removed. The PR now contains exactly 3 file changes: constants.rs (add const), deploy.rs (remove local const, import from constants), report.rs (remove local const, import from constants).
| const REPORT_WARNING: &str = "WARNING: This diagnostics bundle is sanitized on a best-effort basis and may still contain sensitive data. Inspect every file before sharing it publicly."; | ||
| const GUEST_BIN_REL_PATH: &str = "target/riscv-guest/example_program_deployment_methods/example_program_deployment_programs/riscv32im-risc0-zkvm-elf/release"; | ||
| use crate::constants::GUEST_BIN_REL_PATH; | ||
|
|
There was a problem hiding this comment.
use crate::constants::GUEST_BIN_REL_PATH; is placed after a const item. The rest of the codebase keeps all use imports grouped at the top of the module before constants; please move this import up with the other use statements to match the established layout.
There was a problem hiding this comment.
Fixed — use crate::constants::GUEST_BIN_REL_PATH; has been moved to the top of the use block in report.rs, before the const items.
7d49f28 to
025747c
Compare
|
Commits have been re-signed with GPG and the PR has been cleaned up — it now contains only the GUEST_BIN_REL_PATH constant move (3 files, minimal diff). |
|
looks good, but there is a merge conflict |
e6ee1b0 to
1f9c973
Compare
1f9c973 to
7185356
Compare
|
Merge conflict has been resolved. |
|
@teyrebaz33 feel free to resolve the merge conflict and merge this PR. there is already an approval so you should be able to merge this |
|
CI / validate is red on this PR because I prepared a fmt-only fix but cannot push it directly: pushing to The fix is available at:
To unblock: either cherry-pick that commit onto |
Closes #44
Summary
GUEST_BIN_REL_PATHwas defined identically in bothdeploy.rsandreport.rs. This PR moves it tosrc/constants.rsand imports it from there.Changes
src/constants.rs: addedGUEST_BIN_REL_PATHsrc/commands/deploy.rs: removed local const, import from constantssrc/commands/report.rs: removed local const, import from constantsTesting
cargo test