Skip to content

feat(core): move DeepestErrorFinder into dedicated deepest_error.rs - #398

Merged
codeZe-us merged 1 commit into
Toolbox-Lab:mainfrom
JuliobaCR:fix/393-deepest-error-dedicated-file
Aug 23, 2026
Merged

feat(core): move DeepestErrorFinder into dedicated deepest_error.rs#398
codeZe-us merged 1 commit into
Toolbox-Lab:mainfrom
JuliobaCR:fix/393-deepest-error-dedicated-file

Conversation

@JuliobaCR

Copy link
Copy Markdown
Contributor

Summary

Closes #393.

DeepestErrorFinder was previously implemented as part of #378 inside chain_analyzer.rs. This PR moves it into its own dedicated module, crates/core/src/decode/deepest_error.rs, matching the file location specified in #393.

  • DeepestError / DeepestErrorFinder / find_deepest_error extracted into crates/core/src/decode/deepest_error.rs.
  • Shared call-stack bookkeeping and failure-detection helpers (is_failure, topic_to_string, hash_to_strkey, StackFrame) made pub(crate) in chain_analyzer.rs so the two analyzers reuse identical logic instead of duplicating it.
  • Re-exported from decode::mod (DeepestError, DeepestErrorFinder, find_deepest_error).
  • Fixed an off-by-one bug in the reported call depth: it was computed from the post-push stack length instead of the depth of the frame that was actually active when the failure fired. This under-reported the depth by one on every failure nested 2+ levels deep (e.g. a 3-call chain reported depth 3 instead of 2).
  • Added test coverage for 4-level nested failures and recursive re-entry, in addition to the existing cases carried over from DeepestErrorFinder: pinpoint root via event depth #378.

Test plan

  • cargo test -p grat-core --lib -- decode:: — 212 passed, 0 failed (includes 20 deepest_error tests, all chain_analyzer/walker tests unaffected).
  • Verified the depth fix by hand-tracing the call-stack algorithm against the multi-level nested-failure test cases.

Note: main currently fails to build (cargo check -p grat-core) due to ~15 pre-existing, unrelated errors in multi_op_decoder.rs and report.rs (likely from an incomplete merge of #390). Those are out of scope here; to validate this change I temporarily patched around them in a disposable local clone only, not in this branch.

@coderabbitai

coderabbitai Bot commented Aug 22, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: acc76df2-6f77-4cf4-a652-5054b9c896fb


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@JuliobaCR

JuliobaCR commented Aug 22, 2026

Copy link
Copy Markdown
Contributor Author

The failing Rust Checks / Check formatting step is not caused by this PR. cargo fmt --check runs repo-wide, and it stops on pre-existing, unrelated formatting drift in files this PR never touches, e.g. argument_decoder.rs, return_decoder.rs, spec/decoder.rs, spec/tests/wasm_tests.rs. This diff itself (chain_analyzer.rs, deepest_error.rs, decode/mod.rs) is rustfmt-clean.

The job never even reaches the compile/test steps because it fails at formatting first, but for reference, main also currently fails cargo check -p grat-core on its own (~15 unrelated errors in multi_op_decoder.rs and report.rs, likely from an incomplete merge of #390), as noted in the PR description. I verified this change compiles and passes (cargo test -p grat-core --lib -- decode:: → 212 passed, 0 failed) by patching around those pre-existing issues in a disposable local clone only , none of that is part of this diff.

Happy to rebase once main is green again, or to open a separate issue for the formatting/build breakage if that's useful.

@codeZe-us
codeZe-us self-requested a review August 22, 2026 10:37
@codeZe-us

Copy link
Copy Markdown
Contributor

@JuliobaCR thanks, yes i will resolve the formatting issues on my end, i have reviewed your PR, it is okay. Thanks.

@codeZe-us

Copy link
Copy Markdown
Contributor

@JuliobaCR fix conflicts in your pr, main branch issues have been resolved

@codeZe-us

Copy link
Copy Markdown
Contributor

@JuliobaCR i am expecting your changes

Issue Toolbox-Lab#393 asks for DeepestErrorFinder to live in its own file
(crates/core/src/decode/deepest_error.rs) rather than inside
chain_analyzer.rs where it was implemented for Toolbox-Lab#378. Extracts the
struct, finder, and tests into the dedicated module, re-exporting via
decode::mod, and fixes an off-by-one in the reported call depth: the
failure depth was read from the post-push stack length instead of the
depth of the frame that was actually active when the failure fired,
which under-reported the true depth by one on every nested (2+ level)
failure. Adds coverage for 4-level nesting and recursive re-entry.
@JuliobaCR
JuliobaCR force-pushed the fix/393-deepest-error-dedicated-file branch from 854c37c to 7bf2e0a Compare August 23, 2026 16:28
@JuliobaCR

Copy link
Copy Markdown
Contributor Author

@codeZe-us Conflicts resolved — rebased onto the updated main and force-pushed.

  • Rebased fix/393-deepest-error-dedicated-file onto main (now that the pre-existing build issues you mentioned are fixed).
  • Resolved the two conflicts in chain_analyzer.rs / decode/mod.rs: main still had DeepestErrorFinder embedded in chain_analyzer.rs, while this branch had already moved it out to deepest_error.rs. Kept the moved version (it already carries its own 17 tests) and dropped the now-duplicated code/tests from chain_analyzer.rs.
  • Fixed a couple of trivial clippy nits (map().unwrap_or(...)map_or, single-match-else → if let) in the moved code while I was in there.

Verified locally (matching the CI steps):

  • cargo fmt --all -- --check — clean
  • cargo build --workspace --all-targets --all-features — clean
  • cargo test --workspace --all-targets --all-features — 340 passed, 0 failed

PR now shows as mergeable/clean against main. Let me know if anything else is needed.

@codeZe-us

Copy link
Copy Markdown
Contributor

@JuliobaCR Thanks, PR reviewed and merged

@codeZe-us
codeZe-us merged commit 6f13661 into Toolbox-Lab:main Aug 23, 2026
3 checks passed
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.

Diagnostics Surface the Wrong Error in Deeply Nested Contract Call Failures

2 participants