Growing Community with Spritely Goblins

Decent Social Unconference

2022-02-11

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 that makes building secure, distributed applications easy:

  • Peer-to-peer networking that you don't have to think about
  • Secure is the default
  • Easy fail state handling with transactions
  • And more!

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

Actors represent behavior within an application.

  • Actors send/receive asynchronous messages
  • Actors are composable
  • Actors may change their behavior
  • State changes are transactional
  • Actors may live on someone else's computer

1.7. Security

  • User-based access control list security is broken
  • Instead, actors provide the security model: If you don't have it, you can't use it
  • This is called object capability security

1.8. Networking

You can talk to actors on other computers by using the Object Capabilities Network (OCapN) protocol:

  • OCapN takes care of networking so you can focus on application logic
  • Talking to remote actors looks the same as talking to local ones
  • Currently in pre-standardization phase

1.9. Does Goblins = OCapN?

Nope! OCapN provides the network protocol, but you won't get Goblins' killer features like transactionality on any other actor-based system.

1.10. Let's talk about games

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

2. Building 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 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 (shown in a previous slide)

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 '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 there's a simple audit 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 (myself included) but the basics can be learned quickly
  • Goblins is secure by default
  • Goblins handles networking for you so you can focus on building application logic

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