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

lazy/v1 package

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

Migrated

func Migrated() int

Migrated is how many records have actually moved over.

Command

gnokey query vm/qeval -remote "https://rpc.gno.land" -data "gno.land/r/moul/x/upgrade/lazy/v1.Migrated()"

Result

Pending

func Pending() int

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.

Command

gnokey query vm/qeval -remote "https://rpc.gno.land" -data "gno.land/r/moul/x/upgrade/lazy/v1.Pending()"

Result

Render

func Render(_ string) string

Param

Command

gnokey query vm/qeval -remote "https://rpc.gno.land" -data "gno.land/r/moul/x/upgrade/lazy/v1.Render()"

Result

Get

func Get(cur realm, key string) *Record

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.

Param

Command

# WARNING: This command is running in an INSECURE mode.
# It is strongly recommended to use a hardware device for signing
# and avoid trusting any computer connected to the internet,
# as your private keys could be exposed.

gnokey maketx call -pkgpath "gno.land/r/moul/x/upgrade/lazy/v1" -func "Get" -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "gnoland-1" -remote "https://rpc.gno.land" ADDRESSgnokey query -remote "https://rpc.gno.land" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/moul/x/upgrade/lazy/v1" -func "Get" -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -broadcast=false ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "gnoland-1" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "https://rpc.gno.land" call.tx
  

Peek

func Peek(key string) *Record

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.

Param

Command

gnokey query vm/qeval -remote "https://rpc.gno.land" -data "gno.land/r/moul/x/upgrade/lazy/v1.Peek()"

Result