Repository navigation
Update PHILOSOPHY.md - #2
Merged
Merged
Conversation
Contributor
|
Thank you! |
7 tasks done
7 tasks
thehowl
added a commit
that referenced
this pull request
Jan 15, 2024
Before:
```
gno test -verbose .
=== RUN TestFtoa
panic: cannot convert BigintKind to Uint64Kind
goroutine 1 [running]:
github.com/gnolang/gno/gnovm/pkg/gnolang.ConvertTo(0x0, {0xecc8b8, 0xc00026c3f0}, 0xc00011e190, {0xebe6d8, 0xeb0d78})
/home/howl/oc/gno/gnovm/pkg/gnolang/values_conversions.go:868 +0x6479
github.com/gnolang/gno/gnovm/pkg/gnolang.(*Machine).doOpConvert(0xc0000f4a20)
/home/howl/oc/gno/gnovm/pkg/gnolang/op_expressions.go:699 +0x71
github.com/gnolang/gno/gnovm/pkg/gnolang.(*Machine).Run(0xc0000f4a20)
/home/howl/oc/gno/gnovm/pkg/gnolang/machine.go:1227 +0xfce
[... more stacktrace ...]
```
After:
```
=== RUN TestFtoa
.: test pkg: panic: cannot convert BigintKind to Uint32Kind
gno machine: Machine:
CheckTypes: false
Op: [OpHalt OpBody OpRangeIter OpPopBlock OpBody OpReturn OpBody OpPopResults OpExec OpBody OpPopResults OpExec OpBody OpForLoop OpPopBlock OpBody OpDefine OpBody OpReturn OpPrecall OpBody OpPopBlock OpBody OpPopBlock OpBody OpPopBlock OpBody OpPopResults OpExec OpBody OpDefine]
Values: (len: 9)
#8 (ryuFtoaFixed32 func(d *gno.land/r/fG5GBXmX.decimalSlice,mant uint32,exp int,prec int)())
#7 (genericFtoa func(dst []uint8,val float64,fmt uint8,prec int,bitSize int)( []uint8))
#6 (typeval{string} type{})
#5 (FormatFloat func(f float64,fmt uint8,prec int,bitSize int)( string))
#4 (TestFtoa func(t *testing.T)())
#3 (tRunner func(t *testing.T,fn testing.testingFunc,logSteps bool)())
#2 (RunTest func(runFlag string,verbose bool,test testing.InternalTest)(ret string))
#1 (slice[(struct{("TestFtoa" string),(TestFtoa func(t *testing.T)())} testing.InternalTest),(struct{("TestFormatFloatInvalidBitSize" string),(TestFormatFloatInvalidBitSize func(t *testing.T)())} testing.InternalTest)] []testing.InternalTest)
#0 (runtest func(name string)(report string))
Exprs:
#0 (const-type string)(genericFtoa<VPBlock(3,12)>((const (make func(t type{},z ...interface{})( []uint8)))([](const-type uint8), (const (0 int)), max<VPBlock(3,21)>(prec<VPBlock(1,2)> + (const (4 int)), (const (24 int)))), f<VPBlock(1,0)>, fmt<VPBlock(1,1)>, prec<VPBlock(1,2)>, bitSize<VPBlock(1,3)>))
Stmts:
#16 bodyStmt[0/0/12]=di<VPBlock(1,7)>, dfrac<VPBlock(1,12)> := di<VPBlock(1,7)> >> extra<VPBlock(1,10)>, di<VPBlock(1,7)> & extraMask<VPBlock(1,11)>*
#15 return
#14 bodyStmt[0/0/2]=ok<VPBlock(4,12)> = (const (true bool))
#13 bodyStmt[0/0/4]=(end)
#12 bodyStmt[0/0/1]=(end)
#11 bodyStmt[0/0/14]=if !ok<VPBlock(2,12)> { return bigFtoa<VPBlock(4,13)>(dst<VPBlock(2,0)>, prec<VPBlock(2,3)>, fmt<VPBlock(2,2)>, (const-type bool)(neg<VPBlock(2,8)>), mant<VPBlock(2,10)>, exp<VPBlock(2,9)>, flt<VPBlock(2,7)>) }
#10 bodyStmt[0/0/1]=(end)
#9 bodyStmt[0/0/1]=if (const-type bool)(s<VPBlock(2,0)> != test<VPBlock(3,1)>.s) { t<VPBlock(4,0)>.Error((const ("testN=32" string)), test<VPBlock(3,1)>.f, (const-type string)(test<VPBlock(3,1)>.fmt), test<VPBlock(3,1)>.prec, (const ("want" string)), test<VPBlock(3,1)>.s, (const ("got" string)), s<VPBlock(2,0)>) }*
#8 bodyStmt[0/0/6]=(end)
#7 bodyStmt[0/0/1]=(end)
#6 return
#5 bodyStmt[0/0/4]=t<VPBlock(1,0)>.finished = (const (true bool))
#4 return
#3 bodyStmt[0/0/3]=report<VPBlock(1,5)> := t<VPBlock(1,4)>.report()
#2 bodyStmt[0/0/1]=(end)
#1 bodyStmt[2/0/1]=(end)
#0 bodyStmt[0/0/1]=panic((const ("no such test: " string)) + name<VPBlock(1,0)>)*
Blocks:
@(1) Block(ID:0000000000000000000000000000000000000000:0,Addr:0xc004f2d2c0,Source:func ryuFtoaFixed32(d *(decimalS...,Parent:0xc000bf43c0)
d: (&0xc004331cb8.(*gno.land/r/fG5GBXmX.decimalSlice) *gno.land/r/fG5GBXmX.decimalSlice)
mant: (16777216 uint32)
exp: (-23 int)
prec: (6 int)
e2: (-24 int)
q: (5 int)
exact: (true bool)
di: (1638400000 uint32)
dexp2: (-14 int)
d0: (true bool)
extra: (14 uint)
extraMask: (undefined)
dfrac: (undefined)
roundUp: (undefined)
(s vals) @(1) Block(ID:0000000000000000000000000000000000000000:0,Addr:0xc00036bc20,Source:func ryuFtoaFixed32(d *(decimalS...,Parent:0xc00052f620)
d: (nil *gno.land/r/fG5GBXmX.decimalSlice)
mant: (0 uint32)
exp: (0 int)
prec: (0 int)
e2: (0 int)
q: (0 int)
exact: (false <untyped> bool)
di: (0 uint32)
dexp2: (0 int)
d0: (false bool)
extra: (0 uint)
extraMask: (0 uint32)
dfrac: (0 uint32)
roundUp: (false bool)
(s typs) @(1) [*gno.land/r/fG5GBXmX.decimalSlice uint32 int int int int <untyped> bool uint32 int bool uint uint32 uint32 bool]
@(2) Block(ID:89285d5563b8e2373ce3416c367151d9c4102930:5,Addr:0xc000bf43c0,Source:file{ package strconv; import bi...,Parent:0xc0003325a0)
bits: (package(bits math/bits) package{})
(s vals) @(2) Block(ID:0000000000000000000000000000000000000000:0,Addr:0xc00052f620,Source:file{ package strconv; import bi...,Parent:0xc00037ede0)
bits: (package(bits math/bits) package{})
(s typs) @(2) [package{}]
@(3) gno.land/r/fG5GBXmX
Blocks (other):
#13 Block(ID:0000000000000000000000000000000000000000:0,Addr:0xc004f2d0e0,Source:if (const-type bool)(bitSize<VPB...,Parent:0xc004f2cd20)
(static) #13 Block(ID:0000000000000000000000000000000000000000:0,Addr:0xc00016b020,Source:if (const-type bool)(bitSize<VPB...,Parent:0xc00016bac8)
#12 Block(ID:0000000000000000000000000000000000000000:0,Addr:0xc004f2cd20,Source:if (const-type bool)(fmt<VPBlock...,Parent:0xc004f2cb40)
(static) #12 Block(ID:0000000000000000000000000000000000000000:0,Addr:0xc00016b820,Source:if (const-type bool)(fmt<VPBlock...,Parent:0xc000170568)
#11 Block(ID:0000000000000000000000000000000000000000:0,Addr:0xc004f2cb40,Source:if (const-type bool)(shortest<VP...,Parent:0xc004f2be00)
(static) #11 Block(ID:0000000000000000000000000000000000000000:0,Addr:0xc000170020,Source:if (const-type bool)(shortest<VP...,Parent:0xc000701420)
#10 Block(ID:0000000000000000000000000000000000000000:0,Addr:0xc004f2be00,Source:func genericFtoa(dst [](const-ty...,Parent:0xc0017a0000)
dst: (slice[0x] []uint8)
val: (1 float64)
fmt: (101 uint8)
prec: (5 int)
bitSize: (32 int)
.res_0: (nil []uint8)
bits: (1065353216 uint64)
flt: (&0xc005fd7668.(*gno.land/r/fG5GBXmX.floatInfo) *gno.land/r/fG5GBXmX.floatInfo)
neg: (false bool)
exp: (0 int)
mant: (8388608 uint64)
digs: (struct{(slice[0x000000000000000000000000000000000000000000000000] []uint8),(0 int),(0 int)} gno.land/r/fG5GBXmX.decimalSlice)
ok: (false bool)
shortest: (false bool)
(static) #10 Block(ID:0000000000000000000000000000000000000000:0,Addr:0xc000701420,Source:func genericFtoa(dst [](const-ty...,Parent:0xc00023c2e0)
dst: (nil []uint8)
val: (0 float64)
fmt: (0 uint8)
prec: (0 int)
bitSize: (0 int)
.res_0: (nil []uint8)
bits: (undefined)
flt: (undefined)
neg: (false <untyped> bool)
exp: (0 int)
mant: (0 uint64)
digs: (undefined)
ok: (false bool)
shortest: (false <untyped> bool)
#9 Block(ID:0000000000000000000000000000000000000000:0,Addr:0xc004f2b680,Source:func FormatFloat(f (const-type f...,Parent:0xc0017a0000)
f: (1 float64)
fmt: (101 uint8)
prec: (5 int)
bitSize: (32 int)
.res_0: ( string)
(static) #9 Block(ID:0000000000000000000000000000000000000000:0,Addr:0xc000700c20,Source:func FormatFloat(f (const-type f...,Parent:0xc00023c2e0)
f: (0 float64)
fmt: (0 uint8)
prec: (0 int)
bitSize: (0 int)
.res_0: ( string)
#8 Block(ID:0000000000000000000000000000000000000000:0,Addr:0xc004f2b4a0,Source:if (const-type bool)((const-type...,Parent:0xc004d60780)
(static) #8 Block(ID:0000000000000000000000000000000000000000:0,Addr:0xc0004e4020,Source:if (const-type bool)((const-type...,Parent:0xc0003fac20)
#7 Block(ID:0000000000000000000000000000000000000000:0,Addr:0xc004d60780,Source:for i<VPBlock(1,0)> := (const (0...,Parent:0xc004d605a0)
i: (0 int)
test: (&0xc0080f1300.(*gno.land/r/fG5GBXmX.ftoaTest) *gno.land/r/fG5GBXmX.ftoaTest)
s: ("1.00000e+00" string)
x: (slice[0x616263312E3030303030652B3030] []uint8)
(static) #7 Block(ID:0000000000000000000000000000000000000000:0,Addr:0xc0003fac20,Source:for i<VPBlock(1,0)> := (const (0...,Parent:0xc000101420)
i: (0 int)
test: (nil *gno.land/r/fG5GBXmX.ftoaTest)
s: ( string)
x: (nil []uint8)
#6 Block(ID:0000000000000000000000000000000000000000:0,Addr:0xc004d605a0,Source:func TestFtoa(t *(testing<VPBloc...,Parent:0xc008cd8000)
t: (&0xc0049c01e0.(*testing.T) *testing.T)
(static) #6 Block(ID:0000000000000000000000000000000000000000:0,Addr:0xc000101420,Source:func TestFtoa(t *(testing<VPBloc...,Parent:0xc0004ee020)
t: (nil *testing.T)
#5 Block(ID:0000000000000000000000000000000000000000:0,Addr:0xc004c39c20,Source:func tRunner(t *(T<VPBlock(2,3)>...,Parent:0xc0083aa780)
t: (&0xc0049c01e0.(*testing.T) *testing.T)
fn: (TestFtoa func(t *testing.T)())
logSteps: (false bool)
(static) #5 Block(ID:0000000000000000000000000000000000000000:0,Addr:0xc001ff8020,Source:func tRunner(t *(T<VPBlock(2,3)>...,Parent:0xc0008ed620)
t: (nil *testing.T)
fn: (nil testing.testingFunc)
logSteps: (false bool)
#4 Block(ID:0000000000000000000000000000000000000000:0,Addr:0xc004c39860,Source:func RunTest(runFlag (const-type...,Parent:0xc0083aa780)
runFlag: ("" string)
verbose: (true bool)
test: (struct{("TestFtoa" string),(TestFtoa func(t *testing.T)())} testing.InternalTest)
ret: ( string)
t: (&0xc0049c01e0.(*testing.T) *testing.T)
report: (undefined)
out: (undefined)
(static) #4 Block(ID:0000000000000000000000000000000000000000:0,Addr:0xc001fefc20,Source:func RunTest(runFlag (const-type...,Parent:0xc0008ed620)
runFlag: ( string)
verbose: (false bool)
test: (nil testing.InternalTest)
ret: ( string)
t: (nil *testing.T)
report: (nil testing.Report)
out: (nil gonative{[]uint8})
#3 Block(ID:0000000000000000000000000000000000000000:0,Addr:0xc004c39680,Source:if (const-type bool)(test<VPBloc...,Parent:0xc004c394a0)
(static) #3 Block(ID:0000000000000000000000000000000000000000:0,Addr:0xc0083f1020,Source:if (const-type bool)(test<VPBloc...,Parent:0xc00bfc6f20)
#2 Block(ID:0000000000000000000000000000000000000000:0,Addr:0xc004c394a0,Source:for _<VPBlock(0,0)>, test<VPBloc...,Parent:0xc004c392c0)
test: (struct{("TestFtoa" string),(TestFtoa func(t *testing.T)())} testing.InternalTest)
(static) #2 Block(ID:0000000000000000000000000000000000000000:0,Addr:0xc00bfc6f20,Source:for _<VPBlock(0,0)>, test<VPBloc...,Parent:0xc009e5e420)
test: (nil testing.InternalTest)
#1 Block(ID:0000000000000000000000000000000000000000:0,Addr:0xc004c392c0,Source:func runtest(name (const-type st...,Parent:0xc004c38f00)
name: ("TestFtoa" string)
report: ( string)
(static) #1 Block(ID:0000000000000000000000000000000000000000:0,Addr:0xc009e5e420,Source:func runtest(name (const-type st...,Parent:0xc0082d1ba0)
name: ( string)
report: ( string)
Frames:
#8 [FRAME FUNC:ryuFtoaFixed32 RECV:(undefined) (4 args) 28/8/1/15/14 LASTPKG:gno.land/r/fG5GBXmX LASTRLM:Realm{Path:"gno.land/r/fG5GBXmX",Time:881}#89285D5563B8E2373CE3416C367151D9C4102930]
#7 [FRAME FUNC:genericFtoa RECV:(undefined) (5 args) 20/7/1/11/10 LASTPKG:gno.land/r/fG5GBXmX LASTRLM:Realm{Path:"gno.land/r/fG5GBXmX",Time:881}#89285D5563B8E2373CE3416C367151D9C4102930]
#6 [FRAME FUNC:FormatFloat RECV:(undefined) (4 args) 17/5/0/10/9 LASTPKG:gno.land/r/fG5GBXmX LASTRLM:Realm{Path:"gno.land/r/fG5GBXmX",Time:881}#89285D5563B8E2373CE3416C367151D9C4102930]
#5 [FRAME LABEL: 13/5/0/8/7]
#4 [FRAME FUNC:TestFtoa RECV:(undefined) (1 args) 11/4/0/6/6 LASTPKG:testing LASTRLM:Realm{Path:"gno.land/r/fG5GBXmX",Time:881}#89285D5563B8E2373CE3416C367151D9C4102930]
#3 [FRAME FUNC:tRunner RECV:(undefined) (3 args) 8/3/0/4/5 LASTPKG:testing LASTRLM:Realm{Path:"gno.land/r/fG5GBXmX",Time:881}#89285D5563B8E2373CE3416C367151D9C4102930]
#2 [FRAME FUNC:RunTest RECV:(undefined) (3 args) 6/2/0/3/4 LASTPKG:gno.land/r/fG5GBXmX LASTRLM:Realm{Path:"gno.land/r/fG5GBXmX",Time:881}#89285D5563B8E2373CE3416C367151D9C4102930]
#1 [FRAME LABEL: 2/1/0/1/2]
#0 [FRAME FUNC:runtest RECV:(undefined) (1 args) 1/0/0/0/1 LASTPKG:gno.land/r/fG5GBXmX LASTRLM:Realm{Path:"gno.land/r/fG5GBXmX",Time:881}#89285D5563B8E2373CE3416C367151D9C4102930]
Realm:
gno.land/r/fG5GBXmX
Exceptions:
[]
stracktrace:
test.go:446 main.runTestFiles.func1
panic.go:914 runtime.gopanic
values_conversions.go:868 gnolang.ConvertTo
op_expressions.go:699 gnolang.(*Machine).doOpConvert
machine.go:1227 gnolang.(*Machine).Run
machine.go:636 gnolang.(*Machine).Eval
test.go:478 main.runTestFiles
test.go:346 main.gnoTestPkg
test.go:257 main.execTest
test.go:99 main.newTestCmd.func1
command.go:233 commands.(*Command).Run
command.go:237 commands.(*Command).Run
command.go:118 commands.(*Command).ParseAndRun
main.go:14 main.main
proc.go:267 runtime.main
asm_amd64.s:1650 runtime.goexit
; panic: gno.land/r/fG5GBXmX_test/decimal_test.gno:5: dot imports not allowed in Gno
gno machine: Machine:
CheckTypes: false
Op: []
Values: (len: 0)
Exprs:
Stmts:
Blocks:
@(1) gno.land/r/fG5GBXmX_test
Blocks (other):
Frames:
Realm:
gno.land/r/fG5GBXmX_test
Exceptions:
[]
stracktrace:
stracktrace:
…no/gnovm/cmd/gno/test.go:446 main.runTestFiles.func1
…/go/src/runtime/panic.go:914 runtime.gopanic
…kg/gnolang/preprocess.go:173 gnolang.Preprocess.func2.1
…/go/src/runtime/panic.go:920 runtime.gopanic
…o/src/math/big/natdiv.go:520 big.nat.div
…b/go/src/math/big/int.go:268 big.(*Int).Quo
…pkg/gnolang/op_binary.go:870 gnolang.quoAssign
…pkg/gnolang/op_binary.go:256 gnolang.(*Machine).doOpQuo
…m/pkg/gnolang/machine.go:1154 gnolang.(*Machine).Run
…m/pkg/gnolang/machine.go:662 gnolang.(*Machine).EvalStatic
…kg/gnolang/preprocess.go:2150 gnolang.evalConst
…kg/gnolang/preprocess.go:784 gnolang.Preprocess.func2
…kg/gnolang/transcribe.go:728 gnolang.transcribe
…kg/gnolang/transcribe.go:371 gnolang.transcribe
…kg/gnolang/transcribe.go:670 gnolang.transcribe
…kg/gnolang/transcribe.go:708 gnolang.transcribe
…kg/gnolang/transcribe.go:133 gnolang.Transcribe
…kg/gnolang/preprocess.go:149 gnolang.Preprocess
…m/pkg/gnolang/machine.go:443 gnolang.(*Machine).runFiles
…m/pkg/gnolang/machine.go:398 gnolang.(*Machine).RunFiles
…no/gnovm/cmd/gno/test.go:466 main.runTestFiles
…no/gnovm/cmd/gno/test.go:346 main.gnoTestPkg
…no/gnovm/cmd/gno/test.go:257 main.execTest
…no/gnovm/cmd/gno/test.go:99 main.newTestCmd.func1
…/pkg/commands/command.go:233 commands.(*Command).Run
…/pkg/commands/command.go:237 commands.(*Command).Run
…/pkg/commands/command.go:118 commands.(*Command).ParseAndRun
…no/gnovm/cmd/gno/main.go:14 main.main
…b/go/src/runtime/proc.go:267 runtime.main
…/src/runtime/asm_amd64.s:1650 runtime.goexit
FAIL
FAIL . 2.19s
FAIL
FAIL
FAIL: 0 build errors, 1 test errors
```
mvertes
added a commit
that referenced
this pull request
Oct 10, 2025
…4587) This is a refreshed attempt similar to #4027. The Go parser from the standard library has been imported in gnovm/pkg/parser, with a Makefile to generate and apply a custom patch, in order to facilitate maintaining. The patch consist to add a new function ParseFileStats which performs accounting to enable gas computation and set the maximum nesting level. The patch content is in `gnovm/pkg/parser/gno.patch`, produced by the makefile. Parsing is instrumented to measure and control the nesting level and have a first cost estimate of parsing to compute gas, before type checking itself. The advantages are that there is almost no overhead, early catch of problems (even before the AST memory is allocated), and a simple gas formula (no distinction between tokens except the nesting level). No extra pass is added, we just exploit some internal parser metadata for prevention of too deep nesting and gas counting. The drawback is to fork and maintain a different version of the Go parser, but most of it is automated. Note: the Go parser imported through the makefile corresponds to the go version installed on host (currently go1.24.6). The maximum parsing nesting limit has been fixed to 10000, instead of previous 100000. It correspond to a maximum AST depth of approximately half of it (ie now 5000 instead of 50000). Now that we measure the cost of parsing, and that the gas counter is part of the Gno VM, the parsing functions have been made methods of `Machine` structure, to access and update the gas counter. If a `nil` Machine is used, the cost will be discarded. Parsing cost function: `number_of_tokens * Logb(nesting_level)` i.e the number of tokens times the binary exponent of the maximum nesting level, in order to penalize more complex code (for a same number of tokens, with a deeper parenthesis or braces nesting level). --------- Co-authored-by: Morgan Bazalgette <[email protected]> Co-authored-by: Miguel Victoria Villaquiran <[email protected]>
This was referenced Mar 17, 2026
clockworkgr
added a commit
that referenced
this pull request
Apr 17, 2026
Every issue below was a latent bug that could corrupt persisted state or silently drop data. All fixes ship together because several interact (#15 ↔ #40, #1 ↔ #9 ↔ #30). Findings closed =============== #1 Iterator does not register a version reader An open iterator at version V did not increment versionReaders[V], so a concurrent PruneVersionsTo(V) could delete nodes the iterator still needed to traverse via getChild. Iterators now register on construction and decrement exactly once on (idempotent) Close. See iterator.go and TestIterator_BlocksPruneUntilClose. #2 Empty-tree branch mishandled orphan value records When a version committed with an empty root, its orphan value records were left in the DB forever. Pruning logic now handles the empty-root case correctly; verified by TestMarkSweepPrune_EmptyOldVersion. #3 Positional-descent prune algorithm mis-identified subtrees The previous prune walked the new version's tree by position and could mistakenly delete nodes that were still reachable from retained versions, triggering cascading "failed to load child node" panics under sustained random-insert + prune workloads. Replaced with a mark-and-sweep implementation that is content-addressed via NodeKey and therefore immune to positional-routing fragility. Regression coverage: TestMarkSweepPrune_SustainedInsertPrune (seeded long-run), FuzzPruneConsistency, FuzzPruneDeepTree, plus the height-3 stress tests in prune_test.go. #6 ValueKey nonce starting at 0 collided with the all-zero sentinel Fresh stores used nonce = 0 on the first value write, which collides with the legacy empty/zero-value sentinel used elsewhere in the store layer. Nonces now start at 1; a migration test in valuekey_nonce_test.go confirms pre-existing stores continue to load. #8 Iterate dropped resolver errors on both trees Value-resolution errors during iteration were swallowed, yielding silent empty values to the caller. Errors now propagate through Iterate on both the ImmutableTree and MutableTree paths; see iterate_error_test.go. #15 PruneVersionsTo had a check-vs-delete TOCTOU against reader registration beginPruning now holds pruneMu across the reader-count check AND the actual DB deletions. incrVersionReaders takes the same lock, so a reader registration is either serialised before the check (rejecting prune with ErrActiveReaders) or after the deletes have completed (observing a consistent post-prune DB). Lock ordering: pruneMu BEFORE mtx on every path. Regression tests: TestPrune_BeginPruningBlocksReaderRegistration, TestPrune_TOCTOU_ReaderRaceIsClosed, TestPrune_BlocksConcurrentReaderRegistration. #26 SaveVersion idempotent-save false mismatch vs legacy empty-tree blob SaveVersion compared the new empty-tree root record against the legacy on-disk representation byte-for-byte, which produced a spurious mismatch and rejected the idempotent save. Comparison now accepts both the legacy zero-length and hash-only empty-root encodings; coverage in idempotent_save_test.go. #30 GetImmutable / immutableForProof did not register version readers A caller holding an ImmutableTree or generating a proof was not reflected in versionReaders[V], so a concurrent PruneVersionsTo(V) could tear the snapshot out from under the caller. Both paths now register and the ImmutableTree.Close() releases (idempotently). Tests: TestGetImmutable_BlocksPruneUntilClose, TestGetImmutable_EmptyVersionRegistersReader, TestImmutableTree_CloseIsIdempotent, TestProof_ReleasesReaderAfterReturn. #40 GetImmutable / immutableForProof registered the reader AFTER loading Registration happened at the end of GetImmutable, so a prune that had already passed beginPruning could delete the root record between our GetRoot call and our incrVersionReaders call; the subsequent loadNode would then hit a partially-pruned DB. Fix: register FIRST, then read the root, with decrVersionReaders on every error path. Same reordering applied to immutableForProof. Regression tests: TestGetImmutable_BlocksOnInFlightPrune, TestGetImmutable_ReleasesReaderOnMissingVersion. Architecture changes ==================== - prune.go: positional-descent implementation removed; mark-and-sweep is now the sole pruning strategy. Leaf-skip optimisation at inner.height == 1 avoids loading children when marking/deleting them by NodeKey bytes. - nodedb.go: pruneMu introduced. Lock order invariant documented (pruneMu BEFORE mtx on every path that touches both). - immutable_tree.go: Close() is idempotent; subsequent calls are no-ops rather than double-decrementing versionReaders. - mutable_tree.go, proof.go, iterator.go: reader registration reordered to precede any DB reads on versioned snapshots. Tests added =========== - version_readers_test.go — reader-registration invariants for GetImmutable, iterators, proofs, and the Finding #40 TOCTOU regressions. - prune_toctou_test.go — Finding #15 blocking invariants and reader/prune race closures. - prune_marksweep_test.go — basic, reload-after-prune, sustained insert+prune, node-count-decreases, shared-subtree preservation, empty-old-version scenarios. - idempotent_save_test.go — Finding #26 legacy-encoding acceptance. - iterate_error_test.go — Finding #8 resolver-error propagation. - valuekey_nonce_test.go — Finding #6 nonce-from-1 + migration. - prune_test.go — expanded height-3 churn / cascading multi-version prune / height oscillation. - fuzz_prune_test.go — native FuzzPruneConsistency + FuzzPruneDeepTree + TestPrune_FuzzLongRun. Verification ============ go test -short -count=1 ./tm2/pkg/bptree/... ./tm2/pkg/store/bptree/... PASS go test -race -short -run 'TestGetImmutable|TestImmutableTree_| TestIterator_|TestProof_|TestPrune_BeginPruningBlocksReaderRegistration| TestPrune_TOCTOU_ReaderRaceIsClosed| TestPrune_BlocksConcurrentReaderRegistration|TestMarkSweepPrune_' PASS
jaekwon
added a commit
that referenced
this pull request
Apr 19, 2026
…shalAmino
Three issues found by auditing the generator for emission of bare type
names into generated Go source:
1. gen_marshal.go writeUnpackedListMarshal: `new(" + ert.Elem().Name() + ")`
dropped the package prefix for cross-package pointer elements
(defense-in-depth; the branch is unreachable via normal code paths).
Now uses ctx.goTypeName.
2. gen_unmarshal.go writeReprUnmarshal: `var repr <rt.Name()>` failed to
compile when the AminoMarshaler's struct repr lived in another package
(e.g. an AminoMarshaler whose MarshalAmino returns crosspkg.Inner).
Now uses ctx.goTypeName.
3. Discovered while adding a regression test for #2: the []*AminoMarshaler
byte-repr decode path declared `var elem *T` (nil pointer) and then
called `elem.UnmarshalAmino(b)`, panicking. Fixed in three sites
(writeSliceReprUnmarshal beOptionByte and non-beOptionByte branches,
and writeUnpackedListUnmarshal beOptionByte branch) to declare elem
as the value type and append &elem for pointer slices.
Regression coverage:
- tm2/pkg/amino/tests/crosspkg: new subpackage with SmallCount (uint8
repr) and Inner (struct repr used as BoxedInt's repr).
- CrossPkgPointerSlice, CrossPkgBoxedRepr test types in tests package.
- TestCrossPkgBoxedReprRoundtrip and TestCrossPkgPointerSliceRoundtrip
in aminomarshaler_list_test.go.
- TestGenerateProtobuf3_CrossPkgQualifiedNames in genproto2_test.go
inspects emitted source for bare vs qualified names.
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
4 tasks done
thehowl
added a commit
that referenced
this pull request
Apr 21, 2026
PR Body
## Summary
Stops redundant `/t/<TypeID>` backend writes and shrinks block bytes
when a realm persists a `TypeValue`. Every `DeclaredType` now gets
exactly one canonical persisted definition at `/t/<TypeID>` (written
by the owning package's deploy), and references to it — whether at a
field position or a `TypeValue` position — serialize as a compact
`RefType{ID}` rather than an inlined copy.
### The four edits
1. `machine.go` `saveNewPackageValuesAndTypes`: only `SetType` types
whose `PkgPath == pv.PkgPath`. Cross-pkg and uverse aliases skipped.
2. `store.go` `SetType`: invert cache check so a cache hit
early-returns (matches the existing "return if tid already known"
comment). Resolves the `TODO classify them and optimize`.
3. `realm.go` `copyTypeWithRefs` `*DeclaredType` case: remove the
uverse guard. It becomes unreachable under #1 + #2.
4. `realm.go` `copyValueWithRefs` `TypeValue` case: use
`refOrCopyType(cv.Type)` instead of `copyTypeWithRefs(cv.Type)`.
Block bytes reference the type instead of inlining its definition.
See [`gnovm/adr/prxxxx_typevalue_ref_persistence.md`][adr] for the
full design rationale, alternatives considered, and consequences.
[adr]: ./gnovm/adr/prxxxx_typevalue_ref_persistence.md
## New filetest infrastructure
- `// Types:` directive (`gnovm/pkg/test/filetest.go`): prints each
package-declared type as `<Name>[<TypeID>]=<persisted JSON>`.
Consistent in style with `// Realm:`.
- Exported helper `gno.PersistedTypeFormForTypeValue(typ Type) Type`
so filetests can render the on-the-wire shape (not the in-memory
post-`fillType` canonical form).
- Three new realm filetests anchor the behavior for each alias case:
- `alias_uverse_realm.gno` — `type MyErr = error`
- `alias_selfpkg_realm.gno` — self-package `type MyAlias = T`
- `alias_crosspkg_realm.gno` — cross-pkg `type TestingT =
uassert.TestingT`
## Test plan
- [x] `go test ./gnovm/pkg/gnolang/` (full filetest suite passes)
- [x] `go test ./gno.land/...` (full tree passes after golden updates)
- [x] Alias filetests show the compact `RefType{ID}` form
- [x] Integration goldens updated: `issue_4983`, `restart_gas`,
`storage_deposit`, `storage_deposit_bank_send`,
`storage_deposit_collector`. Every delta traces to the same
single cause: smaller persisted byte counts.
## Branch base / target
Based on `upstream/master` (`dc30ea6f6`). PR against `master`.
---
Assisted-By: Claude Opus 4.7 (1M context)
---------
Co-authored-by: ltzMaxwell <[email protected]>
Co-authored-by: Morgan Bazalgette <[email protected]>
8 tasks done
clockworkgr
added a commit
that referenced
this pull request
Apr 22, 2026
Closes the nine confirmed findings from the PR #5571 review pass on the v2/v3 leaf-format work (commits 2133015, d56a693, 44a223c). None of the fixes change tree semantics (structure, hashing, versioning, proof format are untouched); they close cache-coherence bugs, silent-corruption passthroughs, and doc/contract drift. Findings #1 and #2 had deterministic reproducers in the review thread that produced wrong root hashes. Finding #6 surfaced a chain-divergence class where a corrupt value-store record made the tree return an empty value with err == nil. The remaining fixes are smaller correctness or documentation closures. Findings closed =============== #1 (HIGH) — leaf-shift loops did not shift slotsDirty in parallel Files: insert.go, remove.go The five leaf-mutation paths (leafInsert / leafRemove / redistributeRight / redistributeLeft / merge LeafNode case) shifted keys, valueHashes, valueKeys, inlineValues, and slotHashes in parallel — but left the slotsDirty bitmap at the pre-shift indices. rebuildMiniMerkleIncremental then trusted slotHashes[i] for the shifted-in slot whose dirty bit had been left at the old index, emitting a corrupt root hash. Reproducer (in slotsdirty_regression_test.go): empty tree → Set(K20), Set(K30), Set(K10) without intervening Hash() → WorkingHash() disagreed with the same three keys committed in sorted order. Fix: added shiftSlotsDirtyUp / shiftSlotsDirtyDown helpers that mirror the existing shiftInlineMaskUp / shiftInlineMaskDown bit shifts. Wired them into all five mutation sites. For the borrow / absorb cases (redistributeRight at lastIdx → 0, redistributeLeft at 0 → dst, merge at i → lBase+i), the moved slot's dirty bit is mirrored into the destination so the destination's slotHashes validity tracks the source's pre-move state. #2 (HIGH) — InnerNode.Clone() omitted miniTreeDirty File: node.go The explicit struct literal in InnerNode.Clone (added in commit 2133015 alongside the new miniTreeDirty field) did not copy the field. Clones got the Go zero value (false), so a clone of a dirty inner answered Hash() from the pre-mutation mini-merkle heap without rebuilding. Reachable via Snapshot() on a dirty root, common after a deeper-level split. Reproducer (in slotsdirty_regression_test.go): build a 64-key tree, mutate to dirty the root inner, clone, assert clone.Hash() matches root.Hash(). Fix: added miniTreeDirty: n.miniTreeDirty to the field list. #3 (LOW) — slotsDirty doc named the wrong rebuild function File: node.go The slotsDirty field doc said "RebuildMiniMerkle skips slots whose key/value did not change". That function actually rebuilds every occupied slot unconditionally; the function honoring slotsDirty is rebuildMiniMerkleIncremental. Doc rewritten to name the right function and to clarify both rebuild paths. #4 / #9 (HIGH / LOW) — InlineValueThreshold doc/resolver contradiction Files: options.go, mutable_tree.go options.go:25-26 documented "Zero selects DefaultInlineValueThreshold" while resolveInlineThreshold mapped opt == 0 to -1 (disabled). DefaultOptions() returns Options{}, so callers following the documented API silently got inline values disabled. Resolved per the implementing commit (d56a693) intent: the default IS disabled; callers opt into inline storage explicitly. Updated all three doc sites (Options.InlineValueThreshold, InlineValueThresholdOption, resolveInlineThreshold) to match the resolver behaviour and removed the temporal "as in pre-v2 behaviour" wording per CLAUDE.md "no temporal docs" rule. #5 (MEDIUM) — Get-hit hydration aliased leaf.inlineValues[i] File: mutable_tree.go The Get path on a tree-walk hit called fastNodes.Add(string(key), val) with val from leaf.valueAt — which returns leaf.inlineValues[i] for inline slots, a slice aliased to the leaf's own storage. The Set path copied via cacheValueForKey; the Get path didn't. A caller-side mutation of the returned bytes would corrupt both leaf and cache. Fix: defensive copy before Add, mirroring cacheValueForKey. #6 (HIGH) — silent corruption passthrough on missing value record Files: errors.go, nodedb.go, prune_test.go nodeDB.GetValue returned (nil, nil) for an absent DB record under a "callers should check val == nil explicitly" convention. No caller actually did, so a corrupt value store (record deleted out-of-band) surfaced as an empty value with err == nil — indistinguishable from a legitimate Get miss. App-layer hashes garbage, chain diverges, no log, no error. Fix: added ErrValueMissing to the typed-error set; nodeDB.GetValue now returns it instead of (nil, nil). The resolver chain (resolveValue, valueResolverFn, leaf.valueAt) bubbles it up naturally to every read path that already checked err. Updated TestPrune_EmptyVersionOrphansCleaned to assert the new contract (was relying on the old (nil, nil) for missing). #7 (MEDIUM) — Remove swallowed resolveValue error File: mutable_tree.go MutableTree.Remove did `val, _ = t.resolveValue(oldPayload.valueKey)` so the caller could not distinguish "old value was nil" from "couldn't read old value". Combined with #6, a corrupt store made Remove return (nil, true, nil) on a key that did exist. Fix: capture the error, log it via t.logger. The slot has already been shifted out of the leaf at this point so returning early would leave the tree in a partially-mutated state with no coherent retry path; logging preserves the diagnostic trail without breaking the Remove contract. A future change could surface a wrapped error distinguishing resolution failure from a healthy no-old-value case. #8 (LOW) — saveBufPool comment described the wrong policy File: nodedb.go The comment said "Buffers return to the pool with a minimum capacity to avoid re-growing on the next large node". The actual policy is the opposite: a MAXIMUM cap (saveBufCapCap = 8 KiB) that discards oversize buffers on Put so a single pathological node doesn't inflate every pooled buffer. Comment rewritten to describe the actual mechanism. #10 (LOW) — ADVANCED_PLAN.md was temporal scaffolding File: ADVANCED_PLAN.md (deleted) The ~400-line file was development scaffolding: phase status table ("✅ landed", "⬜ open"), baseline commit SHAs, benchmark rules addressed to the author. Per CLAUDE.md "NEVER write comments with temporal words... describing what changed", the entire document is temporal. Removed; phase planning belongs in a PR body or an internal wiki, not in the package. Note: finding #11 (benchmarks missing pebbledb) was already addressed by the merge from feat/alex/bp32tree-second-pass (commit dd30b0a). Regression coverage =================== slotsdirty_regression_test.go pins both reproducers from the review thread: - TestRegression_SlotsDirtyShiftedOnInsert — Set(K20),Set(K30), Set(K10) hash matches the same keys committed in sorted order. - TestRegression_InnerCloneCopiesMiniTreeDirty — clone Hash() matches original Hash() after dirtying the root inner. Future changes to leaf-shift discipline or InnerNode.Clone field membership must keep these passing. Verification ============ go test -count=1 -timeout=10m ./tm2/pkg/bptree/... ./tm2/pkg/store/bptree/... PASS (full suite, ~27 s) go test -race -count=1 -timeout=10m -run='TestRegression|TestPrune| TestSet|TestRemove|TestSaveVersion|TestLoadVersion|TestStore| TestImmutable|TestGetImmutable|TestIdempotent' ./tm2/pkg/bptree/ ./tm2/pkg/store/bptree/ PASS (~189 s)
jaekwon
added a commit
that referenced
this pull request
Apr 24, 2026
The amino codec changes in this branch shift the encoded size of consensus-adjacent types (Block, Tx, Commit with AminoMarshaler zero- repr fields) by a small handful of bytes. That propagates through the gas model into the gas-used figures pinned by four txtar fixtures: gc.txtar 151378628 → 151379058 restart_gas.txtar 2820655 → 2821085 (addpkg #1) 2822984 → 2823414 (addpkg #2) 2822998 → 2823428 (addpkg #3 post-restart) gnokey_gasfee.txtar 2814462 → 2814892 (addpkg simulate) 1269324 → 1269754 (call simulate) plus gas-wanted headroom bumps on the two subsequent broadcast txs that feed the simulate numbers. stdlib_restart_compare.txtar 1974482 → 1974912 (EXACT_GAS env var) The gas-fee and fee_delta values in gnokey_gasfee's INFO line stay at 2955ugnot and 206900 — those round the same way despite the ~430-gas delta. The restart_gas test's "pre-restart vs post-restart gas delta" stays constant (14 gas), preserving the test's actual regression signal that restarts don't leak state-dependent cost. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
jaekwon
added a commit
that referenced
this pull request
Apr 24, 2026
…#12,#8,#9) Five generator fixes where the genproto2-emitted UnmarshalBinary2 diverged from the reflect codec's wire-format semantics. All identified via a systematic 349-item audit (BINARY_AUDIT.md) cross-referencing every conditional in BINARY_CONDITIONS.md against the generator. #1 Monotonic fnum check: `fnum < lastFieldNum` → `<=`. Generator was accepting duplicate field numbers in sequence; reflect rejects. #2 writeReprUnmarshal primitive branch now delegates to writePrimitiveDecodeFrom. Honors BinFixed64/32 dispatch (latent; no reachable type today) and slides bz correctly. #3+#12 Top-level trailing-bytes rejection for non-struct types: - packed-slice repr branch now captures DecodeByteSlice's n and slides bz - both non-struct-or-unpacked branches now emit `if len(bz) != 0 { error }` mirroring amino.go:1054. Also renames reflect error text to "trailing bytes after top-level unmarshal" for consistency. #8 ertIsStruct check in list-element encoding now keyed off einfo.Type (Go kind) not einfo.ReprType.Type (wire kind). nil_elements is a Go-side semantic guard — a nil `*Struct` in a list is the footgun whether the repr is struct or string. Reflect (binary_encode.go:399) agrees. Fixed in gen_marshal.go:487 and gen_size.go:396; gen_unmarshal.go:586 isStructLike left alone (decode-strategy, not nil_elements enforcement). #9 writePrimitiveDecodeFrom Array+Uint8 branch now emits exact-length check before `copy(accessor[:], v)`. Previously short payloads zero-padded; long payloads silently truncated. Mirrors binary_decode.go:551-555. Tests: - wire_validation_test.go: 7 new negative tests covering duplicate/ interleaved fnums, trailing bytes at three top-level shapes, nil struct-ptr in lists with non-struct repr, and byte-array element length mismatches (short+long). - genproto2_test.go: structural test for writeReprUnmarshal's primitive branch bz-slide. - reflect_test.go: fuzz hook for []*StructWithStringRepr (respects the no-nil-elements contract). New registered test types: StructWithStringRepr, StructPtrSliceWithStringRepr, ByteArraySliceStruct. All pb3_gen.go regenerated. Audit artifacts: BINARY_CONDITIONS.md (1050-line reflect-codec conditional reference), BINARY_FIXES.md (30-item fix plan), BINARY_AUDIT.md (349-row checklist used to drive the systematic walk). Verification: full tm2/pkg/amino/..., bft/types, crypto, std, bitarray, gnovm, gno.land/pkg/sdk/vm Gas, gnovm/pkg/gnolang Files -test.short, and gno.land/pkg/integration TestTestdata suites all pass. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
5 tasks
jaekwon
added a commit
that referenced
this pull request
May 22, 2026
Rewrite the PushFrameCall borrow-rule comment block to use the "borrow rule #1/#2/#3" naming and tighten the rule descriptions: - #1 explicitly covers function/method/closure (closures lexically declared in /r/ get fv.PkgPath = /r/ and fire #1, not #3). - #2 says "real, foreign-stamped object" and notes that constructing realm = storage realm under the type-driven stamping model. - #3 narrowed to "(FuncLit) declared in a /p/ package" — the only case where #3 actually fires, since /r/-lexical closures are caught by #1. - "Three borrow rules apply (the first applicable one fires)" replaces the misleading "Layered borrow" framing. Also renames stale "Rule N" and "Layer N" references in surrounding comments at machine.go:2335 and machine.go:2655 to match the new naming convention. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
jaekwon
added a commit
that referenced
this pull request
May 22, 2026
…ts/comments Mechanical rename of all interrealm "Layer 1/2/3" and "Rule 1/2/3" references to "borrow rule #1/#2/#3" across docs, ADRs, integration tests, filetests, and example /r/ and /p/ packages. "Layer" was the wrong word — these are mutually-exclusive rules (first applicable fires), not stacked transformations. Skipped (unrelated meaning): - gnovm/pkg/gnolang/realm.go, values_export*.go — preprocess Layer 1/2 (DeclaredType→RefType collapse), unrelated to borrow rules. - gnovm/adr/pr5544_typevalue_ref_persistence.md — same. - docs/builders/getting-started.md — "Layer 1 blockchain". - gno.land/adr/gas_refactor.md — "cache layer 1/2". Also drops the awkward "borrow rule #N borrow" doublings that the mechanical rewrite introduced (the original "Layer N borrow" form used "borrow" as a noun modifier; "borrow rule #N borrow" is redundant). Hyphenated compound forms ("Rule-1-borrows", "Rule-2-borrowed", "pre-Layer-1-borrow") rewritten in-place. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
2 of 4 tasks
Merged
6 tasks done
jaekwon
added a commit
that referenced
this pull request
Jul 25, 2026
## Summary New `p/nt/groups/v0` package: a `Group` container holding a base address set plus named `Role`s (each with its own member set and free-form metadata), designed for DAOs and permissioned realms. - **Interrealm-safe by construction**: `ReadonlyGroup` / `ReadonlyRole` views (plus a new `addrset.ReadonlySet`) are the only intended realm-boundary handles — unexported fields, read-only method sets, no mutator reachable via borrow rule #2. Security model (three boundary rules, `meta` discipline) documented in the package doc. - **Paginated, gas-bounded API**: every iterator takes `offset, count`; aggregations (`HasAny`, `TotalSize`, `IterateAll`, `RolesContaining`, `RemoveFromAll`) stream with dedup and stop as soon as the requested window is served. ## Changes - `examples/gno.land/p/nt/groups/v0/` — the package (`group.gno`, `role.gno`, `readonly.gno`, `doc.gno`) + mutation-hardened tests - `examples/gno.land/p/moul/addrset/` — `ReadonlySet` live read-only view (`IterateByOffset`/`ReverseIterateByOffset`) + tests - `gnovm/` — fix: `gno lint` scattered `filetests/` files into package roots when writing processed packages back (first `make lint` in `examples/` left 441 stray duplicates, second run failed on the duplicate-filename guard). Added layout-preserving `gnolang.WriteMemPackageTo` + round-trip regression test. Can be split into its own PR if preferred. - `gno.land/adr/prxxxx_p_nt_groups_v0.md` — ADR covering the readonly-view security model and API decisions AI-assisted (Claude Code); ADR included per AGENTS.md.
This was referenced Aug 19, 2026
jaekwon
added a commit
that referenced
this pull request
Aug 25, 2026
The guide describes borrow rules #1 to #3 accurately and omits two facts about when they apply. Both are stated in PushFrameCall and both change the conclusions a reader draws. They govern ordinary calls, not boundary crossings. A cross(...) call sets m.Realm to the callee's realm and returns before any of them; a non-crossing call of a crossing function returns too, after checking the target is not an external realm. The three rules decide what a call that is neither borrows. And they are a priority chain, not three separate tests -- the code says "the first applicable one fires". So "rule #2 protects this receiver" holds only where rule #1 does not already apply. Calling all four defenses "independent" was wrong about the first three; readonly taint really is independent. Verified this pass, no drift found: both VM error messages the guide quotes appear verbatim in the source (errPersistRealm in uverse.go, the allocate format in alloc.go), sanitize.InlineText and InlineCode exist at the cited path, and the three rules are where the guide says they are.
ltzmaxwell
added a commit
that referenced
this pull request
Sep 24, 2026
A /p/ method on a wug-stamped object runs as wug and fires wug's stored callback. From wug that is wug's own code and passes; from relay the relay frame is on the stack and the call is refused.
moul
added a commit
that referenced
this pull request
Nov 5, 2026
## What Every pull request that changes a realm, a package a realm imports, or gnoweb itself gets a **static gnoweb snapshot** published to a per-PR URL, and a sticky comment linking to exactly what changed. - **realm / package change** → the comment lists the changed realms, plus the realms that transitively import a changed package, each with `source` and `help` shortcuts - **gnoweb change** → the comment links the preview homepage and embeds **screenshots** of the four views that carry most of gnoweb's chrome - **anything else** → no artifact, no comment, no job; silently skipped --- ## 👀 See it running This is deployed and working in a scratch repo — **[moul/gno-preview-lab](https://github.com/moul/gno-preview-lab)**, a single-commit snapshot of this branch with every workflow but these four removed — with one pull request per code path: | Lab PR | Change | The comment it produced | The preview it published | |---|---|---|---| | [#1](moul/gno-preview-lab#1) | gnoweb CSS | [comment](moul/gno-preview-lab#1 (comment)) — homepage + 4 screenshots + realm sample | [pr-1/](https://moul.github.io/gno-preview-lab/pr-1/) | | [#2](moul/gno-preview-lab#2) | `r/gnoland/home` | [comment](moul/gno-preview-lab#2 (comment)) — changed realm, no screenshots | [pr-2/r/gnoland/home/](https://moul.github.io/gno-preview-lab/pr-2/r/gnoland/home/) | | [#3](moul/gno-preview-lab#3) | `p/nt/ownable/v0` | [comment](moul/gno-preview-lab#3 (comment)) — 7 realms found by the reverse import walk | [pr-3/r/gnops/valopers/](https://moul.github.io/gno-preview-lab/pr-3/r/gnops/valopers/) | The godoc site is unharmed at the root of the same Pages site: <https://moul.github.io/gno-preview-lab/> Lab PR #1 changes gnoweb's CSS to something deliberately loud, so the screenshot proves the preview rendered **that branch** rather than the published site: <table><tr> <td width="50%"><a href="https://moul.github.io/gno-preview-lab/pr-1/r/gnoland/home/"><img src="https://moul.github.io/gno-preview-lab/pr-1/_shots/home.png" width="100%" alt="Home, rendered markdown"></a><br><sub>Home — rendered markdown</sub></td> <td width="50%"><a href="https://moul.github.io/gno-preview-lab/pr-1/r/gnoland/boards2/v0/_t/help/"><img src="https://moul.github.io/gno-preview-lab/pr-1/_shots/help.png" width="100%" alt="Help and actions forms"></a><br><sub>Help / actions forms</sub></td> </tr></table> > The lab is a temporary scratch deployment for this review and will be deleted once the PR > settles, so these links are not permanent. --- ## How `misc/gnopreview` boots `gnodev` on just the selected packages (dependencies resolve lazily out of `examples/`), crawls the resulting gnoweb, and writes a self-contained static tree. Three workflows, split on the trust boundary so previews work for pull requests opened from forks: | Workflow | Trigger | Token | Runs PR code | |---|---|---|---| | `pr-preview.yml` | `pull_request` | read-only, no secrets | yes — builds gnodev, renders | | `pr-preview-publish.yml` | `workflow_run` | write, through an environment | **no**: downloads the artifact, pushes, comments | | `pr-preview-cleanup.yml` | `pull_request_target: closed` | write, through an environment | **no**: deletes `pr-<N>/` | Publishing is gated on who is asking. A job holding no secret checks that both the PR author and the run's triggering actor have write access here; if so the snapshot publishes through the `gno-previews` environment, otherwise (forks from outside contributors) through `gno-previews-review`, which has required reviewers. The deploy key lives only in those two environments. Rendering always runs on `gnolang/gno`; elsewhere it is opt-in through the `GNOWEB_PREVIEW_BASE_URL` repository variable, which the lab sets: ```sh gh variable set GNOWEB_PREVIEW_BASE_URL -R gnolang/gno -b https://gnolang.github.io/gno-previews ``` ### Why previews live in their own repository Previews publish to **[gnolang/gno-previews](https://github.com/gnolang/gno-previews)**, a separate Pages site in branch mode. `deploy-pages.yml` is **not touched by this PR** — the godoc site keeps deploying exactly as it does today. The two workloads want opposite things. The docs are regenerated from scratch on every deploy (measured: 2 m 57 s) and nobody needs them within five minutes of a merge. A preview's whole value is being there when a reviewer clicks the link. A Pages site built by an Actions workflow has **no incremental deploy** — the entire site ships every time — so sharing one would mean every preview push rebuilds and re-uploads the docs, putting the link 3–6 minutes behind the comment. Publishing from a branch, as the previews repo does, pushes only the bytes that changed. Keeping them apart also bounds the blast radius: a broken preview job cannot delay or break the documentation, and the two do not share a 1 GB site budget or a git history. The previews repo runs its own scheduled `evict.yml` — drop previews whose PR closed, drop previews whose PR has been quiet for 21 days, then enforce a 700 MiB budget oldest-first. Without it the site would reach the 1 GB cap at roughly 78 concurrent previews. ### Setup **Changed in round 2, not yet applied:** the deploy key moves from a repository secret into the environments `gno-previews` (no reviewers) and `gno-previews-review` (required reviewers). Until those exist the review path refuses to publish rather than creating an unprotected environment. - `PREVIEWS_DEPLOY_KEY`: the private half of a **write-enabled deploy key** on `gnolang/gno-previews`, as a secret of those two environments only. A deploy key rather than a fine-grained PAT because it cannot reach any other repository, it does not expire, and it carries no personal identity — preview commits are not attributed to whoever minted the credential, and nothing breaks when that person rotates a token or leaves. - `GNOWEB_PREVIEW_BASE_URL` = `https://gnolang.github.io/gno-previews` (already set), which is also the publishing switch: unset means nothing is published or cleaned up. On a fork's own repository it is also what turns rendering on. ## Measured on the lab | | | |---|---| | Preview render (gnodev boot → crawl → 50 pages + 4 screenshots) | ~20 s, 6.2 MB | | Worst case, 25 realms (a change to `p/nt/avl/v0`) | **8.8 MB / 110 pages** (was 22.2 MB / 243 before rendering only changed files' sources) | | A one-file realm change | 936 KB | | Push to `gno-previews` → serving | **33 s** (measured on the live repo) | | The same content through a shared Actions-built Pages site | 3–6 min (godoc rebuild + whole-site upload) | The comment does not wait on the deploy: the publishing job posts it as soon as the snapshot is pushed, and the link is serving about half a minute later. ## Scope and bounds Deliberately **not** previewed: `*_test.gno`, `*_filetest.gno`, `filetests/`, `examples/quarantined/**`, and `ignore = true` packages. Realms under `gno.land/r/tests/` are previewed when changed directly, never pulled in as dependents. The crawl skips URL shapes that enumerate rather than describe — `$state&oid=` / `&tid=` (walks the object graph, and trips gnoweb's own rate limiter), `$state` (~1.3 MB per realm of a chain that only ran `init()`), `$help&func=X` (`$help` already lists them all), `$download`. At most 25 realms and 400 pages, and the comment says how many realms were dropped. `misc/gnopreview/README.md` documents the output layout, the URL-to-path slugging (no `$`, `:` or `&` ever reaches a file path), and the known limits. ## Notes for review - Running the three lab PRs **concurrently** found two bugs a local run could not, both fixed here: 1. **A single global concurrency group silently drops a publish.** GitHub queues at most *one* pending run per group, so with three PRs publishing at once the middle one was cancelled: its snapshot rendered, its comment never appeared. The group is now keyed on the source head repository and branch, so different PRs publish in parallel — the shared branch is already serialized by the replay loop. 2. **`cancel-in-progress: true` on the `pages` group starves the deploy.** With a dispatch per preview publish, consecutive `deploy / pages` runs cancelled one another and the site stopped updating for the length of the burst. Left at `false`, its original value: every run publishes the complete site, so GitHub's one-running-plus-one-pending behaviour already coalesces a burst, and the pending run picks up everything when it starts. Moot now that previews no longer share the docs pipeline, but the reasoning is why `deploy-pages.yml` ends up unchanged. - **Changed realms are shown before and after.** A second gnodev renders the same realms from a merge-base checkout, using the *head's* gnodev binary and the head's assets in both passes, so the pair isolates the realm change rather than whatever else moved on master. A realm the PR *adds* says so instead of faking a before; a run with no base checkout makes no claim at all. gnodev defaults both its RPC listener and its keybase to fixed locations, so the two passes are given distinct ones — otherwise they fight over `127.0.0.1:26657`. - **Previews are `noindex`, and were not.** gnoweb's layout emits `<meta name="robots" content="index, follow">` on every page (`components/layouts/head.html:38`), so a published snapshot — a near-duplicate of a real gno.land page — was actively inviting the crawler. The renderer now *replaces* that tag with `noindex, nofollow` rather than adding a second one; two conflicting robots directives leave the outcome to each crawler's precedence rules. Not a `robots.txt` `Disallow`: a disallowed path can still be indexed from an external link, and being disallowed is exactly what stops a crawler from reading the `noindex`. - `misc/gnopreview` is registered in `ci-dir-misc.yml`'s matrix — that file's own comment warns an unlisted program is never built. - `public/js/index.js` builds its dynamic `import()` specifiers from a hardcoded `/public/js/controller-` prefix. The snapshot rewrites it relative to the asset's own URL; without that, every interactive control 404s from any mount point but the site root. The renderer warns loudly if that string ever disappears. - The comment is **not** the untrusted job's: the publishing job builds it with the default branch's `gnopreview comment` from the artifact's `preview.json`, refusing any package path that is not a plain path and deriving every link, image path and caption again. It is byte-identical to what the render job writes for an honest snapshot (checked on a realm render with a before/after pair and on a gnoweb render with four screenshots). - `actionlint`, `zizmor --persona=regular`, `golangci-lint` with `.github/golangci.yml`, `go fix`, `go vet` and `go test` all clean. ADR: `gno.land/adr/pr6194_gnoweb_pr_previews.md`. --- ## Review round 1 Every one of @alexiscolin's findings reproduced; all are fixed in `fix(ci): address review …`. The three security ones: - **The pull request number came from the artifact**, which the fork's own render job writes — a cross-PR primitive: name another number and you replace that preview and PATCH its comment. Now resolved from the `workflow_run` payload, with a head-SHA check that stands down when a newer run has superseded this one, and `state=open` so a render finishing after close publishes nothing. - **A `.git` in the artifact** makes `git add -A` record `pr-<N>` as mode `160000` (reproduced), which GitHub Pages reports as a build error — freezing publication for every preview. Stripped before the copy, plus a size cap on the snapshot. - **The privileged job executed `bin/reindex.sh` from `gno-previews@main`** while holding `pull-requests: write` here. Nothing in this repository runs code from that one any more; the index is regenerated by a workflow over there with its own token. And the rest: slugs no longer traverse (`:..` folded onto the realm's own render page) or collide (`:p/a-b`, `:p/a/b`, `:p/a&b` shared one file) — non-trivial slugs now carry a digest and are length capped; the trailing slash is preserved, since `/r/x/y/` is a different page from `/r/x/y` (48,642 vs 62,174 bytes) and `/r` is no longer seeded because gnoweb answers it with 400; gnodev is watched, so a node that dies fails in seconds with the reason instead of timing out on "not ready", and the log is printed on failure; the sticky comment matches the bot's authorship, not just the marker; the per-file budget is charged at capture rather than at link discovery; "New in this PR" is asserted from the merge-base tree rather than inferred from a missing capture. **Screenshots were showing the no-JS state.** Chrome will not load ES modules over `file://` — 0 controllers initialise versus 3 over HTTP, matching the numbers in the review. The renderer now serves the snapshot on a loopback port while photographing it. A one-line gnoweb fix using `import.meta.url` in `index.ts` would also remove the `/public/js/controller-` rewrite this depends on; happy to take that PR. --- ## Review round 2 All of @alexiscolin's second-round points are addressed in `f09f12f` and `0420507`; each fix that has a test was seen red before green. - **Fork trust.** Publishing needs the author *and* the triggering actor to have write access, or a maintainer's approval through `gno-previews-review` (both, because a maintainer's "Update branch" makes the maintainer the actor). The deploy key is environment-only. The run must come from `.github/workflows/pr-preview.yml` (`workflow_run.path`), so a same-named look-alike is ignored. Freshness is re-checked after approval, since an approval can come days after the render. - **Fork PRs never rendered.** The render gate is `github.repository == 'gnolang/gno' || vars.GNOWEB_PREVIEW_BASE_URL != ''`, which holds whether or not a fork run sees variables. - **Comment body**: rebuilt by trusted code, as above. - **Site budget**: 20 MiB and 1,000 files per preview (apparent size), and publishing refuses to take the whole site past 900 MiB between two evictions. - **Timeouts**: every job has one, and Chrome runs under a 60 s deadline that kills its whole process group (killing only the parent leaves its helpers holding the pipe open). - **Readiness** probes gnoweb's `/ready` and requires its `{"status":"ready"}` body. A bare 200 was not enough: a local run crawled another server already on the port. The ports are checked free before gnodev starts. - **Queue fill**: scope is re-checked at fetch time with the seed exemption, as suggested. The 2,000-link case goes from 2,004 fetches to 7, and a separate test covers the before-pass. - Changed realms cut by the realm cap are named without a link; `--no-renames`; slug examples carry their digest (and are pinned by a test); `Draft` and the Makefile are gone; the ADR names the variable, the secret, the environments and every cap. --------- Signed-off-by: moul <[email protected]> Co-authored-by: Alexis Colin <[email protected]> Co-authored-by: Antoine Eddi <[email protected]>
This was referenced Nov 10, 2026
Draft
aeddi
pushed a commit
that referenced
this pull request
Nov 17, 2026
…val (#15)
* fix(gnovm): meter big-number literal parsing and shifts to close qeval DoS
Unmetered O(n^2) big.Int.SetString / big.ParseFloat on integer and float
literals in doOpEval was reachable free and unauthenticated via the ABCI
vm/qeval query path: withQueryEvalMachine does not call chargePreprocessGas
and the parser bills per token, so a ~700K-digit literal cost ~84 gas for
hundreds of ms of CPU. A sibling chained big-int shift vector compounded it.
Meter the under-charged operations at the VM op layer. No hard size caps: a
literal-only cap does not lower the free-query CPU ceiling (the chained-shift
path is gas-bounded, not capped, since arbitrary-precision arithmetic must
not be forbidden), and it would be the only Go-incompatible change.
- op_eval.go: charge quadratic CPU gas (digits/10)^2 * slope / 10 before
parsing, for both INT and FLOAT (a trailing ".0"/"e1" must not bypass it).
- op_binary.go + op_assign.go: meter doOpShl / doOpShlAssign by operand
bit-width (mirroring doOpShr / doOpShrAssign) so chained shifts are billed
for the operand they grow, not just the shift amount.
A third change -- making BigintValue.GetShallowSize proportional to magnitude
-- was considered and dropped: it is independent of this DoS fix, it is
consensus-affecting on its own, and no reachable call path was demonstrated.
See Alternatives in the ADR.
Adds regression tests through the real QueryEval path and the preprocess
fold path, plus an ADR. Consensus-affecting: changes tx-path preprocess gas
(no literal is rejected by a hard cap, though a sufficiently large one now
exhausts the budget), so it must ship behind a coordinated network upgrade.
The parse slopes are order-of-magnitude estimates pending a bench on
reference hardware. See gnovm/adr/prxxxx_qeval_bignum_dos.md.
* docs(gnovm): correct factual claims in the qeval bignum ADR
Several claims in the ADR were used to justify design decisions and were
wrong. None of the decisions change; the justifications do.
Radix complexity is Go-version dependent. On the toolchain go.mod requires
(go 1.25.9), nat.scan packs bases 2/4/16 into words and parses them linearly;
only the default arm (bases 8 and 10) is quadratic. The ADR asserted the
opposite and used it to dismiss reviewer reports of hex over-charging. That
measurement was taken under go1.22.3, which does lack the packing path -- a
scratch module picks up the local toolchain, not the auto-switched one that
"go version" reports. The reviewers were right.
The decision (one base-independent slope) is unchanged, but is now justified
as deliberately conservative rather than resting on a false premise, and
states the cost: ~15x over-charge at 100K hex chars, ~240x at 1.2M, and hard
rejection above ~1.23M hex chars for ~12ms of real work.
The residual free-query ceiling was understated ~3.5x (6.3-9.5s at 4000
shifts, 14.0s at 40000, against a quoted ~4s) and mis-attributed. Bignum
metering is not what bounds it: the generic ParseExpr+Eval path is quadratic
in term count and under-priced ~4-5x, so 80KB of plain arithmetic containing
no big number takes 53.9% of the query budget. That is a calibration gap, not
a metering gap, and it is pre-existing -- the merge-base shows the same shape.
Decision 3 claimed store.go:564 as a call site for BigintValue.GetShallowSize.
It cannot be one: that call is on an Object, and BigintValue is a bare
struct{ V *big.Int } with no ObjectInfo. Only the GC walk can reach it, and an
instrumented build recorded zero calls with a non-nil V across representative
paths -- untyped bigints are preprocess-only. The section now says so, and
recommends splitting decision 3 out or dropping it until a reachable path is
demonstrated, since it is consensus-affecting and independent of the DoS fix.
Three adjacent corrections for consistency: the "slopes are the binding bound"
bullet contradicted the residual finding, so it is narrowed to bounding
literal size; the MulQ comparison band was labelled "schoolbook" when only
1024 and 2048 bits qualify (karatsubaThreshold = 40 words = 2560 bits), so the
schoolbook band is 0.23-0.59 and the drift to 1.22 is the quadratic charge
outrunning Karatsuba; and the huge-exponent-float bullet described a mechanism
that does not happen -- ParseFloat returns +Inf with err == nil, so the
MantExp guard does not fire and Rat.SetString is what rejects the value. That
conclusion (safe, ~5-40us) was right; the route was not.
Documentation only; no code or gas constants change.
* fix(gnovm): clamp the doOpShl shift-amount gas charge to maxBigintShift
The shift-amount charge int64(rv.GetUint())*OpCPUSlopeBigIntShl/1024 runs
before shlAssign enforces maxBigintShift, so rv is unvalidated at that point.
For amounts above ~2.4e17 the multiply wrapped int64 negative and ConsumeGas
panicked "gas must not be negative" instead of reporting the real
"shift amount exceeds maximum" error:
const _ = 1 << 300000000000000000 -> "gas must not be negative"
const _ = 1 << 18446744073709551615 -> correct (int64(MaxUint64) is -1,
which truncates to a 0 charge)
Clamp the amount to maxBigintShift for charging purposes, at both sites
(doOpShl and doOpShlAssign). Anything over the cap panics in shlAssign
regardless, so this cannot under-charge an operation that actually runs -- it
only changes the gas billed for a shift that is rejected either way.
Pre-existing bug, not introduced by the metering fix, but on the line that
fix edits. Kept separate so it can be reviewed and reverted independently.
Covered by TestShiftAmountGasOverflow.
* docs(gnovm): record BigintValue.GetShallowSize as considered and dropped
The size-proportional GetShallowSize change is dropped from this PR. It was
independent of the DoS fix (bigints are never charged to Alloc.Allocate at
creation, so the doOpEval/doOpShl CPU charges are what bound growth), it is
consensus-affecting on its own, and no reachable call path was demonstrated:
only the GC walk could dispatch to it, and an instrumented build recorded zero
calls with a non-nil V across representative paths.
A coordinated network upgrade is the worst place to carry a change nothing
depends on, so it moves from Decisions to Alternatives with the evidence
recorded. BigdecValue.GetShallowSize has the identical gap, so the two should
move together if either is revisited.
* fix(gnovm): keep the big-literal parse charge eval-invariant
Charge chargeBigLitParse on the raw literal length, before the
blank-identifier separators are stripped, so the strip's own O(n) scan
(which does not go through m.Alloc) is billed rather than run for free
ahead of any charge.
That is only sound if the length cannot change between evaluations, so
stop writing the stripped text back into x.Value: doOpEval now uses a
local via stripBlanks and leaves the AST node as written. Combining a
raw-length charge with the in-place mutation would have billed the first
evaluation of a node differently from later ones (24 gas then 20, for a
102-digit literal with 11 separators), making gas a function of
evaluation history.
That is latent, not reachable: preprocess replaces every BasicLitExpr
with a ConstExpr, which Transcribe treats as a leaf, so no literal parsed
out of .gno source is evaluated twice -- confirmed by an instrumented
build over the gnovm and sdk/vm suites. Pinned anyway by
TestBigLitParseChargeIsEvalInvariant, which also asserts the charge
formula itself so the keeper-side mirror of it cannot drift undetected.
Billing separators can only over-charge (raw >= stripped). Gas differs
only when floor(raw/10) != floor(stripped/10) and the raw length is >= 30
(INT) or >= 20 (FLOAT). An exhaustive parse of all 65,037 INT/FLOAT
literals across 4,502 .gno files, reproduced independently, finds none
affected; the .txtar corpus is likewise unaffected. Files and TestTestdata
are unchanged.
* docs(gnovm): calibrate the parse slopes and pin the residual as a test
Addresses the two review comments on the PR.
Calibration (moul #2). The existing doOpEval literal benchmarks topped
out at 100 digits, inside the constant-dominated regime, so no quadratic
slope could be recovered -- which is why these two constants were the
only ones in the block without a fit. Adds sized series
(BenchmarkOpEval_BigIntLit_*, BigDecLit_*) plus hex and int-shaped-float
controls, so the next reference-HW run produces a native fit, and records
the local fit as ranges: two independent re-measurements of the same
quantity differed by ~20%, and these benchmarks must not share a process
with other large-allocation benchmarks. The TODO now carries the exact
command, including -tags benchmarkingops, without which the ns/op(pure)
this block is calibrated in is not emitted at all.
Fits are two-point. Naive single-size t/n^2 -- what the neighbouring
entries use -- reads ~9e-4 at n=16000 for INT against a ~6-8e-4 two-point
fit, because a real linear term is still material there. Mixing the two
methods across sizes manufactures an apparent sub-quadratic trend; the
coefficient is in fact flat to ~2.5% out to 750K digits, exponent ~2.0,
as the Go source implies.
Corrects the stated reason for OpCPUSlopeBigDecParse = 4. The
MantExp > ratOverflowBits guard bounds the parsed value's magnitude, not
the literal's length: a frac-shaped literal like 1.999...9 stays near 1
in magnitude at any length, so the guard never fires and Rat.SetString
runs on the full mantissa on top of ParseFloat. The BigDecLit vs
BigDecLitInt benchmarks isolate that second pass at ~2x. So 4 is the
calibrated ratio, not headroom -- measuring big.ParseFloat alone sees
only half the op and would argue for halving it.
Residual (davd-gzl, moul #3). The charge first refuses a decimal INT at
1,224,750 digits, but a default node caps the body at 1 MB and base64s
the []byte payload, so the largest deliverable literal is 749,886 digits
-- gas alone refuses nothing reachable.
TestVMKeeperQueryEvalBignumResidualCeiling asserts that as a fact and
fails if it ever flips. The frac-shaped FLOAT is the worst admitted
payload at 75% of the budget, ~2x the INT case both comments priced, and
its margin over the delivery ceiling is only 1.15x.
Also corrects the effective RPC limits: node.go:803-806 overwrites
rpcserver.DefaultConfig()'s 5 MB / 0 with config.RPC's 1 MB / 900. The
1 MB figure is what bounds the residual; at 5 MB the charge would bind.
Radix timings are reduced to one significant figure after re-measurement
moved every absolute figure by 1.5-5x (ratios and the linear-vs-quadratic
split are stable).
* test(gnovm): pin the tx-path literal cap that keeps the charge unreachable
The ADR argues the tx path needs no separate charge because go/types
rejects any numeric literal over 10000 characters long before
chargeBigLitParse could refuse one (~1.23M INT / ~866K FLOAT). Nothing
asserted that.
The cap is go/types' own `const limit` in go/types/literals.go, not
something the GoVersion pinned in gotypecheck.go governs, so a toolchain
bump can move it silently and the argument would quietly stop holding.
TestTxPathLiteralCap covers all three literal shapes the charge applies to
at 1.3M chars, the exact 10000/10001 boundary, and prices the worst
tx-deliverable literal against the query budget. Mutation-checked: setting
the expected cap to 9000 fails the boundary subtest.
Raised by Villaquiranm in review.
---------
Co-authored-by: Morgan <[email protected]>
aeddi
pushed a commit
that referenced
this pull request
Nov 17, 2026
…d of relabelling them (#342) * fix(gnovm)!: convert var a, b T = f() results instead of relabelling them doOpValueDecl gave each result of a typed multi-value declaration the type T with a bare relabel, so neither of convertValue's inter-realm checks ran. A realm could relabel another realm's stored slice to a /p/ type with a mutator and write it under borrow rule #2, which the explicit conversion refuses, and could build values of a type another /r/ realm declares. Convert each result whose run-time type differs from T with convertValue, in place on m.Values before popping them, as doOpAssign does for a, b = f(). Single-value declarations, interface targets and untyped comma-ok results are left to the existing paths. * chore(gnovm): gno fmt the var-decl conversion filetest * fix(gnovm): decide the var-decl conversion from the call's declared result types Comparing each result's run-time type with T refused declarations that only read. A getter declared to return map[string]int that does `return two()` over maps its realm stores as M leaves M on them, so `var a, b map[string]int = vault.Pair(cross(cur))` converted the other realm's stored maps in the caller and was refused, while `a, b :=` on the same call read them. Record the conversions at preprocess from the types the call declares, in ATTR_ASSIGN_CONVERT, as `a, b = f()` does, and have doOpValueDecl apply those. A result whose run-time type differs from its declared one is wrong where it was produced, and is converted there instead. * refactor(gnovm): skip the var-decl conversion lookup on single-name declarations Guard the ATTR_ASSIGN_CONVERT lookup with the shape preprocess records it on, as doOpAssign's single-Lhs fast path does, take the results with PeekValues, and decide once per declaration whether any result may convert. The seal comment now names doOpValueDecl as a reader too. * fix(gnovm): convert nothing for a _ in var a, b T = f() A discarded result keeps no alias, so it needs no conversion, and converting it refused var _, n T = f() when the dropped value was another realm's stored one, which develop and _, n = f() accept. Skip blank names when recording the conversions, as the assignment path does. * docs(gnovm): drop the var-decl conversion ADR The change is small enough that the PR description carries its reasoning. --------- Co-authored-by: ltzmaxwell <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Just corrected the spelling of virtual....