Skip to content

refactor(avl): call the chain's single-value Get and drop the vendored fork - #73

Open
davd-gzl wants to merge 1 commit into
feat/topaz-v2-renamefrom
fix/avl-get-single-value
Open

davd-gzl wants to merge 1 commit into
feat/topaz-v2-renamefrom
fix/avl-get-single-value

Conversation

@davd-gzl

@davd-gzl davd-gzl commented Jul 27, 2026 •

Copy link
Copy Markdown
Collaborator

p/samcrew/avl is a fork of a package we already vendor, kept only because its Tree.Get returns (value, exists) where the chain's returns a single value. It has to be exempted from the provenance byte-comparison, and that exemption is the one hole in the job: it matches a directory prefix, but the compiler resolves a package by the module line in its gnomod.toml. A directory under vendored/gno.land/p/samcrew/avl/ can therefore claim any package path, become what the build compiles, and still get drift 0.

Calling the chain's own Get removes the fork and the exemption with it. An absent key reads back as nil, so the type assertion that already followed every lookup settles absent and wrong-type at once:

roleData, ok := m.Roles.Get(role).(*Role)

Six lookups panicked on a present-but-wrong-typed entry instead of falling through. They keep that, via Has in the failure path, and store_corruption_test.gno goes red if any of the six is dropped.

Provenance now covers all 118 vendored files with no source exemption, and the shadow directory above is caught as MISSING UPSTREAM. The two fork-specific CI steps are deleted. NOTICE recorded 2c7f1abe while the Makefile pins fc40526; it now matches.

Lint clean, 10 of 10 test targets green.

…d fork

topaz-1's stdlib p/nt/avl/v0 exposes a single-value Get. gnodaokit called
the two-value form, so a fork of avl carrying that signature was vendored
alongside the real dependency closure, exempted from the provenance
byte-comparison, and guarded by two bespoke CI steps instead.

Calling the chain's own shape removes all of it. An absent key reads back
as nil, so the type assertion that already followed every lookup settles
absent and wrong-type in one step:

    roleData, ok := m.Roles.Get(role).(*Role)
    if !ok {
        // absent, or not a *Role
    }

That collapses 13 duplicated `if !ok` blocks in members.gno alone.

Six lookups treated a present-but-wrong-typed entry differently from an
absent one, panicking rather than falling through. The stores are exported
avl trees, so a same-realm write can produce either, and the distinction is
worth keeping: absent is a normal answer and a wrong type is a bug. Those
six check Has in the failure path so the panic survives, with a test that
goes red when any of them is removed.

vendored/gno.land/p/samcrew/avl/ is deleted, and with it the only source
exemption in the provenance job. Every vendored file is now byte-compared
against gnolang/gno at the pinned GNOVERSION in both directions, so the job
covers 118 files with nothing skipped but this directory's own README,
NOTICE and LICENSE. The stdlib-avl boundary step and the two-value Get step
are gone; the compiler enforces both directly now.

The pinned ref also carries input checks the fork predates: GetByIndex
panics on a negative index, TraverseByOffset clamps a negative offset, and
pager.GetPageWithSize panics on a non-positive page size. None is reachable
here. extensions.gno rejects a negative index before GetByIndex and
normalises a negative start before IterateByOffset, ParseQuery clamps a
non-positive size back to the default, and both pager call sites pass 10.

NOTICE recorded 2c7f1abe while the Makefile pins fc40526; it now matches.
@davd-gzl
davd-gzl marked this pull request as ready for review July 27, 2026 17:01
@davd-gzl
davd-gzl requested a review from zxxma July 27, 2026 17:01
@davd-gzl

Copy link
Copy Markdown
Collaborator Author

To be merged in #65

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.

1 participant