Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: proof of concept of w3up-on-zinnia #1338

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions packages/zinniup/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# ZinniUP

w3up blooms

## What is this?

This is a proof-of-concept of running w3up on a WASM-adjacent runtime.

Zinnia is "a sandboxed and resource-limited runtime for distributed workers" that
provides an easy way to run w3up on an execution platform that supports WASM.

This proof-of-concept shows that it is possible to run w3up in "a sandboxed
and resource-limited runtime" which may be useful if we'd like to enable many different
entities to run w3up instances.

## Installation

First, `pnpm install` in the same directory as this README.

Next, follow Zinnia's instructions to install the `zinnia` CLI:

https://github.com/filecoin-station/zinnia/blob/main/cli/README.md#installation

Finally, run `pnpm build` in the same directory as this README.

## Running

If you added `zinnia` to your shell `PATH`, `pnpm start` should run the
rollup-bundled script at `dist/main.js` which, as of 3/21/2024, will create
a w3up server, print a trivial log line, and exit.
35 changes: 35 additions & 0 deletions packages/zinniup/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "@web3-storage/zinniup",
"description": "The upload api for web3.storage, on Zinnia!",
"version": "0.0.0",
"type": "module",
"main": "./src/main.js",
"homepage": "https://web3.storage",
"repository": {
"type": "git",
"url": "https://github.com/web3-storage/w3up.git",
"directory": "packages/zinniup"
},
"files": [
"src",
"test",
"dist/**/*.d.ts",
"dist/**/*.d.ts.map"
],
"scripts": {
"build": "rollup -c rollup.config.js",
"start": "zinnia run dist/main.js"
},
"dependencies": {
"@ucanto/principal": "^9.0.0",
"@web3-storage/upload-api": "workspace:^"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-node-resolve": "^15.2.3",
"rollup": "^4.13.0"
},
"engines": {
"node": ">=16.15"
}
}
11 changes: 11 additions & 0 deletions packages/zinniup/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { nodeResolve } from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';

export default {
input: 'src/main.js',
output: {
dir: 'dist',
format: 'es'
},
plugins: [nodeResolve({ browser: true }), commonjs()]
};
17 changes: 17 additions & 0 deletions packages/zinniup/src/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import * as UploadAPI from '@web3-storage/upload-api'
import * as ed25519 from '@ucanto/principal/ed25519'

const servicePrincipal = await ed25519.generate()
/**
* TODO: remove this any type and add the appropriate context variables to make this work!
* @type {any}
*/
const context = {}

const server = UploadAPI.createServer({
...context,
id: servicePrincipal,
maxUploadSize: 10000
})

console.log(`started server ${server}`)
Loading
Loading