Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

v1 source realm

untrusted-render: records are seeded in init or derived from lazy/v0's own init; this realm exposes no setter, so no ...

Readme View source

gno.land/r/moul/x/upgrade/lazy/v1

Version 1 of the lazy migration pattern (pattern D). Declares a new record shape and converts each v0 record on first touch.

Migrating writes, and writing means crossing, so Get(cur, key) is a transaction and is invisible to vm/qeval and to Render. Peek(key) is the free read-only half: same value, no migration.

See the pattern and the exploration.


Part of moul/gno-contracts — moul's versioned gno.land contracts. See the repository for the full catalog, build/test tooling, and usage.

Dependency graph:

gno.land/r/moul/x/upgrade/lazy/v1 dependency graph

🧪 Highly experimental — potentially vibe-coded. Not audited; may break, change, or be removed at any time. Do not use with anything of value. Full disclaimer: DISCLAIMER.

Overview

untrusted-render: records are seeded in init or derived from lazy/v0's own init; this realm exposes no setter, so no caller string ever reaches Render.

Package lazy is version 1 of the "lazy migration" upgrade pattern (pattern D of the exploration; see ../README.md).

v1 changes the stored shape (Score widens, Active is new) and migrates one record at a time, on first touch, paid for by whoever touched it. There is no migration transaction and no pause.

The catch on today's gno: migrating on read MUTATES, so the read path has to be a crossing function. Get therefore costs a transaction and is invisible to vm/qeval and to Render. Peek is the honest read-only half, and it reports the pre-migration answer for records that have not been touched yet.

Functions 5

func Pending

Action
1func Pending() int
source

Pending is how many v0 records have never been touched. It is only a bound: v0 keeps every record it ever had, migrated or not.

func Get

crossing Action
1func Get(cur realm, key string) *Record
source

Get returns a record, migrating it from v0 on first touch.

Crossing, because the migration writes. That is the cost of the pattern: the cheapest possible read is now a transaction.

func Peek

Action
1func Peek(key string) *Record
source

Peek is the read-only half: it never migrates, so a record that has not been touched yet reads as its v0 self converted on the fly and NOT stored.

Types 1

type Record

struct
1type Record struct {
2	Name   string
3	Score  int64
4	Active bool
5}
source

Record is v1's shape: Score widened to int64 and scaled by 1000, plus a new Active flag that migrated records get set to true.

Methods on Record

func String

method on Record
1func (r *Record) String() string
source

Imports 3

Source Files 4