diff --git a/presentations/2023-07-24--talk-nebular--manfred/Makefile b/presentations/2023-07-24--talk-nebular--manfred/Makefile new file mode 100644 index 0000000..23ef1d0 --- /dev/null +++ b/presentations/2023-07-24--talk-nebular--manfred/Makefile @@ -0,0 +1,2 @@ +run: + cd ..; go run golang.org/x/tools/cmd/present -http 0.0.0.0:3999 # -base ../.. diff --git a/presentations/2023-07-24--talk-nebular--manfred/code/.#gno-sdk-api.go b/presentations/2023-07-24--talk-nebular--manfred/code/.#gno-sdk-api.go new file mode 120000 index 0000000..7f2be9a --- /dev/null +++ b/presentations/2023-07-24--talk-nebular--manfred/code/.#gno-sdk-api.go @@ -0,0 +1 @@ +moul@moul-dorado.23396 \ No newline at end of file diff --git a/presentations/2023-07-24--talk-nebular--manfred/code/cosmos-sdk.go b/presentations/2023-07-24--talk-nebular--manfred/code/cosmos-sdk.go new file mode 100644 index 0000000..73c5cd4 --- /dev/null +++ b/presentations/2023-07-24--talk-nebular--manfred/code/cosmos-sdk.go @@ -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) +} diff --git a/presentations/2023-07-24--talk-nebular--manfred/code/cosmwasm-rust.rs b/presentations/2023-07-24--talk-nebular--manfred/code/cosmwasm-rust.rs new file mode 100644 index 0000000..4241f6d --- /dev/null +++ b/presentations/2023-07-24--talk-nebular--manfred/code/cosmwasm-rust.rs @@ -0,0 +1,20 @@ +#[cfg_attr(not(feature = "library"), entry_point)] +pub fn execute( + deps: DepsMut, + _env: Env, + info: MessageInfo, + msg: ExecuteMsg, +) -> Result { + match msg { + ExecuteMsg::Increment {} => increment(deps), + } +} + +pub fn increment(deps: DepsMut) -> Result { + STATE.update(deps.storage, |mut state| -> Result<_, ContractError> { + state.count += 1; // HL + Ok(state) + })?; + + Ok(Response::new().add_attribute("method", "increment")) +} diff --git a/presentations/2023-07-24--talk-nebular--manfred/code/demo.gno b/presentations/2023-07-24--talk-nebular--manfred/code/demo.gno new file mode 100644 index 0000000..bf1d3fb --- /dev/null +++ b/presentations/2023-07-24--talk-nebular--manfred/code/demo.gno @@ -0,0 +1,7 @@ +package demo + +var x int + +func Incr() { + x += 1 +} diff --git a/presentations/2023-07-24--talk-nebular--manfred/code/gno-sdk-api.go b/presentations/2023-07-24--talk-nebular--manfred/code/gno-sdk-api.go new file mode 100644 index 0000000..f3c5b15 --- /dev/null +++ b/presentations/2023-07-24--talk-nebular--manfred/code/gno-sdk-api.go @@ -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) diff --git a/presentations/2023-07-24--talk-nebular--manfred/code/gno-sdk-chainconfig.go b/presentations/2023-07-24--talk-nebular--manfred/code/gno-sdk-chainconfig.go new file mode 100644 index 0000000..8987fba --- /dev/null +++ b/presentations/2023-07-24--talk-nebular--manfred/code/gno-sdk-chainconfig.go @@ -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...) + diff --git a/presentations/2023-07-24--talk-nebular--manfred/code/gno-sdk-distribution.go b/presentations/2023-07-24--talk-nebular--manfred/code/gno-sdk-distribution.go new file mode 100644 index 0000000..8bdc0a8 --- /dev/null +++ b/presentations/2023-07-24--talk-nebular--manfred/code/gno-sdk-distribution.go @@ -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{}) diff --git a/presentations/2023-07-24--talk-nebular--manfred/code/gno-sdk-names.go b/presentations/2023-07-24--talk-nebular--manfred/code/gno-sdk-names.go new file mode 100644 index 0000000..eed9f97 --- /dev/null +++ b/presentations/2023-07-24--talk-nebular--manfred/code/gno-sdk-names.go @@ -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 +} diff --git a/presentations/2023-07-24--talk-nebular--manfred/code/gno-sdk-valset.go b/presentations/2023-07-24--talk-nebular--manfred/code/gno-sdk-valset.go new file mode 100644 index 0000000..1e3045a --- /dev/null +++ b/presentations/2023-07-24--talk-nebular--manfred/code/gno-sdk-valset.go @@ -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) diff --git a/presentations/2023-07-24--talk-nebular--manfred/code/goapp.go b/presentations/2023-07-24--talk-nebular--manfred/code/goapp.go new file mode 100644 index 0000000..06e7882 --- /dev/null +++ b/presentations/2023-07-24--talk-nebular--manfred/code/goapp.go @@ -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 +} diff --git a/presentations/2023-07-24--talk-nebular--manfred/code/gor-banner.txt b/presentations/2023-07-24--talk-nebular--manfred/code/gor-banner.txt new file mode 100644 index 0000000..2f0d444 --- /dev/null +++ b/presentations/2023-07-24--talk-nebular--manfred/code/gor-banner.txt @@ -0,0 +1,8 @@ +  + ______ ____ ____ __ + / ____/___ _____ ___ ___ ____ / __/ / __ \___ ____ _/ /___ ___ _____ + / / __/ __ `/ __ `__ \/ _ \ / __ \/ /_ / /_/ / _ \/ __ `/ / __ `__ \/ ___/ + / /_/ / /_/ / / / / / / __/ / /_/ / __/ / _, _/ __/ /_/ / / / / / / (__ ) + \____/\__,_/_/ /_/ /_/\___/ \____/_/ /_/ |_|\___/\__,_/_/_/ /_/ /_/____/ +  +  diff --git a/presentations/2023-07-24--talk-nebular--manfred/presentations.slide b/presentations/2023-07-24--talk-nebular--manfred/presentations.slide new file mode 100644 index 0000000..7f46d3a --- /dev/null +++ b/presentations/2023-07-24--talk-nebular--manfred/presentations.slide @@ -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!