Comments (10)
@thehowl I just ran that test and it is passing for me, so maybe some of the fixes we've made to the VM have resolved the underlying issue.
from gno.
Hey @irreverentsimplicity. Maybe it is possible the object isn't getting removed correctly. Would it be possible to provide more context and send over something like the script below? I ran this locally and wasn't able to reproduce. I'm just trying to figure out the gno code and maketx combination that I need to do to observe the issue for myself.
## start a new node
gnoland start
gnokey maketx addpkg -pkgdir $WORK -pkgpath gno.land/r/bar -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1
gnokey maketx call -pkgpath gno.land/r/bar -func AddListing -args "hello" -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1
gnokey maketx call -pkgpath gno.land/r/bar -func RemoveListing -args "hello" -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1
gnokey maketx call -pkgpath gno.land/r/bar -func AddListing -args "hello" -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1
-- bar.gno --
package bar
import "gno.land/p/demo/avl"
var listings = avl.NewTree()
type Listing struct {
id string
}
func AddListing(id string) {
listings.Set(id, Listing{id: id})
}
func RemoveListing(id string) {
listings.Remove(id)
}
func Render(path string) string {
return "hello from foo"
}
from gno.
@irreverentsimplicity I've already had an issue with the same error (not necessarily the same cause ;) ) and it caused tremendous headaches when developing GnoChess. Does this help? gnolang/gnochess#97
from gno.
@thehowl thanks, it definitely helps, it is actually to the same scenario, although with slightly different objects.
As far as I understand, you had to reinstantiate an object (the chess board) before re-adding the same key.
I'm not sure this approach can be used in my case, though. The avl.Tree I'm using holds listing ids for the marketplace. Re-instantiating the whole avl.Tree basically wipes all the data (or at least that's how I understand by re-instantiation, I might be wrong). I'll dig more over the next few days, and if I can't find a way, I may resort to using a map to hold listings (although a bit more verbose and slightly slower).
Somehow related to this: I remember you mentioned you're working on a new type of data structure in a dev call, one that also allowed pagination. I don't know what the status of this new data structure is (merged or not) but if you can give me some pointers to it, I might try to use that instead (pagination very useful in listing potentially huge amounts of NFTs and marketplace listings).
Thanks!
from gno.
For tracking references & searchability: there is a reproducible test on #1172 . The PR contains a lot of extra commits (coming from the patch/gnochess
branch); the test itself is here: https://github.com/moul/gno/blob/dev/moul/bug-gnochess-97/gno.land/cmd/gnoland/testdata/bug-gnochess-97.txtar
@irreverentsimplicity The issue is not about re-using the avl tree per se. Take a look at the txtar test, it doesn't use an AVL tree at all.
I'd need to take a better look at the entire code to be certain of how to work it around. If you still don't manage to do it, ping me on Signal.
Let's keep this issue open to track the problem officially, I believe I hadn't opened it originally because I didn't have time when developing GnoChess to make a proper report... :)
from gno.
I can still reproduce this on my machine. Here is the stack trace when sending the tx from command line:
gnokey maketx call -broadcast -pkgpath gno.land/r/demo/flippando -gas-wanted 10000000 -gas-fee 1000000ugnot -func ListMarketplaceNFT -args 1 -args g1ewad87z8sxxejhsuasg0s5ffdl2s3x0fyca0t8 -args 2 test
Enter password.
--= Error =--
Data: unexpected object with id 1b4fe769c2b0acba527e54f1eca22a38499de5b4:522
Msg Traces:
0 /Users/dragosroua/gno/tm2/pkg/crypto/keys/client/addpkg.go:214 - deliver transaction failed: log:msg:0,success:false,log:--= Error =--
Data: &errors.errorString{s:"unexpected object with id 1b4fe769c2b0acba527e54f1eca22a38499de5b4:522"}
Msg Traces:
0 /Users/dragosroua/gno/gno.land/pkg/sdk/vm/keeper.go:279 - VM call panic: unexpected object with id 1b4fe769c2b0acba527e54f1eca22a38499de5b4:522
Machine:
CheckTypes: false
Op: [OpHalt OpBody OpReturn OpBody OpDefine OpBody OpDefine OpBody]
Values: (len: 4)
#3 (<*gno.land/p/demo/avl.Tree>.Get(tree *gno.land/p/demo/avl.Tree,key string)(value interface{},exists bool) func(key string)(value interface{},exists bool))
#2 (GetChildrenOf func(tokenID string)( []int64))
#1 (<*gno.land/r/demo/flippando.Marketplace>.ListNFT(m *gno.land/r/demo/flippando.Marketplace,compositeTokenID gno.land/p/demo/grc/grc721.TokenID,seller std.Address,price uint64)( .uverse.error) func(compositeTokenID gno.land/p/demo/grc/grc721.TokenID,seller std.Address,price uint64)( .uverse.error))
#0 (ListMarketplaceNFT func(compositeTokenID string,seller std.Address,price uint64)( .uverse.error))
Exprs:
Stmts:
#3 bodyStmt[0/0/1]=return
#2 bodyStmt[0/0/1]=if exists<VPBlock(2,3)> { return [](const-type int64)(childrenOf<VPBlock(2,2)>) }*
#1 bodyStmt[0/0/1]=newListing<VPBlock(1,6)> := Listing<VPBlock(3,3)>{CompositeTokenID<VPField(0,0,CompositeTokenID)>: compositeTokenID<VPBlock(1,1)>, BasicTokenIDs<VPField(0,1,BasicTokenIDs)>: basicTokenIDs<VPBlock(1,5)>, Seller<VPField(0,2,Seller)>: seller<VPBlock(1,2)>, Price<VPField(0,3,Price)>: price<VPBlock(1,3)>}*
#0 bodyStmt[0/0/1]=(end)
Blocks:
@(1) Block(ID:0000000000000000000000000000000000000000:0,Addr:0x14007709860,Source:func (tree *(Tree<VPBlock(2,2)>)...,Parent:0x14007709680)
tree: (&(struct{(&(struct{("1" string),(slice[ref(1b4fe769c2b0acba527e54f1eca22a38499de5b4:522)] []int64),(0 int8),(1 int),(nil *gno.land/p/demo/avl.Node),(nil *gno.land/p/demo/avl.Node)} gno.land/p/demo/avl.Node) *gno.land/p/demo/avl.Node)} gno.land/p/demo/avl.Tree) *gno.land/p/demo/avl.Tree)
key: ("1" string)
value: (slice[ref(1b4fe769c2b0acba527e54f1eca22a38499de5b4:522)] []int64)
exists: (true bool)
(s vals) @(1) Block(ID:0000000000000000000000000000000000000000:0,Addr:0x14001967820,Source:func (tree *(Tree<VPBlock(2,2)>)...,Parent:0x1400029e620)
tree: (nil *gno.land/p/demo/avl.Tree)
key: ( string)
value: (undefined)
exists: (false bool)
(s typs) @(1) [*gno.land/p/demo/avl.Tree string interface{} bool]
@(2) Block(ID:26a90809de387e567a70972c32a4cc9e8d44e55f:4,Addr:0x14007709680,Source:ref(gno.land/p/demo/avl/tree.gno...,Parent:%!!(MISSING)!(MISSING)p(gnolang.RefValue={{{[38 169 8 9 222 56 126 86 122 112 151 44 50 164 204 158 141 68 229 95]} 2} true {[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]}}))
(RefNode names not shown)
(s vals) @(2) Block(ID:0000000000000000000000000000000000000000:0,Addr:0x1400029e620,Source:file{ package avl; type IterCbFn...,Parent:0x1400029e920)
(s typs) @(2) []
(block ref 26a90809de387e567a70972c32a4cc9e8d44e55f:2)
Blocks (other):
#3 Block(ID:0000000000000000000000000000000000000000:0,Addr:0x140077090e0,Source:func GetChildrenOf(tokenID (cons...,Parent:0x14007e4ab40)
tokenID: ("1" string)
.res_0: (nil []int64)
childrenOf: (undefined)
exists: (undefined)
(static) #3 Block(ID:0000000000000000000000000000000000000000:0,Addr:0x1400d74a420,Source:func GetChildrenOf(tokenID (cons...,Parent:0x1400cf9b820)
tokenID: ( string)
.res_0: (nil []int64)
childrenOf: (undefined)
exists: (false bool)
#2 Block(ID:0000000000000000000000000000000000000000:0,Addr:0x14007708f00,Source:func (m *(Marketplace<VPBlock(2,...,Parent:0x14007e4b2c0)
m: (&(ref(1b4fe769c2b0acba527e54f1eca22a38499de5b4:32) gno.land/r/demo/flippando.Marketplace) *gno.land/r/demo/flippando.Marketplace)
compositeTokenID: ("1" gno.land/p/demo/grc/grc721.TokenID)
seller: ("g1ewad87z8sxxejhsuasg0s5ffdl2s3x0fyca0t8" std.Address)
price: (2 uint64)
.res_0: (undefined)
basicTokenIDs: (undefined)
newListing: (undefined)
(static) #2 Block(ID:0000000000000000000000000000000000000000:0,Addr:0x14006840c20,Source:func (m *(Marketplace<VPBlock(2,...,Parent:0x14002c96320)
m: (nil *gno.land/r/demo/flippando.Marketplace)
compositeTokenID: ( gno.land/p/demo/grc/grc721.TokenID)
seller: ( std.Address)
price: (0 uint64)
.res_0: (undefined)
basicTokenIDs: (nil []int64)
newListing: (nil gno.land/r/demo/flippando.Listing)
#1 Block(ID:0000000000000000000000000000000000000000:0,Addr:0x140077083c0,Source:func ListMarketplaceNFT(composit...,Parent:0x14007e4af00)
compositeTokenID: ("1" string)
seller: ("g1ewad87z8sxxejhsuasg0s5ffdl2s3x0fyca0t8" std.Address)
price: (2 uint64)
.res_0: (undefined)
(static) #1 Block(ID:0000000000000000000000000000000000000000:0,Addr:0x14005233c20,Source:func ListMarketplaceNFT(composit...,Parent:0x1400db18c20)
compositeTokenID: ( string)
seller: ( std.Address)
price: (0 uint64)
.res_0: (undefined)
Frames:
#3 [FRAME FUNC:Get RECV:(&(struct{(&(struct{("1" string),(slice[ref(1b4fe769c2b0acba527e54f1eca22a38499de5b4:522)] []int64),(0 int8),(1 int),(nil *gno.land/p/demo/avl.Node),(nil *gno.land/p/demo/avl.Node)} gno.land/p/demo/avl.Node) *gno.land/p/demo/avl.Node)} gno.land/p/demo/avl.Tree) *gno.land/p/demo/avl.Tree) (1 args) 7/3/0/3/4 LASTPKG:gno.land/r/demo/flippando LASTRLM:Realm{Path:"gno.land/r/demo/flippando",Time:530}#1B4FE769C2B0ACBA527E54F1ECA22A38499DE5B4]
#2 [FRAME FUNC:GetChildrenOf RECV:(undefined) (1 args) 5/2/0/2/3 LASTPKG:gno.land/r/demo/flippando LASTRLM:Realm{Path:"gno.land/r/demo/flippando",Time:530}#1B4FE769C2B0ACBA527E54F1ECA22A38499DE5B4]
#1 [FRAME FUNC:ListNFT RECV:(&(ref(1b4fe769c2b0acba527e54f1eca22a38499de5b4:32) gno.land/r/demo/flippando.Marketplace) *gno.land/r/demo/flippando.Marketplace) (3 args) 3/1/0/1/2 LASTPKG:gno.land/r/demo/flippando LASTRLM:Realm{Path:"gno.land/r/demo/flippando",Time:530}#1B4FE769C2B0ACBA527E54F1ECA22A38499DE5B4]
#0 [FRAME FUNC:ListMarketplaceNFT RECV:(undefined) (3 args) 1/0/0/0/1 LASTPKG:main LASTRLM:Realm(nil)]
Realm:
gno.land/r/demo/flippando
Exceptions:
[]
Stack Trace:
0 /Users/dragosroua/gno/tm2/pkg/errors/errors.go:20
1 /Users/dragosroua/gno/gno.land/pkg/sdk/vm/keeper.go:279
2 /usr/local/go/src/runtime/panic.go:884
3 /Users/dragosroua/gno/gnovm/pkg/gnolang/store.go:250
4 /Users/dragosroua/gno/gnovm/pkg/gnolang/values.go:410
5 /Users/dragosroua/gno/gnovm/pkg/gnolang/ownership.go:343
6 /Users/dragosroua/gno/gnovm/pkg/gnolang/values.go:282
7 /Users/dragosroua/gno/gnovm/pkg/gnolang/op_assign.go:44
8 /Users/dragosroua/gno/gnovm/pkg/gnolang/machine.go:1347
9 /Users/dragosroua/gno/gnovm/pkg/gnolang/machine.go:711
10 /Users/dragosroua/gno/gno.land/pkg/sdk/vm/keeper.go:285
11 /Users/dragosroua/gno/gno.land/pkg/sdk/vm/handler.go:66
12 /Users/dragosroua/gno/gno.land/pkg/sdk/vm/handler.go:29
13 /Users/dragosroua/gno/tm2/pkg/sdk/baseapp.go:644
14 /Users/dragosroua/gno/tm2/pkg/sdk/baseapp.go:823
15 /Users/dragosroua/gno/tm2/pkg/sdk/baseapp.go:580
16 /Users/dragosroua/gno/tm2/pkg/bft/abci/client/local_client.go:82
17 /Users/dragosroua/gno/tm2/pkg/bft/proxy/app_conn.go:73
18 /Users/dragosroua/gno/tm2/pkg/bft/state/execution.go:253
19 /Users/dragosroua/gno/tm2/pkg/bft/state/execution.go:102
20 /Users/dragosroua/gno/tm2/pkg/bft/consensus/state.go:1347
21 /Users/dragosroua/gno/tm2/pkg/bft/consensus/state.go:1275
22 /Users/dragosroua/gno/tm2/pkg/bft/consensus/state.go:1221
23 /Users/dragosroua/gno/tm2/pkg/bft/consensus/state.go:1252
24 /Users/dragosroua/gno/tm2/pkg/bft/consensus/state.go:1637
25 /Users/dragosroua/gno/tm2/pkg/bft/consensus/state.go:1483
26 /Users/dragosroua/gno/tm2/pkg/bft/consensus/state.go:691
27 /Users/dragosroua/gno/tm2/pkg/bft/consensus/state.go:650
28 /usr/local/go/src/runtime/asm_arm64.s:1172
--= /Error =--
,events:[]
--= /Error =--
from gno.
@irreverentsimplicity Dylan was referring to the txtar test I provided in my comment :)
They are automated integration tests that let us reproduce bugs. If you want to give a shot at creating one for this issue you have, please do. See directory gno.land/cmd/gnoland/testdata/
from gno.
Hey, I tried this code out and it seems to work. Maybe some PR has fixed it. https://gno.land/r/leon/test/avltestv1/package.gno
Calling Add, Remove, Add, Read works perfectly with reusing the same keys.
from gno.
@irreverentsimplicity we'll need to have a reproducible test for this issue. If you can still reproduce, ping me and I can help you work out a txtar.
from gno.
@thehowl I can still reproduce this.
Here is the last part of the error message:
Frames:
#3 [FRAME FUNC:Get RECV:(&(struct{(&(struct{("2" string),(undefined),(2 int8),(3 int),(&(struct{("1" string),(slice[ref(1b4fe769c2b0acba527e54f1eca22a38499de5b4:156)] []int64),(0 int8),(1 int),(nil *gno.land/p/demo/avl.Node),(nil *gno.land/p/demo/avl.Node)} gno.land/p/demo/avl.Node) *gno.land/p/demo/avl.Node),(&(ref(1b4fe769c2b0acba527e54f1eca22a38499de5b4:533) gno.land/p/demo/avl.Node) *gno.land/p/demo/avl.Node)} gno.land/p/demo/avl.Node) *gno.land/p/demo/avl.Node)} gno.land/p/demo/avl.Tree) *gno.land/p/demo/avl.Tree) (1 args) 7/3/0/3/4 LASTPKG:gno.land/r/demo/flippando LASTRLM:Realm{Path:"gno.land/r/demo/flippando",Time:563}#1B4FE769C2B0ACBA527E54F1ECA22A38499DE5B4]
#2 [FRAME FUNC:GetChildrenOf RECV:(undefined) (1 args) 5/2/0/2/3 LASTPKG:gno.land/r/demo/flippando LASTRLM:Realm{Path:"gno.land/r/demo/flippando",Time:563}#1B4FE769C2B0ACBA527E54F1ECA22A38499DE5B4]
#1 [FRAME FUNC:ListNFT RECV:(&(ref(1b4fe769c2b0acba527e54f1eca22a38499de5b4:32) gno.land/r/demo/flippando.Marketplace) *gno.land/r/demo/flippando.Marketplace) (3 args) 3/1/0/1/2 LASTPKG:gno.land/r/demo/flippando LASTRLM:Realm{Path:"gno.land/r/demo/flippando",Time:563}#1B4FE769C2B0ACBA527E54F1ECA22A38499DE5B4]
#0 [FRAME FUNC:ListMarketplaceNFT RECV:(undefined) (3 args) 1/0/0/0/1 LASTPKG:main LASTRLM:Realm(nil)]
Realm:
gno.land/r/demo/flippando
Exceptions:
Stack Trace:
0 /Users/dragosroua/gno/tm2/pkg/errors/errors.go:20
1 /Users/dragosroua/gno/gno.land/pkg/sdk/vm/keeper.go:318
2 /usr/local/go/src/runtime/panic.go:770
3 /Users/dragosroua/gno/gnovm/pkg/gnolang/store.go:254
4 /Users/dragosroua/gno/gnovm/pkg/gnolang/values.go:411
5 /Users/dragosroua/gno/gnovm/pkg/gnolang/ownership.go:343
6 /Users/dragosroua/gno/gnovm/pkg/gnolang/values.go:282
7 /Users/dragosroua/gno/gnovm/pkg/gnolang/op_assign.go:44
8 /Users/dragosroua/gno/gnovm/pkg/gnolang/machine.go:1380
9 /Users/dragosroua/gno/gnovm/pkg/gnolang/machine.go:734
10 /Users/dragosroua/gno/gno.land/pkg/sdk/vm/keeper.go:324
11 /Users/dragosroua/gno/gno.land/pkg/sdk/vm/handler.go:53
12 /Users/dragosroua/gno/gno.land/pkg/sdk/vm/handler.go:33
13 /Users/dragosroua/gno/tm2/pkg/sdk/baseapp.go:650
14 /Users/dragosroua/gno/tm2/pkg/sdk/baseapp.go:829
15 /Users/dragosroua/gno/tm2/pkg/sdk/helpers.go:17
16 /Users/dragosroua/gno/tm2/pkg/sdk/baseapp.go:418
17 /Users/dragosroua/gno/tm2/pkg/sdk/baseapp.go:391
18 /Users/dragosroua/gno/tm2/pkg/bft/abci/client/local_client.go:180
19 /Users/dragosroua/gno/tm2/pkg/bft/appconn/app_conn.go:144
20 /Users/dragosroua/gno/tm2/pkg/bft/rpc/core/abci.go:59
21 /usr/local/go/src/reflect/value.go:596
22 /usr/local/go/src/reflect/value.go:380
23 /Users/dragosroua/gno/tm2/pkg/bft/rpc/lib/server/handlers.go:185
24 /Users/dragosroua/gno/tm2/pkg/bft/rpc/lib/server/handlers.go:209
25 /usr/local/go/src/net/http/server.go:2166
26 /usr/local/go/src/net/http/server.go:2683
27 /Users/dragosroua/go/pkg/mod/github.com/rs/[email protected]/cors.go:281
28 /usr/local/go/src/net/http/server.go:2166
29 /Users/dragosroua/gno/tm2/pkg/bft/rpc/lib/server/http_server.go:216
30 /Users/dragosroua/gno/tm2/pkg/bft/rpc/lib/server/http_server.go:189
31 /usr/local/go/src/net/http/server.go:2166
--= /Error =--
,events:[]
--= /Error =--
I am still not sure if this is a coding error on my part, or some unusual behavior of avl.Tree. Steps to reproduce:
-
clone my branch: https://github.com/irreverentsimplicity/gno/tree/feat/flippando-testnet
-
restart the local dev chain, preferably with a clean gnoland-data folder & genesis.json
-
clone and run the UI from here: https://github.com/irreverentsimplicity/flippando-gno
-
run the UI with
npm install
,npm run dev
-
create 4 basic NFTs (4 flips)
-
access the UI from a new browser window (this will create a different account)
-
from that account, go to Playground, you should see the 4 basic NFTs created on the first account
-
assemble a new composite NFT (drag & drop the basic NFTs on the canvas) and click Make Art
-
go to My Art, you should see the composite NFT you just created
-
click List (ignore the non responsive UI, the transaction should go through) and pick a price under 4 FLIP
-
switch to the first account, and go to marketplace, you should see the listed NFT by the 2nd account
-
click Buy (ignore the non responsive UI, the transaction should go through)
-
go to My Art, you should see the composite NFT you just bought
-
click List and that should trigger the error
In terms of code, the main function call sequence is:
marketplace.ListNFT(...)
marketplace.BuyNFT(...)
marketplace.ListNFT(...)
Any feedback is highly appreciated. Thank you!
from gno.
Related Issues (20)
- Constant Declaration with Slice Type Compiles Without Error HOT 1
- [infra] Minimal Setup of Observability node running monitoring service
- `gno fmt` adds an extra line at the end of the file HOT 3
- Panic on Type Assertion with Interface HOT 2
- Incorrect Variable Assignment
- [infra] GnoFaucet - Create Healthcheck enpoint HOT 1
- Better Gno Error Handling HOT 1
- Removing the admin from the system contract entirely.
- error: primitive type int cannot be indexed
- [Native Banker] Implement `TotalCoin` HOT 2
- GnoDev - Conflicting Package Resolution Between Personal Repo and Examples Folder HOT 4
- Investigate effect of "0.0.0.0 Day" issue in browsers on running gno locally
- [Homepage] `/r/gnoland/featured` realm
- bug(gnovm): prohibit conversion of non-convertible typed constants
- Gno Playground - deploy on portal loop does not take my namespace input HOT 1
- [Debugger] Debug realms during transaction execution HOT 2
- GnoWeb not rendering correctly on Windows HOT 1
- Add timezone support to the gno standard library's `time` package
- How to verify the timestamp of a node? HOT 1
- Feature: GnoLinks BlockChain Interactions
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gno.