Skip to content

feat: add cross-contract call failure attribution analyzer (#246)#252

Open
Awointa wants to merge 1 commit into
Toolbox-Lab:mainfrom
Awointa:feat/cross-contract-failure-attribution
Open

feat: add cross-contract call failure attribution analyzer (#246)#252
Awointa wants to merge 1 commit into
Toolbox-Lab:mainfrom
Awointa:feat/cross-contract-failure-attribution

Conversation

@Awointa

@Awointa Awointa commented Jun 19, 2026

Copy link
Copy Markdown

closes #246

Summary

When a cross-contract call fails, the error previously surfaced at the top
level with no indication of which contract in the call chain actually caused
it. This PR implements an analyzer that traces the diagnostic event stream to
pinpoint the exact origin.

What changed

  • crates/core/src/decode/cross_contract.rs — new analyzer that walks
    diagnosticEventsXdr in order, maintains a call stack via fn_call/fn_return
    host events, and detects the first error/panic event to identify the failing
  • crates/core/src/types/report.rs — new FailureAttribution struct
    (contract_address, function_name, call_depth, origin_description) and
    cross_contract_attribution: Option field on
    DiagnosticReport
  • crates/core/src/decode/mod.rs — wires cross_contract::attribute_failure into
    the decode pipeline after diagnostic enrichment
  • crates/cli/src/output/human.rs — renders a Cross-Contract Failure
    Attribution section when attribution is present

Behaviour

Attribution is only populated when the failure depth is > 0, meaning a
sub-contract caused the error. Top-level-only failures are unaffected and
produce no attribution noise.

Testing

  • cargo check -p prism-core ✅
  • cargo check -p prism ✅

Walk diagnostic event stream to detect fn_call/fn_return boundaries
and error/panic events to pinpoint the exact contract and function
in a sub-contract call chain that caused the failure.

- Add FailureAttribution struct to types/report.rs
- Add cross_contract_attribution field to DiagnosticReport
- New decode/cross_contract.rs: attribute_failure() analyzer
- Wire attribute_failure into decode pipeline (decode/mod.rs)
- Render attribution section in CLI human output (human.rs)
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.

Trace the Diagnostic Event Stream to Find Which Contract in a Chain Actually Failed

1 participant