Skip to content

feat(core): parse UdtStructV0 struct metadata from contract spec WASM - #400

Merged
codeZe-us merged 4 commits into
Toolbox-Lab:mainfrom
Agbasimere:feat/parse-udt-struct-v0
Aug 22, 2026
Merged

feat(core): parse UdtStructV0 struct metadata from contract spec WASM#400
codeZe-us merged 4 commits into
Toolbox-Lab:mainfrom
Agbasimere:feat/parse-udt-struct-v0

Conversation

@Agbasimere

Copy link
Copy Markdown
Contributor

Summary

  • Parse ScSpecEntry::UdtStructV0 from contractspecv0 into cacheable ContractStructDef entries on ContractSpec (name, fields, ScSpecTypeDef).
  • Keep nested/cyclic UDTs memory-safe: UDT names are not expanded during parse, XDR decode is bounded, and type formatting is depth-capped to avoid stack overflow.
  • Cover nested structs, self-referential and mutually recursive UDTs, deep container nesting, and JSON roundtrip of the parsed spec.

Test plan

  • cargo test -p grat-core --lib spec:: (27 passed)
  • cargo fmt --all -- --check (currently fails on pre-existing files outside this change)
  • cargo test --workspace --all-targets --all-features on Ubuntu CI (local MSVC SDK is missing kernel32.lib; multi_op_decoder also does not compile against stellar-xdr 21)
  • Decode a contract return value that is a custom struct and confirm fields are labeled JSON

Closes: #395

Extract named struct fields from contractspecv0 so return values can be decoded as labeled JSON, with bounded XDR and type-depth limits so cyclic or hostile specs cannot stack-overflow the parser.
@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: da8c5f32-9939-48e7-97c3-7109f09f2b33


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.

Agbasimere and others added 3 commits August 22, 2026 15:39
The main merge dropped the helpers that decoder.rs still calls, which broke CI with E0433/E0425.
Restore struct-name tracking after the main merge left seen_structs unused, which made rustc fail with E0282 on CI.
@codeZe-us
codeZe-us self-requested a review August 22, 2026 18:51

@codeZe-us codeZe-us left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@Agbasimere PR reviewed and merged

@codeZe-us
codeZe-us merged commit da36f1c into Toolbox-Lab:main Aug 22, 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.

Contract Struct Definitions Are Not Parsed From WASM Metadata

2 participants