Skip to content

fix(gnovm): persist function-local declared types referenced by saved values#5894

Open
ltzmaxwell wants to merge 8 commits into
gnolang:masterfrom
ltzmaxwell:fix/maxwell/local_type_persist
Open

fix(gnovm): persist function-local declared types referenced by saved values#5894
ltzmaxwell wants to merge 8 commits into
gnolang:masterfrom
ltzmaxwell:fix/maxwell/local_type_persist

Conversation

@ltzmaxwell

@ltzmaxwell ltzmaxwell commented Jul 3, 2026

Copy link
Copy Markdown
Contributor
  • Function-local declared types are never SetType'd (only package-level types are, at addpkg), so persisting a value referencing one writes a dangling RefType; after a node restart every access panics with unexpected type with id ... — the realm state is permanently unreadable. Reproduces on master via interface-typed package vars and closure captures.
  • Fix: a localTypeSaver walk in saveObject persists reachable function-local types before SetObject; copyTypeWithRefs preserves ParentLoc so the local type's TypeID survives the persist/reload round trip.
  • Defense-in-depth: a debugAssert-gated invariant in SetObject panics at save time on any dangling function-local type ref, so a missed route fails loudly inside the rolled-back tx instead of committing unreadable state.
  • Tests: restart txtars are the true reproducers (fail on master) — interface var / closure / bound method value, cross-realm, p/-package local type, map-key TypeID stability, reload→mutate→resave across two restarts; zrealm_localtype* filetests guard the save side under -tags debugAssert and pin the on-the-wire RefType shape.
  • Also unblocks fix(gnovm): match Go's call-time dispatch for interface-bound method values #5737, whose call-time method dispatch persists the interface-boxed operand and newly hits this hole. ADR: gnovm/adr/pr5894_local_type_persist.md.

@Gno2D2

Gno2D2 commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

🛠 PR Checks Summary

All Automated Checks passed. ✅

Manual Checks (for Reviewers):
  • IGNORE the bot requirements for this PR (force green CI check)
Read More

🤖 This bot helps streamline PR reviews by verifying automated checks and providing guidance for contributors and reviewers.

✅ Automated Checks (for Contributors):

🟢 Maintainers must be able to edit this pull request (more info)

☑️ Contributor Actions:
  1. Fix any issues flagged by automated checks.
  2. Follow the Contributor Checklist to ensure your PR is ready for review.
    • Add new tests, or document why they are unnecessary.
    • Provide clear examples/screenshots, if necessary.
    • Update documentation, if required.
    • Ensure no breaking changes, or include BREAKING CHANGE notes.
    • Link related issues/PRs, where applicable.
☑️ Reviewer Actions:
  1. Complete manual checks for the PR, including the guidelines and additional checks if applicable.
📚 Resources:
Debug
Automated Checks
Maintainers must be able to edit this pull request (more info)

If

🟢 Condition met
└── 🟢 And
    ├── 🟢 The base branch matches this pattern: ^master$
    └── 🟢 The pull request was created from a fork (head branch repo: ltzmaxwell/gno)

Then

🟢 Requirement satisfied
└── 🟢 Maintainer can modify this pull request

Manual Checks
**IGNORE** the bot requirements for this PR (force green CI check)

If

🟢 Condition met
└── 🟢 On every pull request

Can be checked by

  • Any user with comment edit permission

@ltzmaxwell ltzmaxwell changed the title fix(gnovm): persist function-local declared types referenced by saved values WIP fix(gnovm): persist function-local declared types referenced by saved values Jul 3, 2026
@ltzmaxwell ltzmaxwell changed the title WIP fix(gnovm): persist function-local declared types referenced by saved values fix(gnovm): persist function-local declared types referenced by saved values Jul 6, 2026
@ltzmaxwell ltzmaxwell requested review from davd-gzl, omarsy and thehowl July 6, 2026 05:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

📦 ⛰️ gno.land Issues or PRs gno.land package related 📦 🤖 gnovm Issues or PRs gnovm related

Projects

Development

Successfully merging this pull request may close these issues.

2 participants