refactor(vm): replace custom JSON types with standard Amino encoding (alternative to #4972)#5274
refactor(vm): replace custom JSON types with standard Amino encoding (alternative to #4972)#5274
Conversation
🛠 PR Checks SummaryAll Automated Checks passed. ✅ Manual Checks (for Reviewers):
Read More🤖 This bot helps streamline PR reviews by verifying automated checks and providing guidance for contributors and reviewers. ✅ Automated Checks (for Contributors):No automated checks match this pull request. ☑️ Contributor Actions:
☑️ Reviewer Actions:
📚 Resources:Debug
|
6bb8194 to
31b0729
Compare
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
Use ExportRefValue with ":N" IDs for cycle-breaking references instead of RefValue with synthetic ObjectIDs. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
31b0729 to
f3bed45
Compare
Wire up the QueryEvalJSON and QueryObject keeper methods to the ABCI query handler so they are accessible via vm/qeval_json and vm/qobject endpoints. Also adds both methods to the VMKeeperI interface. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Regenerate gnolang.proto to include ExportRefValue message - Fix gofmt formatting in values_export.go - Add QueryEvalJSON and QueryObject to mockVMKeeper Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Factor out exportObject helper shared by JSON and binary variants. Add vm/qobject_binary route, QueryObjectBinary keeper method, and interface/mock updates. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add txtar integration tests exercising the new query endpoints end-to-end: - qeval_json: primitives, strings, structs, slices, multiple returns, errors - qobject_json/qobject_binary: error handling for invalid/missing ObjectIDs, RefValue presence for persisted pointers Also register ObjectNotFoundError with Amino and regenerate vm.proto. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…rface tests Add tests for uncovered export paths: maps, functions, closures, interfaces, int slices, list arrays, multiple returns, ExportObject, and heap items (captured variables). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add handler tests for qeval_json, qobject_json, qobject_binary, and unknown endpoint queries. Add additional export value tests for bound methods, declared types, map[string]struct, nested slices, type values, structs with methods, and recursive structs. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add handler success path tests for qobject_json and qobject_binary. Add export type tests for InterfaceType, ChanType, tupleType, uint values, BigintValue nil, and Block objects. Add WillSetParam tests for auth and bank params. Add helper.go tests for MustParam functions. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove TestExportValuesClosure (duplicate of HeapItem), TestExportValuesStructWithMethods (duplicate of struct value), TestExportValuesTypeValue (weak assertions), TestExportCopyValue_UintValues (covered by Primitive table), TestExportValuesNestedSlice (no new branch), TestExportValuesMapStringStruct (map already covered), and TestVmHandlerQuery_ObjectBinary error-only test (same parsing as JSON). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
The PR description says "Add This includes the type information for the |
| stdout '"results":\[' | ||
| stdout 'PrimitiveType' |
There was a problem hiding this comment.
It seems like a good idea to test against the entire reply rather than checking for substrings. (whole file)
|
@gfanton ok. lets keep both for now but migrate over time to orthogonal APIs. qdocs returning types is not orthogonal (it's composite) because well, a package doc isn't doc about any type, it's about names. So really qdoc should change to not return type information, and qtypes should be called separately to get type information without docs. For now this is what we need for #5283 (new state explorer) MVP. I don't think the state explorer should be showing docs though. For JS library UX the misc/gnojs javascript library is where we can make composite APIs built upon the orthogonal APIs. |
Summary
This builds on @gfanton's PR #4972.
JSONField,JSONStructValue,JSONArrayValue,JSONMapValue,JSONMapEntry,JSONObjectInfotypes from gnolangExportValues()+amino.MarshalJSON()instead — the same encoding already used for persistencetryGetErrorpanic-safe: re-panics OOG, gracefully degrades on other panics (omits@errorfield)Follow-up PR
A separate PR for a state explorer will add:
vm/qtypequery endpoint for fetching type definitions (including struct field names)Test plan
convert_test.gotests pass (primitives, structs, slices, pointers, maps, declared types, cycles, errors)keeper_test.gotests pass (persisted objects, nested object traversal, JSON formatting)values_export_test.gotests pass.Error()gracefully omits@errorfield.Error()properly re-panics🤖 Generated with Claude Code