Growing Community with Spritely Goblins

1. Introduction

1.1. Hi!

I'm David Thompson, the Core Infrastructure Architect at the Spritely Networked Communities Institute!

  • I've been a professional software developer for >10 years
  • I joined Spritely in December 2022
  • I want to share my experience as a beginner with Spritely Goblins

1.2. About Spritely Institute

spritely-logo.png

We are a 501(c)(3) nonprofit that is focused on re-decentralizing networked communities.

1.3. Founders

  • Christine Lemmer Webber (FOSS and social networking)
    • ActivityPub
    • The Spritely Project
    • MediaGoblin
  • Randy Farmer (40+ years working with social platforms)
    • Electric Communities
    • Avatars
    • E
    • JSON

1.4. What is Goblins?

Goblins is a library for building distributed applications!

  • Peer-to-peer communication (no gatekeepers!)
  • Secure by default (object capabilities)
  • Write local code that just works over the network

1.5. Why build new architecture?

Goblins opens doors for new (and secure!) decentralized social experiences that go beyond federated web applications such as interactive virtual worlds!

1.6. Let's talk about games

  • I think games are a fun, engaging way to demonstrate new ideas
  • I like to garden
  • Christine (cofounder) suggested I make a tile-based gardening game to demonstrate my progress with understanding Goblins

2. Build a game demo with Goblins

2.1. The concept

My demo was modeled after a community garden:

  • Multiple users share the garden space represented as an 8x8 tile grid
  • Users can plant and dig up tiles, but they must abide by the community rules that state which kinds of plants are allowed

2.2. Limitations

  • I didn't know how to program with Goblins yet
  • I only had 2 days

Thus I had to keep things really simple!

2.3. The result

graphics.png

2.4. The actors

  • The Garden: The shared growing space
  • The Gardener: Someone who can modify a garden
  • The Botanist: The resident plant expert that says which plants are allowed to be grown in the garden
  • The Garden Gate: The place where gardeners check-in to get approval before planting something

2.5. Example: The botanist

(define (^botanist bcom)
  (define-values (seal-plant unseal-plant approved-plant?)
    (make-sealer-triplet))
  (methods
   ((approve-plant plant)
    (seal-plant plant))
   ((check-plant plant)
    (if (approved-plant? plant)
        (unseal-plant plant)
        (error "plant is not allowed" plant)))))

2.6. Example: Spawning a new garden

;; Create the garden.
(define the-botanist (spawn ^botanist))
(define the-garden-gate (spawn ^garden-gate the-botanist))
(define our-garden
  (spawn ^garden
         "Spritely Institute Community Garden"
         (make-garden-bed 8 8)
         the-garden-gate))
;; Sunflowers are allowed.
(define sunflower/approved
  ($ the-botanist 'approve-plant sunflower))
;; Alice likes to garden.
(define alice (spawn ^gardener "Alice" our-garden))
($ alice 'plant 2 2 sunflower/approved)

2.7. Text visualization

With the essential actors in place, I could edit the garden with code and output the garden state as text.

text-render.png

That's not very exciting, so I quickly moved on to adding a graphical renderer that was shown a few slides back!

2.8. Network interaction

  • The program was split up into a host side and a client side
  • A Tor Onion service was used as the network transport layer
  • Messaging remote actors works just like messaging local ones!
  • This is the first time I've ever made a multiplayer game!

2.9. Multiplayer in action

multiplayer.png

2.10. Example: Sharing a garden

(define garden (spawn ^garden ...))
(define community (spawn ^garden-community garden))
(define user-name "Bob")
(define user ($ community 'register-gardener user-name))
(define onion-netlayer (new-onion-netlayer))
(define mycapn (spawn-mycapn onion-netlayer))
(let ((community-sref ($ mycapn 'register (community host) 'onion)))
  (format #t "Connect to: ~a\n"
          (ocapn-id->string community-sref))

2.11. Example: Joining a shared garden

(define community-sref
  (string->ocapn-id community-address))
(define onion-netlayer (new-onion-netlayer))
(define mycapn (spawn-mycapn onion-netlayer))
(define community (<- mycapn 'enliven community-sref))
(define user-name "Alice")
(define user
  (<- community 'register-gardener user-name))

2.12. Audit logging

It's good for the host to know what events have occurred in the garden, so I added a log.

audit-log.png

2.13. A notable omission

  • This demo is auditable, but access to the garden is not revokable should someone abuse their privileges!
  • This was a limitation of time, not Goblins!
  • A future version of this demo could easily add the revocation capability

2.14. Extrapolating

  • A real community garden simulator could have lots of social elements!
  • Users could visit/host many gardens, each with their own community rules

3. Conclusion

3.1. Summary

  • Goblins presents concepts that are new to many of us
  • However, the basics can be learned quickly!
  • Goblins enables iterative development
  • Focus on modeling actors first
  • Networking is easily added after

3.2. Our supporters

FFDW-logo.png

logo_nlnet.png

mmgdao.svg

Agoric-logo-color.png

3.3. Thank you!

For more information, check out:

https://spritely.institute

https://spritely.institute/goblins/