Giter VIP home page Giter VIP logo

Comments (4)

gfanton avatar gfanton commented on August 17, 2024 7

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.

Week 1: ressources, setup and challenge

Gather Resources:

  • GNO Official Repo: gno
  • Curated List of GNO Resources: awesome-gno
  • Awesome GNO Tutorials: tutorials
  • GNO By Example: website
  • Getting Started Boards: README
  • Getting Started Repository: getting-started
  • Cool and Usefull Videos About GNO:
    • Intro to GNO: link
    • Create a Microblog with GNO: link (note: it's a bit outdated)

First Week Challenge:

  • Set up a local dev environment without blockchain (gno cli)

    • Setup Editor:
      • I'm using Emacs, and since there is no GNO mode yet, I created gno-mode, based on go-mode. Inspired by the VSCode extension, I will move this to a dedicated repo later.
    • Install GNO from GitHub:
      • I usually manage all my projects the old Golang way (with [org]/[name]), so I'm cloning gno into ~/code/gnoland/gno and executing a simple make to install the gno and gnokey binaries.
    • Getting Started:
      • Following the getting started page, I generated my first private key and saved the address and mnemonic into my password manager for quick access.
      • Checking my key with gnokey list: success.
      • The next step is to add some tokens to my address using the faucet on https://test3.gno.land/faucet. Well, not a success; as I'm writing these lines, this faucet seems to be down. I had to use https://staging.gno.land/faucet, which is reset every hour.
        • Note: Even on staging, I still have some random issues (like unauthorized error); I had to send my request multiple times to make it work.
      • Using gnokey query auth/accounts/<myaddr>, I can now see my token balance (targeting https://staging.gno.land).
      • The next step is to create a Board using the 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.
      • I haven't tried every call of every realm, but CreateThread was the only call that worked for me, using the default board (bid:1).
        • Maybe instructions are outdated on the 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.
        • I had to remove true from -broadcast true to make the examples work.
        • The -send argument should already be filled, at least for the getting started instructions.
        • The automatically generated help and source pages are totally awesome and super useful.
    • Improvement Ideas:
      • Besides correcting outdated information, a cool idea would be something similar to 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.
      • As a new user, it can be really frustrating to encounter some issues on a getting started page, especially with little knowledge of the project, as it's hard to determine if the problem comes from you or the given instructions.
  • Set up a local dev environment with blockchain (gnoland + gnoweb + gnokey)

    • The process is not really different from the previous exercise; the only difference is that instead of communicating with an already running remote instance, we use a local instance.
    • For this, I had to install some other tools located inside gno/gno.land, using the make build command to build all the remaining required tools (gnoland, gnoweb).
    • Then, simply running those two tools in two separate shell instances enabled me to access the testnet on https://localhost:8888 (with the web UI).
    • I was unable to make the faucet work locally, but I was able to edit the genesis file located at gno.land/genesis/genesis_balances to add my key address and set my starting balance to an arbitrary amount.
      • I had to remove the gnoland data folder and restart the node to make the change take effect.
    • Ultimately, I ended up with the same result as the previous exercise.
  • Writing contracts

    • Exploring Existing Contracts

      • Before writing my own smart contracts, I delved into the existing set of smart contracts from example directory in the main repo to see how things work, playing around with the gno binary, which is very similar to the go binary. I was able to run the whole set of GNO file tests.
        • It appears that running every _test file ended up with a panic: package ./gnovm/stdlibs/bufio already exists in cache.
      • I also encountered some issues running tests outside the 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.
      • Besides that, gnovm seems to work fine with most existing Golang syntax, and looks really handy to write.
    • Hello World

      • For my first contact, I wrote down a simple contract with a basic counter state that can be incremented with an 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: gnolang/gno#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.

        • While digging into the code, I was a little confused by the large number of 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 ...

from hackerspace.

moul avatar moul commented on August 17, 2024 1

Welcome, Cosmonaut! 🚀 Feel right at home in this new environment, where your past experiences pave the way for exciting possibilities. 🌌 Enjoy the voyage!

from hackerspace.

moul avatar moul commented on August 17, 2024 1

https://gist.github.com/gfanton/6e233656dfeabd7a46f21f7507b6b311 -> Awesome-gno, please!

from hackerspace.

moul avatar moul commented on August 17, 2024

@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.

from hackerspace.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.