filecoin-project / devgrants

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

Glow on FVM — safer smart contracts for Filecoin and beyond #1567

Closed fare closed 1 year ago

fare commented 1 year ago

Open Grant Proposal: Glow on FVM — safer smart contracts for Filecoin and beyond

Project Description

We propose to port our language Glow to the Filecoin ecosystem.

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.

Glow is designed for portability and in the future will work identically on the FVM and on Lurk on Filecoin, as well as on the respective virtual machines of Ethereum, Cardano, Solana, PolkaDot, Cosmos, Algorand, Nervos, Tezos, or any blockchain with smart contracts.

In the past, we already demonstrated working prototypes of Glow targeting (a) Ethereum’s EVM, (b) Cardano’s Plutus and (b) Filecoin’s Lurk. We propose to build a prototype of Glow targeting Filecoin’s FVM instead. Our prototype will include an end-to-end example of a simple DApp interaction using Glow from the Unix command-line. Furthermore, we will implement for Filecoin a Glow feature that we haven’t implemented on other blockchains yet.

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, Filecoin will be experience the following benefits:

As part of this grant proposal, we will do a basic port of Glow to the FVM, 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 the first step of Glow development on Filecoin: a basic demonstration of Glow working on the FVM—demonstrating feasibility and illustrating utility of porting Glow to 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 3 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 an FVM compilation and runtime backend 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, but the FVM backend as such may 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 low 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 Filecoin We will design how to implement Glow on Filecoin based on the differences and commonalities between Filecoin and other platforms we already support.
  3. Extend the Glow language model and the compiler internal representations We will enhance Glow and its internals with any necessary capabilities to support Filecoin that were not necessary so far on other platforms.
  4. Extend the ****Glow** compiler with a Filecoin backend** Implement a compiler backend and accompanying runtime bits according to the plan above.
  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 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 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. (2 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 the FVM. The design will be informed by the differences and commonalities between Filecoin and other platforms we already support, namely Ethereum’s EVM, Cardano’s Plutus and Filecoin’s Lurk. 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 the FVM. (3 dvwk).

Phase 3: Extend the Glow language model and compiler internals

We will extend the way that Glow represents code and data internally to suitably support Filecoin, where new capabilities are required that were not needed to support previous platforms. We will actually implement during this phase 3 the necessary changes identified in the previous phase 2. We don’t expect this phase to take too long, but it might very well be that we will be surprised by the findings of phase 2 and that this phase will take longer to much longer. There lies a lot of uncertainty. (2 dvwk)

Phase 4: Extend the Glow compiler with a Filecoin backend

We will implement a compiler backend and the accompanying runtime bits according to the plan above. This phase should follow in a straightforward way from the previous phases, especially considering the fact that we’re aiming at a so-called “naive” implementation rather than an “optimized” implementation as far as code generation is concerned. (3 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 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. 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 18 dev-weeks over an estimated 5 month period. Since these are estimates, we propose that 5 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.

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!