Closed gfanton closed 1 month ago
Welcome, Cosmonaut! 🚀 Feel right at home in this new environment, where your past experiences pave the way for exciting possibilities. 🌌 Enjoy the voyage!
Quick introduction about myself: I previously worked at Berty, a distributed secure messenger, where I played a lot with IPFS
and its underlying network library libp2p
. I've been working with Golang for around 5 years, especially on mobile. Apart maybe from the original Bitcoin paper, I currently have little to zero knowledge of the blockchain ecosystem.
[X] Set up a local dev environment without blockchain (gno cli)
go-mode
. Inspired by the VSCode extension, I will move this to a dedicated repo later.[org]/[name]
), so I'm cloning gno
into ~/code/gnoland/gno
and executing a simple make
to install the gno
and gnokey
binaries.gnokey list
: success.gnokey query auth/accounts/<myaddr>
, I can now see my token balance (targeting https://staging.gno.land).gnokey maketx call
on the https://staging.gno.land/r/demo/boards realm using the CreateBoard
method (located in public.gno). Unfortunately, it wasn't successful, and it ended with an unauthorized
error.CreateThread
was the only call that worked for me, using the default board (bid:1).
getting started
page? I have already corrected some links, so I won't be surprised if some calls haven't been updated for a while.true
from -broadcast true
to make the examples work.-send
argument should already be filled, at least for the getting started instructions.help
and source
pages are totally awesome and super useful.org-babel
but with Markdown, extracting all snippets as single or multiple independent bash block(s) and executing against a local chain for continuous testing.[X] Set up a local dev environment with blockchain (gnoland + gnoweb + gnokey)
gno/gno.land
, using the make build
command to build all the remaining required tools (gnoland
, gnoweb
).gno.land/genesis/genesis_balances
to add my key address and set my starting balance to an arbitrary amount.
data
folder and restart the node to make the change take effect.[X] Writing contracts
Exploring Existing Contracts
gno
binary, which is very similar to the go
binary. I was able to run the whole set of GNO file tests.
_test
file ended up with a panic: package ./gnovm/stdlibs/bufio already exists in cache
.gno
main repo; for example, this test located in the getting started repository wasn't working from scratch for me. The test was unable to find the std
library, and it took me some time to realize that I was missing the root-dir
argument. Looking at the code to find out how guessing the root dir works took me here, where basically the root dir is guessed by reading an upper go.mod
file using go mod list
to find gno
location; doing a go mod download
should have fixed my issue. I ended up making a small pull request adding GNOROOT
as an environment variable so it can be set globally.Hello World
Incr
method and rendered with the Render
method. I believe this is perhaps the most straightforward example you can create using the state feature of GNO:
var counter int
func Incr() { counter += 1 }
func Render(string) string { b := new(strings.Builder) b.WriteString("# gfanton's Realm\n\n") b.WriteString(ufmt.Sprintf("### this is my super gfanton counter: %d\n", counter)) return b.String() }
* I then published it on my local node using `gnokey maketx addpkg -pkgpath "gno.land/r/gui/gfrealm"`: *success*. I can now access it at: http://localhost:8888/r/gui/gfrealm and increase my counter calling the `Incr` with `gnokey maketx call -func "Incr"`
* Later on, you quickly realize that if you want to make some updates to your contract, it's impossible for now. If you really want to make some changes, you will need to publish it with a new pkgpath: `gno.land/r/gui/gfrealm2`. While it can make sense that you can't update your contract on a chain, it left me confused about how to manage things. I ended up versioning my pkg by publishing successively on `gno.land/r/gui/gfrealmX` (where X is my version), whether or not that makes sense.
Subscription
My next challenge was to continue working on a Subscriptions
contract from this PR: https://github.com/gnolang/gno/pull/1025
The first thing that caught me off guard when writing a larger contract is that without a linter, debugging becomes quite challenging. You have to do a lot of back and forth to guess the type or name of the method you want to call from the standard library. Essentially, you write down your contract and then repeatedly run go test .
to fix the errors one by one. This was so frustrating to me that I decided to take the gno test
run process part and put it inside the gno lint
command (which appears to be a work in progress) so I could integrate it into my editor to have real-time errors. This also enabled me to dig a bit deeper into the GNO code to see how things work. For the curious, here is the small change I made to make this works. It's a bit ugly and far from perfect, as it seems to only work on testing packages for now, but it's far enough for me to work under satisfactory conditions.
panic
calls, especially in the lower-level parts of the codebase (for example, in preprocess.go
). From my own personal experience, I feel this is unusual in Go, but it's not necessarily wrong; it just took me a while to handle it "properly" on the linter side, as I'm not used to handling errors this way.TO CONTINUE ...
@gfanton, would you like to include a conclusion to wrap up and archive this onboarding journey? We can refer to awesome-gno for guidance if needed.
I love how this journey stopped being updated after week 1
Time to chaos: 1 week 😂 cc @aeddi
Welcome to My Onboarding Journey!
Hello future contributors 👋
Embarking on this project? Follow my footsteps. From the initial setup to my first GNO contract, I will try to document my entire onboarding experience right here.
So grab your favorite beverage ☕️, sit back, and join me on this expedition!