Skip to content

Commit

Permalink
feat: add nebular slides (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
moul authored Jul 24, 2023
1 parent 8b77f30 commit c2a4166
Show file tree
Hide file tree
Showing 13 changed files with 269 additions and 0 deletions.
2 changes: 2 additions & 0 deletions presentations/2023-07-24--talk-nebular--manfred/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
run:
cd ..; go run golang.org/x/tools/cmd/present -http 0.0.0.0:3999 # -base ../..
25 changes: 25 additions & 0 deletions presentations/2023-07-24--talk-nebular--manfred/code/cosmos-sdk.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package keeper // OMIT
// cli/cli.go, msg.go, handler.go, >keeper.go<
// * keeper/handler pattern, "ctx", binary codec, determinism
import (
"strconv" // OMIT
// OMIT
"github.com/gnolang/gno/pkgs/sdk"
)

type Keeper struct{ storeKey storetypes.StoreKey } // expected to be prefix store.

func (k *Keeper) Incr(sdk.Context) {
store := ctx.KVStore(k.storeKey)
bz := store.Get("x")
if bz == nil {
panic("XXX")
}
x, err := strconv.Atoi(bz)
if err != nil {
panic("XXX")
}
x += 1 // all we wanted // HL
bz = strconv.Itoa(x)
store.Set("x", bz)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#[cfg_attr(not(feature = "library"), entry_point)]
pub fn execute(
deps: DepsMut,
_env: Env,
info: MessageInfo,
msg: ExecuteMsg,
) -> Result<Response, ContractError> {
match msg {
ExecuteMsg::Increment {} => increment(deps),
}
}

pub fn increment(deps: DepsMut) -> Result<Response, ContractError> {
STATE.update(deps.storage, |mut state| -> Result<_, ContractError> {
state.count += 1; // HL
Ok(state)
})?;

Ok(Response::new().add_attribute("method", "increment"))
}
7 changes: 7 additions & 0 deletions presentations/2023-07-24--talk-nebular--manfred/code/demo.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package demo

var x int

func Incr() {
x += 1
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// simple chicken-egg problem resolving
if sdk.RealmExists("gno.land/r/demo/foo") {}

// load the realm as a Go object
r := sdk.GetRealm("gno.land/r/demo/foo")

// retrieve the state of a variable without executing the contract, cheap
v, _ := r.GetState("things")

// similar to calling the contract from a transaction, more dynamic but expensive
ret, _ := r.Call("HasAccess", ...args)

// appends an event to contract's incoming queue, consumed later with `evt := <-std.Recv()`
r.Send(abci.Event{...})

// reads events from contract's outgoing queue
e := r.Recv()

// interact with realms' bankers methods
banker := r.Banker.XXX

// subscribe to specific events to trigger actions
sdk.Subscribe(filterFn, callbackFn)
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// r/system/config: contributors DAO votes for chain configuration changes (runtime limits, etc)
func Propose() {}
func Apply{}

// baseapp: the baseapp subscribes to changes happening in the contract
sdk.Subscribe(configChangedFilterFn, applyConfigChange)

// baseapp: to fetch the expected configuration
sdk.GetRealm("r/system/config").GetState("chainCfg")

// baseapp: during abci.EndBlocker
bft.XXX(opts...)

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// baseapp: chain fees (gas) are sent to the rewards' banker.
gasDestination := sdk.GetRealm("r/system/rewards").Banker().Addr()

// r/system/rewards: Distribution logic implemented in the contract,
// querying other contracts, applying rules.
import "gno.land/r/system/validators"
import "gno.land/r/gnoland/dao"
func Distribute() {
// Split rewards among recipients.
}

// Baseapp: Relevant chain events (double sig, etc.) can be sent to the contract.
r.GetRealm("r/system/rewards").Send(abci.Event{})
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// baseapp: hook when `AddPkg` is called in a transaction
sdk.Subscribe(filterFn, callbackFn)

// baseapp: if realm does not exist, skip validation
if !sdk.HasRealm("r/system/names") {
return true
}

// baseapp: returns list of available personal and team namespaces (manfred, gnocore, teamfoo)
sdk.GetRealm("r/system/names").Call("GetGroups", "manfred")

// baseapp: if namespace matches
if matches {
return true
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// r/system/config: contributors DAO votes for chain configuration changes (runtime limits, etc)
func Propose() {}
func Apply() {}

// baseapp: the baseapp subscribes to changes happening in the contract
sdk.Subscribe(valsetChangedFilterFn, applyValsetFn)

// baseapp: to fetch the expected configuration
updates := sdk.GetRealm("r/system/validators").GetState("updates")

// baseapp: during abci.EndBlocker
bft.ValidateValidatorUpdates(updates)
23 changes: 23 additions & 0 deletions presentations/2023-07-24--talk-nebular--manfred/code/goapp.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package counter

import (
"io/ioutil"
"strconv"
)

func IncrementCounter() (int, error) {
counterBytes, err := ioutil.ReadFile("counter.txt")
if err != nil {
return 0, err
}
counter, err := strconv.Atoi(string(counterBytes))
if err != nil {
return 0, err
}
counter += 1 // HL
err = ioutil.WriteFile("counter.txt", []byte(strconv.Itoa(counter)), 0644)
if err != nil {
return 0, err
}
return counter, nil
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

______ ____ ____ __
/ ____/___ _____ ___ ___ ____ / __/ / __ \___ ____ _/ /___ ___ _____
/ / __/ __ `/ __ `__ \/ _ \ / __ \/ /_ / /_/ / _ \/ __ `/ / __ `__ \/ ___/
/ /_/ / /_/ / / / / / / __/ / /_/ / __/ / _, _/ __/ /_/ / / / / / / (__ )
\____/\__,_/_/ /_/ /_/\___/ \____/_/ /_/ |_|\___/\__,_/_/_/ /_/ /_/____/


107 changes: 107 additions & 0 deletions presentations/2023-07-24--talk-nebular--manfred/presentations.slide
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# Examining Gno Core Stack
Differences between the Cosmos SDK and the Gnolang SDK
24 Jul 2023
Tags: gnolang, gnoland, gno, gnosdk, cosmos, proof-of-contribution, consensus, tendermint, bft, smart contract, blockchain
Summary: TODO

Manfred Touron
VP Eng., Gno.land
https://gno.land/
https://github.com/gnolang
@moul

## What is Gno?
- Timeless code ecosystem
- Gnolang/GnoVM: comprehensive smart contract suite, based on Golang
- Gno.land: first L1 using Gnolang
- built on Tendermint2 in the Cosmos/IBC ecosystem
- aims for fairness, simplicity, security, scalability
- -> long-term viability

## What is Gnolang?
- optimized for blockchain
- deterministic execution
- auto-persisted, without ORM
- interpreted, apps + lib
- auto-merkle-ized, with rich types
- built-in rendering
- auto-generated documentation
- "std"

## Increment a counter in Gno
.code ./code/demo.gno

## Increment a counter in Cosmos SDK
.code ./code/cosmos-sdk.go

## Increment a counter in Cosmwasm/Rust
.code ./code/cosmwasm-rust.rs

## Increment a counter in a Go app
.code ./code/goapp.go

## What is Gno.land?
- GnoVM + Tendermint2
- "GnoHub", home of Gno realms and pure packages (IBCx)
- first of a series of GnoVM chains
- simple, secure, reliable, trustable

## Gno.land interop
- IBC soon after mainnet
- ICS consumer of the Cosmos hub
- ICS provider for GnoVM chains
- specialized nodes and sharding, x.gno.land
- IBC2/GNO/x

## IBC2/GNO/x
- the first implementation looks like go channels (In, Out) from contracts PoV
- preserves type-safety and rich type
- permissionless IBC
- local IBC
- could be linked with non-gno and non-cosmos chains, i.e., `.gno<->.sol`
- IBC is "Cross-border payments"; IBCx is "Cross-border applications"

## Gno clients vs Gno SDK
- clients: series of clients to interact with the chain and create richer dApps:
- `tm2-js-client`, generic RPC client for chains build with Tendermint2
- `gnovm-js-client` extension to publish, read, inspect and interact with contracts
- `gnoland-js-client`, uses the two above + configuration to interact with the gno.land chain -> for most developers
- Gno SDK: Golang library to customize appChains using GnoVM and Tendermint2, similar goal with Cosmos SDK

## Gno SDK
- realm/contract-centric
- minimized validator upgrades, enhanced system stability
- unified transparency: clear contracts and chain configuration
- instant finality for governance
- bridging chains and contracts, seamless integration & versatility
- addressing chicken-egg problem
- gno.land is the initial version, generic SDK to come after

## Gno SDK _potential_ API
.code code/gno-sdk-api.go

## GnoSDK example: chain configuration
.code code/gno-sdk-chainconfig.go

## GnoSDK example: proof-of-contribution
.code code/gno-sdk-valset.go

## GnoSDK example: chain fees distribution
.code code/gno-sdk-distribution.go

## GnoSDK example: namespace support for package paths
.code code/gno-sdk-names.go

## What is Game of realms?
- ongoing competition for contributors
- experimental phase for proof of contributions
- building **Evaluation DAO**, and the new governance module
- earn $ATOM and become member on mainnet genesis

.code ./code/gor-banner.txt

## Action Items
* follow github.com/gnolang/gno
* visit gno.land
* help us create "Game of Realms"
* contribute!

0 comments on commit c2a4166

Please sign in to comment.