owned this note
owned this note
Published
Linked with GitHub
# Stable DAOFusion
## Abstract
[Midjourney](https://midjourney.gitbook.io) is a very popular service for running Stable Diffusion -- it is a centralized service that has a free plan for people to try out SD, and eventually move to a [paid plan](https://midjourney.gitbook.io/docs/billing) for more GPU minutes.
This paper explores creating a decentralized version of Midjourney, underpinned + monetized by the DFSN coin and powered by Avalanche's Elastic Subnets (built at first for a crypto-enthusiastic audience).
## Motivation
It would be cool to build one of the first Proof of Stake Subnets as an appchain to help illustrate why the appchain thesis is a perfect fit for Subnets.
## Specification
Focusing on a v0.01, with friendly-audience assumptions being made.
### Components
#### FVM (FusionVM) Client
- Fork of `BlobVM`
- Takes an incoming ```GenerationRequestTX``` , makes sure its a valid request and then adds to mempool
- (tbd) gossips mempool to other nodes?
- (tbd) ```BlockBuilder``` scans mempool for ```GenerationRequestTX``` objects, for each found it commands a ```peer```'s `ComputeClient` to do the work generating the request
- (tbd) somehow make sure the `peer` doesnt cheat?
- (tbd) if the peer doesnt provide valid response within 5 minutes, they get slashed
- reading up on how the gossiping of transactions works and stuff now to nail down these details
#### ComputeClient
- Every node registers a `ComputeClient` when it joins the network as a validator
- Server that provides the compute power for a validator node
- (tbd) this is a modified Stable Diffusion client where we can input a bunch of parameters to get replicable results
#### Webapp
- a basic dApp that lets a user submit their prompt/metadata to our network, and pay with `DFSN` coin via metamask
- user can share their results to twitter
- marketing idea - we can run 'twitter contests' where the user with best performing shared tweets get some free `DFSN` coin
### User Flows
#### Alice
Alice is an existing Avalanche validator node operator, who is looking to get involved with Subnets and test out new blockchain technology.
Alice hears about DAOFusion, and wants to participate because she 1) is already an Avalanche Validator and 2) runs Stable Diffusion on her home PC all the time.
She is excited to participate in a new Subnet, and contribute her home hardware to the cause.
Alice uses the [APM](https://github.com/ava-labs/apm) to download the FVM (FusionVM) client to her Avalanche validator node. She requests an airdrop of DFSN tokens, and upon recieving it she stakes them in our staking contract through our WebApp.
Alice's node is now labeled as a Trial Validator. She sees instructions on the WebApp on how to register her hardware compute to FVM.
She downloads the ```ComputeClient``` to her home PC, and follows the onscreen instructions. She runs ```ngrok``` on her machine, grabs the exposed URL, and inputs it as her config to the FVM.
**NOTE: maybe we dont do this next part**
**/START**
She goes back to the webapp, presses "Test My Hardware", and submits a ```TestHardwareTX``` to her ```TrialNode```. She notices that her ```ComputeClient``` is starting to do some work creating a StableDiffusion image from the generated ```TestPrompt```. After a while, she sees that the ```WebApp``` updates her ```nodeStatus``` from ```TrialNode``` to ```FullNode```.
**/END**
Alice is pretty happy at this point, and knows that she needs to keep her Home PC running in order to service requests. For every successful request filled, she is awarded an amount of ```DFSN``` coins. For every request not filled, some of her staking principal is slashed.
#### Bob
Bob is a user who likes generating Stable Diffusion prompt, and is most likely a crypto twitter user. Bob is a Subnet-skeptic, but he likes cool crypto stuff.
Bob goes to ```WebApp```, buys a sack of ```DFSN``` coin (eg 1 dollar for 20 credits), enters in his prompt with parameters, and submits the request. He waits up to 5 minutes for his image, and clicks the 'share to twitter' button to share his creation!
## Rationale
Stable Diffusion is a deep learning, text-to-image model released by startup StabilityAI in 2022. A user types a prompt such as "big cat flying on the moon" (and inputs a few parameters), and the AI model generates a novel image based on the prompt.
[The results can be pretty cool](https://mpost.io/best-100-stable-diffusion-prompts-the-most-beautiful-ai-text-to-image-prompts/), people love sharing images they create on Twitter (which adds to the popularity of SD). The cons is that it takes beefy hardware to run the model in a reasonable amount of time, and not everyone has access to hardware.
## Test Cases
## Security Considerations