Giter Site home page Giter Site logo

blog's Introduction

Fission logo

Powering Microservices for Web3

FISSION is a set of useful status codes and translated messages to connect smart contracts of all kinds 🔌

Build Status Maintainability Coverage Status
ERC-1066 ERC-1444 ECIP-1050 Built with ❤ by SPADE Co

Quickstart

npm install --save fission-codes
// Solidity
pragma solidity ^0.5.0;
import { FISSION } from "/fission-codes/contracts/FISSION.sol";
// JavaScript
const fission = require("fission-codes");

Table of Contents

TL;DR

FISSION helps developers understand and build interoperable smart contracts. It establishes a common vocabulary for smart contracts to interact with a rich set of messages to tag data and common situations. It has applications in state transfer, development tooling, instrumentation, and user messaging.

  1. Improved feedback for humans (end users and developers alike)
  2. Helping developers understand their code at runtime
  3. Enhanced smart contract interoperability and autonomy

Motivation

The very essence and power of having a shared platform like a programmable blockchain is how it facilitates the flow of information. We pay for this abstraction with a speed penalty, but at the application layer there is no need to worry about the common issues in distributed systems: availability, stale state, locked data, and so on. This is an oft-overlooked advantage of this technology, so let’s make the most of it!

Not to be confused with a fluent interface, FISSION can be seen as a fluid interface — an common interface flowing between nodes. This stands in contrast to the concrete interfaces that we commonly see today on Ethereum: method signatures. These are not mutually exclusive concepts, but rather two halves of a very powerful whole!

The core of the FISSION is status codes. These provide the common interface to build messages, flows, and protocols from. This strategy isn’t limited projects under the FISSION umbrella; everyone is encouraged to build robust protocols from these building blocks!

The idea is very simple: 256 codes organized as a 16x16 table. The columns are categories (ex. permissions, time, off-chain, etc), and the rows are reasons (ex. failure, success, informational, required action). They are passed around as the first value in a multi-value return, or as an argument to a function.

This library makes it easy to construct codes, inspect them for conditions, automatically revert on failures, retrieve human-readable localizations, and so on.

Contract Autonomy

Smart contracts are largely intended to be autonomous. While each contract may define a specific interface, having a common set of semantic codes can help developers write code that can react appropriately to various situations.

In the above diagram, the dotted arrows are requests (or calls). The rest are responses (or returns) that contain FISSION codes: green arrows are success responses, and orange arrows are neither successes nor errors. By convention, the code is the first value in a request or multiple return.

Semantically Rich

HTTP status codes are widely used for this purpose. BEAM languages use atoms and tagged tuples to signify much the same information. Both provide a lot of information both to the programmer (debugging for instance), and to the program that needs to decide what to do next.

FISSIONs convey a much richer set of information than booleans, and are able to be reacted to autonomously unlike arbitrary strings.

User Feedback

Since status codes are finite and known in advance, we can provide global, human-readable sets of status messages. These may also be translated into any language, differing levels of technical detail, added as revert messages, natspecs, and so on.

We also see a desire for this in transactions, and there's no reason that FISSIONs couldn't be used by the EVM itself.

Web3 Microservices

Shared multi-user systems like Ethereum should lend themselves to easily sharing data. Data is decentralized in the sense that we don’t have one giant database with open access. Unlike how we can use on-chain libraries to share functionality (rather than redeploying the same classes over and over), the true value of most applications is the data that they contain. Unfortunately, the majority of bespoke architectures silo data behind access control and programmatic interfaces with only brittle and limited options for requesting this data. We need a way to help data flow between these silos.

Smart contracts decompose into two parts that may be of interest to others: behaviour and data. Behaviour on its own may be deployed to the network as a library. They are very flexible chunks of code that may be verified by the community as safe to use. In fact, this is arguably safer than even redeploying it from your own contract, since you have certainty about that exact bytecode.

Unlike behaviour, data is owned by particular contracts, and depends on a program to get and set values. The data itself may be valuable to other contracts (ex. a token balance or authorization). Rather than duplicating this data, a single home is both efficient and convenient. For any stateful data, this is obviously something that must live on chain rather than being redeployed.

