filecoin-project / devgrants

👟 Apply for a Filecoin devgrant. Help build the Filecoin ecosystem!
Other
369 stars 307 forks source link

Glow on Lurk on FVM — private smart contracts for Filecoin #1579

Closed fare closed 1 year ago

fare commented 1 year ago

Open Grant Proposal: Glow on Lurk on FVM — private smart contracts for Filecoin

Project Description

We propose to make our language Glow work on the Filecoin ecosystem while using Lurk for Privacy.

We are Mutual Knowledge Systems, a.k.a. MuKn (pronounced “Moon”—the “K” is silent), a blockchain-agnostic cryptocurrency technology company.

Glow is our safe, user-friendly and portable Domain-Specific Language (DSL) to develop Decentralized Applications (DApp). See the Glow Whitepaper.

We previously built a prototype of Glow working on top of Filecoin's Lurk: https://github.com/MuKnSys/glow-on-lurk

We propose to turn this Lurk prototype into code that actually runs on top of the FVM, thus providing a general solution for fully private smart contract on Filecoin. Quite probably a first on any blockchain.

Our initial prototype will only support private interactions between two parties. Supporting more than two participants in a private interaction is conceptually easy but requires noticeably more work, and could be the topic of a follow-up grant. Supporting public interactions that anyone can join yet uses zk-SNARKs for succintness requires our AVOUM technology which is possible but involves significantly more work, and would require a larger commitment.

Value: The Power of Abstraction

Compared to other “smart contract” languages such as Solidity or Rust, Glow provides a much higher level of abstraction, including built-in support for participants and assets. Abstraction means that:

By funding support for Glow on the FVM via Lurk, Filecoin will be experience the following benefits:

As part of this grant proposal, we will do a basic port of Glow to the FVM via Lurk, demonstrating both the feasability of such a port and the utility of Glow, but without any Filecoin-specific feature.

Deliverables

Low-hanging Fruits in a Tall Tree

Our complete plan for Glow goes all the way from implementing simple private interactions on the EVM (what it can do now) to a complete cross-chain application ecosystem integrated with the user’s wallets and connected to a network of liquidity providers between all pairs of assets (directly or indirectly).

This proposal is only for Glow as a private smart contract solution on Filecoin using zk-SNARKs via Lurk: a basic demonstration of Glow working via Lurk on top of the FVM—demonstrating feasibility and illustrating utility of private smart contracts on Filecoin.

Goals

The deliverables in this first step of Glow development on Filecoin, will be as follow:

We believe all of that is feasible in 4 to 6 months depending on whether everything goes smoothly or there are yet unforeseen hurdles along the way.

Non-Goals

We explicitly will not include any of the following developments as part of this proposal:

We will just add a Lurk compilation backend with an FVM runtime to the existing Glow implementation. Glow on Filecoin may benefit from the usual high-level optimizations and efficient data representation provided by the Glow compiler, as well as from the succintness offered by Lurk. But the Lurk+FVM backend as such may otherwise be “naive” and miss many opportunities for low-level optimizations. If anything, we will optimize the generated code for correctness and clarity rather than for efficiency or lowest fees.

Now, assuming this first grant is considered successful and convincing, the features excluded from this initial development may well be included in future developments funded through future grants.

Development Roadmap

Overview of Deliverables

Here is a short description of each of the successive phases of development that we have planned, and what deliverables or increasing functionality will be built at each stage.

  1. Basic runtime support for Filecoin We will create a runtime library for Glow to support Filecoin, including basic interaction with Filecoin nodes and wallets so as to create contracts and interact with them.
  2. Design a simple language backend strategy for Lurk on Filecoin We will design how to implement Glow on Lurk on Filecoin based on our experience with Lurk and Filecoin and the differences and commonalities between them and other platforms we already support.
  3. Implement a suitable FVM contract for our Glow on Lurk runtime We will write a FVM contract that implements the Glow interaction model, and uses a zk-SNARK for validation of interaction steps.
  4. Extend the Glow-on-Lurk runtime with Filecoin support Implement an extension to our Glow-on-Lurk runtime such that it can work with the above contract on Filecoin.
  5. Ensure that the standard demos work Address any issues to make sure that the standard Glow demo contracts (buy a signature, rock/paper/scissors, asset swap, etc.) will all work on FileCoin on Lurk on the FVM.
  6. Extend the Glow command-line for Filecoin Make it easy for developers to write their own contracts in Glow and deploy them on Lurk to the Filecoin network at the Unix command-line.
  7. Update the Glow documentation for running on Filecoin Extend our documentation to make it easy for developers to learn how to use Glow on Filecoin.

Note on cost estimates

We estimate costs in abstract units of developer-week (or dvwk for short), which represents one week of work by one developer assigned full-time on the project, but which also accounts for technical leadership costs, management costs, administrative costs, consulting costs (for when the main assigned developer needs help from another expert), ancillary costs, amortized software and hardware costs, etc.

To account for the above, we estimate a monetary cost of $5000/dvwk for a short-term grant. This cost can decrease if Filecoin is willing to commit to a larger longer-term development grant and/or to shoulder the risk of cost overrun.

