gnolang / gno

Gno: An interpreted, stack-based Go virtual machine to build succinct and composable apps + Gno.land: a blockchain for timeless code and fair open-source
https://gno.land/
Other
844 stars 344 forks source link

gnoland automatically adds realms #1123

Closed schollz closed 9 months ago

schollz commented 9 months ago

Description

I've been out for a few weeks and coming back there is a new change that I wasn't expecting. When I am working on a realm (currently working on /r/demo/art/haiku), I am finding that gnoland is automatically creating a realm before making a transaction.

Reproduce

Create a realm folder (I'm using https://github.com/schollz/gno/tree/realm/haiku with the haiku realm added) and start gnoland. I use the following script to spin-up a fresh gnoland locally:

#!/bin/bash
# run from gno/ folder
pkill -f 'build/gnoland'
pkill -f 'build/gnoweb'
rm -rf gno.land/testdir
cd gno.land && ./build/gnoland start & 
sleep 3
cd gno.land && ./build/gnoweb -bind 0.0.0.0:8888 & 
sleep 3

Now I can query the realm before creating a transaction to add it:

> curl localhost:8888/r/demo/art/haiku

Expected behaviour

Previously, the behavior was that it would produce a response correctly saying it could not find realm:

> curl localhost:8888/r/demo/art/haiku
error querying realm package

Actual behaviour

Now it actually prints out some HTML from a different realm:

> curl localhost:8888/r/demo/art/haiku
<!DOCTYPE html>
<html>
  <head>
    <title>Gno.land</title>
...

Problem

The problem is that I can't seem to add a realm anymore because it "already exists" though it has not actually been added:

> gnokey maketx addpkg --pkgpath "gno.land/r/demo/art/haiku" --pkgdir "examples/gno.land/r/demo/art/haiku" --deposit 100000ugnot --gas-fee 2000000ugnot --gas-wanted 10000000 --broadcast --chainid dev --remote localhost:26657 zzkey1 
Enter password.
--= Error =--
Data: invalid package path
Msg Traces:
    0  /home/zns/Documents/gno/tm2/pkg/crypto/keys/client/addpkg.go:214 - deliver transaction failed: log:msg:0,success:false,log:--= Error =--
Data: vm.InvalidPkgPathError{abciError:vm.abciError{}}
Msg Traces:
    0  /home/zns/Documents/gno2/tm2/pkg/sdk/vm/errors.go:23 - package already exists: gno.land/r/demo/art/haiku

Perhaps this is all expected behavior now? If so, I'm not sure how to add my realm in when starting gnoland.

thehowl commented 9 months ago

Yes, expected behaviour. https://github.com/gnolang/gno/pull/763 (tl;dr: everything with a gno.mod in examples gets automatically loaded)

Because realm/pkg upgrades are still up for discussion (#694), current behaviour is to reject any addpkg to an existing path. Suggestion is to change the name to something else. (For my own pet-project, I configured an auto-deployer that watches for fs changes, and publishes the realm with a random numerical suffix, ie gno.land/r/demo/chess_1234)

schollz commented 9 months ago

Thanks, changing the name works! Also love the auto-deployer, I have something similar in a makefile but yours is much more clever.