Requesting data comes with its own set of use cases: access control, a missing value, expiration, out of range, and so on. Any smart contract that needs to request data from a collaborator (ie: lots of contracts) can leverage FISSION helpers to make it easy to autonomously handle these use cases without writing reams of code, or demanding human intervention.

This has been described as "microservices for web3". It is complementary to concrete interfaces (like ERC20). method interfaces are primarily mechanical (the “how”), data and status codes are primarily semantic (the “what”).

Example

Scenario

It's common for one group of users to make use of several contracts. It would be useful to register this information once, and share it among many different contracts, rather than duplicating this information across many places (with potential inconsistencies).

For instance, if a teammate is promoted to admin status, this should be reflected across all of the shared contracts. Likewise, if someone is banned, it is much easier to make this change once and rest assured that it covers all of our contracts.

Smart Contracts

Here is a contract that consolidates member rights in one place for this group of users. It returns a common set codes from FISSION as a simple way of communicating with other contracts (primarily about permissions).

pragma solidity ^0.5.0;

import { FISSION } from "fission-codes/contracts/FISSION.sol";

contract SimpleAuth {
    enum Level {
        Banned,
        Unregistered,
        Member,
        Admin
    }

    mapping (address => Level) private auth;

    constructor() public {
        auth[tx.origin] = Level.Admin;
    }

    function min(Level minLevel) public view returns (byte status) {
        if (auth[tx.origin] == Level.Banned) { return FISSION.code(FISSION.Status.Revoked); }
        if (auth[tx.origin] < minLevel) { return FISSION.code(FISSION.Status.Disallowed_Stop); }
        return FISSION.code(FISSION.Status.Allowed_Go);
    }

    function set(address who, Level level) public returns (byte status) {
        require(auth[tx.origin] == Level.Admin, "Must be an admin");
        auth[who] = level;
        return FISSION.code(FISSION.Status.Success);
    }
}

There may be many collaborator contracts. Below is a portfolio controlled by the SimpleAuth members.

pragma solidity ^0.5.0;

import { FISSION } from "fission-codes/contracts/FISSION.sol";
import { SimpleAuth } from "./SimpleAuth.sol";

contract Portfolio {
    SimpleAuth private auth;
    mapping (address => bool) private holdings;

    constructor (SimpleAuth control) public {
        auth = control;
    }

    function isHeld(address token) external view returns (byte status, bool held) {
        byte permission = auth.min(SimpleAuth.Level.Unregistered);
        if (FISSION.isBlocking(permission)) { return (permission, false); }
        return (FISSION.code(FISSION.Status.Found_Equal_InRange), holdings[token]);
    }

    function setTracking(address token, bool track) external returns (byte status) {
        FISSION.requireSuccess(auth.min(SimpleAuth.Level.Member));
        holdings[token] = track;
        return FISSION.code(FISSION.Status.Success);
    }
}

Resources

Documentation

Standards

This library contains implementations of these standards:

Ethereum Improvement Proposals (EIP)

Ethereum Classic Improvement Proposals (ECIP)

Articles

Discussions

Presentations

@expede presenting FISSION at Devcon IV

FAQ

Is this like HTTP status codes?

They're similar! FISSION is more structured and designed for smart contract use cases. Blockchains have different constraints than the web, and the design of FISSION reflects that!

Does this replace revert-with-reason?

Not at all! FISSION fully supports revert and revert-with-reason, and this library has several functions that make it easy to combine the two. Sometimes it makes sense to return a regular status code, and let the caller decide if it should revert. Of course you should immediately revert if there’s an overflow, or find ourselves with nonsensical state.

Is FISSION an acronym? What does "FISSION" stand for?

"FISSION" stands for the Fluid Interface for Scalable Smart Contract Interoperable Networks.

Badge

Feel free to put this badge on your FISSION-compatible projects to let others know that they can interop easily with your contracts!

FISSION compatible

<!-- README.md -->