Actual delivery time for any step may be shorter than the estimated number of developer-weeks (if work is somewhat parallelizable between multiple developers, within the limits of Amdahl’s Law), but will likely longer (due to various delays, sickness, vacations, etc.). On the other hand, given sufficient budget, some phases can be executed wholly in parallel with other phases by distinct developers (e.g. phases 6 to 8 vs other phases between 3 and 8).

Phase 1: Basic runtime support for Filecoin

We will experiment with the Filecoin ecosystem, and implement in our metalanguage Gerbil Scheme a library to support Filecoin. The library will include basic interaction with Filecoin nodes and wallets so as to create contracts and interact with them. It will constitute the basis for the Glow runtime on Filecoin. (3 dvwk)

Phase 2: Design a simple language backend strategy for Filecoin

We will design the required changes to our compiler and runtime architecture to make it portable to running on top of the FVM using Lurk. The design will be informed by the differences and commonalities between the various platforms for which we are building support, including Filecoin’s FVM, Filecoin’s Lurk, Ethereum’s EVM, and Cardano’s Plutus. This phase will depend on the findings made while studying the fine details of Filecoin documentation during phase 1. The deliverable will be a markdown document that explains the changes required to our architecture, including a mapping of Glow to a suitable ABI and calling conventions for Lurk on the FVM. (4 dvwk).

Phase 3: Implement a suitable FVM contract for our Glow on Lurk runtime

We will write a smart contract on the FVM that suitably supports the Glow interaction model while using Lurk for the validation of interaction steps. The smart contract will be written in whichever language gets us there faster (e.g. Solidity, or direct FVM assembly). The contract will be optimized for simplicity. While simplicity does help with both performance and safety, a further development pass and an independent audit will be necessary to ensure that performance and safety. This pass and that audit are not included in either this deliverable or this proposal, but would be good deliverables for a future follow-up proposal. We don’t expect this phase to take too long, but some findings of phase 2 might make it somewhat longer. (3 dvwk)

Phase 4: Extend the Glow-on-Lurk runtime with Filecoin support

We will implement an extension to our Glow-on-Lurk runtime, that will enable it to work with the above contract on Filecoin. This phase should follow in a straightforward way from the previous phases, especially considering the fact that we’re optimizing for simplicity rather than for performance. (4 dvwk)

Phase 5: Ensure that the standard demos work

We will address any issues to make sure that the standard Glow demo contracts (buy a signature, rock/paper/scissors, asset swap, etc.) will all work on FileCoin using Lurk on the FVM. This phase includes a lot of debugging which introduces a lot of uncertainty and typically takes longer than expected. (4 dvwk)

Phase 6: Extend the Glow command-line

We will polish our code so far and ensure that it is easy for developers to write their own contracts in Glow and deploy them to the Filecoin network at the Unix command-line with Lurk as a backend. This phase completes the code produced in the previous phases, to cross the t’s and dot the i’s. (2 dvwk)

Phase 7: Update the Glow documentation

We will extend our documentation to make it easy for developers to learn how to use Glow on Filecoin. This phase crowns the project with documentation to make the above code usable by third parties. We will include a short video demonstration together with the documentation. (2 dvwk)

Total Budget Requested

We propose that to start with, Filecoin would fund the seven phases of this project, with a total number of 22 dev-weeks over an estimated 6 month period, for a $110,000 budget. Since these are estimates, we propose that 6 months should not be a hard deadline, but that up to 2x the initial estimates be allowed on time, though the price paid would be the same. Filecoin would receive a weekly update, and pay each phase in advance on schedule, with the ability to stop at any point with a one week heads up.

We propose that upon mid-project review (3 months) as well as at the end of the project, we would then convene to determine whether Filecoin is interested in funding further development of Glow, or in helping find investors who would.

Team

Contact Info

fare@mukn.io

Team Members

Team Member LinkedIn Profiles

Team Website

The Mutual Knowledge Systems website: https://mukn.com

The Glow language website: https://glow-lang.org

The Glow whitepaper: https://bit.ly/GlowWhitepaper2020

Relevant Experience

Relevant previous work by our contributors are listed in the Wiki for our Glow language:

https://github.com/Glow-lang/glow/wiki/Bibliography-Glow

Team code repositories

Our Glow compiler and runtime: https://github.com/Glow-Lang/glow

The Glow on Lurk prototype: https://github.com/MuKnSys/glow-on-lurk

More repositories of code we built at https://github.com/MuKnSys

Additional Information

MuKn is already a partner of Filecoin, as a contributor to the Lurk project: we have implemented a prototype backend of our smart contract language Glow on top of Lurk, and have been working on the formalization of Lurk, for which we have submitted another proposal.

See also our proposal Glow on FVM — safer smart contracts for Filecoin and beyond #1567 to port Glow to work directly on the FVM, rather than through Lurk.

ErinOCon commented 1 year ago

Hi @fare, thank you for your proposal! We will not be moving forward with the consideration of this proposal at this time, but would be happy to proceed with the review once Wasm actors are on mainnet.

Wishing you all the best as you continue building!