-
Notifications
You must be signed in to change notification settings - Fork 375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: panic in store.SprintStoreOps
#1036
fix: panic in store.SprintStoreOps
#1036
Conversation
Output with standard JSON: https://gist.github.com/moul/cc7fda42d648ceae144d9bff55a20d7e |
I think this is because I think it's related to one of your other PRs, with the goal to make Maybe the best move is:
|
That's also what I thought initially, but // Realm:
// xxx then there is no panic. I think the panic is due to :
The PR you're referring to doesn't exist yet, there's just a preliminary PR that brings test to make it doable (#1023). |
How did you achieve that? using only |
I found the culprit : file package std
type Address string // NOTE: bech32
func (a Address) String() string {
return string(a)
}
const RawAddressSize = 20 // <--------------------- interpreted as a bigint
type RawAddress [RawAddressSize]byte Proof of this, if I change the value to 21, the panic becomes
So I think it's related to how gno bigint are interpreted in amino. If I change again this const to const RawAddressSize = int(20) Everything works properly. Does anyone know if something has changed in the way that |
e2ddccd
to
d301dad
Compare
store.SprintStoreOps
store.SprintStoreOps
I believe using bigint as the default type for numeric constants is a bug. The implementation of bigint seems incomplete, possibly due to lacking marshalling helpers in values.go, causing the mentioned panic. @jaekwon wdyt? |
630a84d
to
29fa699
Compare
29fa699
to
e90bfd8
Compare
``` go run ./gnovm/cmd/gno test -verbose ./examples/gno.land/p/demo/tests/ -run file/z0 ? ./examples/gno.land/p/demo/tests/subtests [no test files] === RUN file/z0_filetest.gno panic: expected JSON object but got "20" goroutine 1 [running]: github.com/gnolang/gno/tm2/pkg/amino.(*Codec).MustMarshalJSON(...) /home/tom/src/gno/tm2/pkg/amino/amino.go:818 github.com/gnolang/gno/tm2/pkg/amino.MustMarshalJSON({0xda1d40?, 0xc0001305a0?}) /home/tom/src/gno/tm2/pkg/amino/amino.go:140 +0x53 github.com/gnolang/gno/gnovm/pkg/gnolang.StoreOp.String({0x0, {0x1026bf0, 0xc0001305a0}, {0x0, 0x0}}) /home/tom/src/gno/gnovm/pkg/gnolang/store.go:654 +0xb2 github.com/gnolang/gno/gnovm/pkg/gnolang.(*defaultStore).SprintStoreOps(0xc0000166c0) /home/tom/src/gno/gnovm/pkg/gnolang/store.go:687 +0xff github.com/gnolang/gno/gnovm/tests.RunFileTest({0xc000357158, 0x11}, {0xc0003691a0, 0x2e}, {0xc0001499e8, 0x1, 0x1013280?}) /home/tom/src/gno/gnovm/tests/file.go:325 +0x44e main.gnoTestPkg({0xc000116500, 0x20}, {0x0?, 0x0, 0x1?}, {0xc00035b720, 0x1, 0xc000129af8?}, 0xc00034c8c0, 0xc0002948c0) /home/tom/src/gno/gnovm/cmd/gno/test.go:337 +0x876 main.execTest(0xc00034c8c0, {0xc00035b590, 0x1, 0x1}, 0xc000036220?) /home/tom/src/gno/gnovm/cmd/gno/test.go:208 +0xb67 main.newTestCmd.func1({0x0?, 0x0?}, {0xc00035b590?, 0xc00035f118?, 0x0?}) /home/tom/src/gno/gnovm/cmd/gno/test.go:51 +0x32 github.com/gnolang/gno/tm2/pkg/commands.(*Command).Run(0x5?, {0x1018768?, 0xc00003a130?}) /home/tom/src/gno/tm2/pkg/commands/command.go:233 +0x1ac github.com/gnolang/gno/tm2/pkg/commands.(*Command).Run(0xc00035ee70?, {0x1018768?, 0xc00003a130?}) /home/tom/src/gno/tm2/pkg/commands/command.go:237 +0x154 github.com/gnolang/gno/tm2/pkg/commands.(*Command).ParseAndRun(0x4059dc?, {0x1018768, 0xc00003a130}, {0xc0000361f0?, 0x401240?, 0x0?}) /home/tom/src/gno/tm2/pkg/commands/command.go:118 +0x4f main.main() /home/tom/src/gno/gnovm/cmd/gno/main.go:14 +0x75 exit status 2 ```
- change std.RawAddressSize type to int - run z0_filetest.gno with -update-golden-tests flag
d10a42b
to
1107a00
Compare
1107a00
to
b2ffe3b
Compare
When checking if `info.IsJSONAnyValueType`, if this type is a AminoMarshaler, then also check `info.ReprType.IsJSONAnyValueType`. This prevents a panics that happens during the sanity check phase of `encodeReflectJSONInterface()` when the type `ConcreteInfo` doesn't match the JSON structure. For instance, before that fix, that used to happen with `BigintValue` which is a struct (so expected JSON is `{...}` and `IsJSONAnyValueType=false`), but is marshaled into a simple string (so expected JSON is only `"..."`, and `ReprType.IsJSONAnyValueType=true`). `decodeReflectJSONInterface` is also impacted.
b2ffe3b
to
4b6891a
Compare
Yeah, I often use my library for debugging: https://pkg.go.dev/moul.io/godev#PrettyJSONPB :) |
2 ways to reproduce :
Additional notes:
// Realm:
instruction is present, it triggers a comparison between the store and the content of the instruction.// Realm:
instruction, for instanceexamples/gno.land/p/demo/avl/z_0_filetest.gno
is still working wellContributors' checklist...
BREAKING CHANGE: xxx
message was included in the description