[![FISSION compatible](https://github.com/fission-suite/fission-codes/raw/master/static/FISSION-badge.svg?sanitize=true)](https://fission.codes)
<!-- website.html -->
<a href="https://docs.fission.codes/fission-codes/"
  ><img
    alt="FISSION compatible"
    src="https://github.com/fission-suite/fission-codes/raw/master/static/FISSION-badge.svg?sanitize=true"
/></a>

Featured On

Sponsors

blog's People

Contributors

nichoth avatar walkah avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

nichoth

blog's Issues

Static site generation

Summary

Initial notes regarding ssg with the blog app. cc @walkah

Look at 'static site generation' type of workflow for the blog app

The 'feed' in the app is the content source. That then gets rendered whenever you call the 'publish' function.

There is a fairly direct map between files and the webnative context, just need to make sure that the built html files are published on the web (vs the source markdown files)

You wouldn't need to automate the build process, it can happen in the 'blog' app, b/c the built files would need to be in 'webnative' also, just in a separate directory from the source files.

Image upload

  • can save an image

What to do about UI for image input? Should have a 'preview' image before saving a post.

Image deduplication

Summary

Should not save the same blob multiple times

Problem

The images are linked to a blog post, but it is possible that the image could be saved & the blog feed not updated. And that's fine, it just means you would have a stray image sitting in ipfs. In that case you would re-post the post.

Could make a call to see if the given image filename exists already in webnative.

Solution

You could use a hash of the image as the filename, that way it would automatically de-duplicate the images if you wrote the same one again when you re-post the post.

text functionality

Continued from discord

Have a look at adding image uploading as a feature
Ideally write it up as an issue with how you think it should work

Related steps/features:

  • step one -- just save a blog post
  • how do you get the right feed?
    • see /src/pages/Editor.tsx
    • see /src/pages/Posts.tsx
        const feedPath = fs.appPath(wn.path.file("feed.json"));
        if (await fs.exists(feedPath)) {
    • feed should be higher in the state tree so it can be used in other views too (besides Posts)
  • should display existing posts on the 'home' view

image upload

  • could be a part of the 'new post' view
  • what to do with webnative? need to call fs.write with an image file
  • the 'new post' view should show the image as a preview

see notes

Implement post/item id generator

From the JSON Feed spec:

id (required, string) is unique for that item for that feed over time. If an item is ever updated, the id should be unchanged. New items should never use a previously-used id. Ideally, the id is the full URL of the resource described by the item, since URLs make great unique identifiers.

The URL would be nice, but if we haven't created the app yet, we won't necessarily know the canonical URL. It might be worth going with a UUID or some other identifier instead.

testing plan

What would be a good way to test this? Do people have preferences about what library/framework to use?

I have started writing tests using jest here -- https://github.com/nichoth/blog/blob/photo/test/feed.spec.ts

Jest was a good choice here because it just worked without much fiddling with things. There is a minimal jest config file -- jest.config.cjs, and that's all the setup I had to do to get it working with typescript and import syntax.

Next I was going to setup cypress and do some higher level tests -- checking the UI and seeing that the browser-based crypto works.


My normal tests for browser environment is tape + tape-run, an npm script like

"test-browser": "browserify test/index.js -p esmify | tape-run | tap-spec",

The advantage of this is that it is clearer to me about what is happening -- we compile the JS, then it runs in a new electron process (for a browser environment). The bad part about this is that we have to add another bundler (browserify), and I'm not sure how well it works with typescript.

The jest process feels like it is hiding more inside of the jest command -- need to compile the typescript and possibly bundle things. Is it running in a node process?

cc @walkah

Investigate rich text editors

Shall we embed a rich text editor?

Open to any others.

  • How hard is it to integrate / work with as a developer?
  • Make it work with Markdown?
  • Image uploads / integration?

This is a lightweight, as time permits task.

Show the published URL somewhere

Should show the user the URL & have a link to a public website/blog created with this app.

You have a public URL path of USERNAME.files.fission.name/p/PATH-TO-BLOG

Sharing this path would be one thing to have in the editor -- maybe like "View published blog" or something

Implement feed updates via context

Should have an app state context that will handle the following app-wide:

  • Initialize the feed object (if none exists)
  • Provide the current feed object
  • Allow updates (add item, edit item, remove item).

Documentation request -- publishing

How do other people read my blog posts?

It saves things to ipfs as is, how do you determine where, if anywhere, this is visible on the web?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.