Catalyst milestone 4: Separate PlutusTx backend and improvements to existing LambdaBuffers facilities

Outputs

  • A separate code generator for Haskell and PlutusTx

    • A separate LambdaBuffers code generation module that outputs type definitions and derived implementations for Haskell's Prelude and PlutusTx's Prelude (or equivalent LambdaBuffers' Preludes) given a LambdaBuffers schema.

      • The common files for code generation of both Haskell's Prelude and PlutusTx's Prelude can be found here

      • The Haskell code generator implementation can be found here

      • The PlutusTx code generator implementation can be found here

    • A Haskell test suite that assures the manually implemented and automatically generated implementations are consistent with the predefined LambdaBuffers Prelude golden data set of JSON files and perform correct implementation derivation.

      • The Haskell test suite can be found here
  • Nix devops modules (Nix API) for streamlining the LambdaBuffers code generation pipeline to either Haskell's Prelude or PlutusTx's Prelude.

    • A Nix API for streamlining LambdaBuffers code generation Haskell's Prelude can be found here

    • The Nix API for streamlining LambdaBuffers code generation PlutusTx's Prelude can be found here or PlutusTx's Prelude can be found

  • Documentation on LambdaBuffers usage patterns for Haskell's Prelude and PlutusTx's Prelude

    • Documentation for Haskell's Prelude can be found here.

    • Documentation for PlutusTx's Prelude can be found here.

  • A complete Plutus .lbf schema file to include all Plutus Ledger API types with backend support for Rust, TypeScript, and PureScript.

    • The .lbf schema file for V1 Plutus Ledger API can be found here

    • The .lbf schema file for V2 Plutus Ledger API can be found here

    • Rust backend support is given by the JSON file here where the types are provided by this package.

    • TypeScript backend support is given by the JSON file here where the types are provided by this package

    • PureScript backend support is given by the JSON file here where the types are provided by this package

  • An extended integration test suite to verify that the manually implemented and automatically implemented instances of the updated LambdaBuffers' Plutus .lbf schema file are consistent across all backends.

    • The extended integration test suite to verify that the manually implemented and automatically implemented instances of the updated LambdaBuffers' PlutusTx .lbf schema file are consistent across all backends can be found here.
  • A versioning scheme for the LambdaBuffers git repository using git tags that follow semantic versioning.

    • A versioning scheme for the git repository using git tags that follows semantic versioning is given in the Releases page

    • Documentation for how the versioning scheme interplays with the monorepo setup is described in the CONTRIBUTING.md

  • Optimized Nix build times.

    • This was fixed in #233. It's well known that (in the version of Nix used with LambdaBuffers) large flake.lock files are a detriment to performance. So prior of #233, in e.g. 9ae3705f3f1a5c2506c7f86c8d5643c38d79e849, we see that

      $ git checkout 9ae3705f3f1a5c2506c7f86c8d5643c38d79e849
      $ time nix flake lock
      
      real    0m27.437s
      user    0m27.331s
      sys     0m0.116s
      
      $ wc -l flake.lock
      44552 flake.lock
      

      it takes almost 28 seconds to execute the nix flake lock command due to the almost 45000 lines large flake.lock file.

      After the merge of #233, in e.g. 401f8a920a557c71440795174da199a1e128c4f9, we see significantly improved Nix performance

      $ git checkout 401f8a920a557c71440795174da199a1e128c4f9
      $ time nix flake lock
      
      real    0m1.423s
      user    0m1.348s
      sys     0m0.067s
      
      $ wc -l flake.lock
      11585 flake.lock
      

      where it now takes only about 1.5 seconds to execute the nix flake lock command due to the significantly reduced flake.lock file size of being just under 12000 lines.

  • Error messages that follow the GNU error message format.

    • This was implemented in PR #147 and PR #249. See below for examples of following the GNU error message format.

Acceptance Criteria

  • An executable and Nix tooling to translate LambdaBuffers modules to Haskell projects to specify application types.

    • An executable to translate LambdaBuffers modules to Haskell projects is given in the Nix attribute lbf-prelude-to-haskell defined here

    • Convenient Nix tooling to translate LambdaBuffers modules to Haskell projects is given in the Nix function lbfPreludeHaskell defined here here

  • An executable and Nix tooling to translate LambdaBuffers modules to PlutusTx projects to specify application types.

    • An executable to translate LambdaBuffers modules to PlutusTx projects is given in the Nix attribute lbf-plutus-to-plutustx defined here

    • Convenient Nix tooling to translate LambdaBuffers modules to PlutusTx projects is given in the Nix function lbfPlutusTx defined here here

  • An updated LambdaBuffers Plutus schema for the complete Plutus Ledger API types.

    • The updated LambdaBuffers Plutus schema for the complete Plutus Ledger API types can be found here
  • The documentation and devops tooling is available to facilitate easy adoption.

    • The entire project's documentation can be found in the documentation website here

    • Devops tooling can be found in the form of Nix functions for conveniently creating Haskell or PlutusTx projects found here.

  • Git tags for official releases of LambdaBuffers.

    • The releases page contains git tags for official releases of LambdaBuffers.

Evidence of Milestone Completion

  • The completed and reviewed LambdaBuffers code generator for Haskell's Prelude.

    • The completed common files for code generation of both Haskell's Prelude and PlutusTx's Prelude can be found here

    • The Haskell code generator implementation can be found here

  • The completed and reviewed LambdaBuffers code generator for PlutusTx's Prelude.

    • The completed common files for code generation of both Haskell's Prelude and PlutusTx's Prelude can be found here

    • The PlutusTx code generator implementation can be found here

  • Benchmarks of the before and after optimized Nix build times.

    • This was fixed in #233, see above for benchmarks.
  • Demonstrations (in the form of screenshots or simply text) of error messages following the GNU error message format.

    • We can see the following error messages follow the GNU error message format
    $ lbf-prelude-to-haskell DoesNotExist.lbf
    DoesNotExist.lbf: error: the provided module file DoesNotExist.lbf doesn't exist
    
    $ cat TEST.lbf
    module TEST
    
    import Prelude (Eq, Json, Maybe, Either, List, Integer)
    
    derive Eq What
    
    $ lbf-prelude-to-haskell TEST.lbf
    TEST.lbf:5.11-5.15: error: [module TEST] type What not found in the module's scope Either Integer List Maybe Prelude.Either Prelude.Integer Prelude.List Prelude.Maybe
    
    $ cat ANOTHERTEST.lbf
    module ANOTHERTEST
    
    import Prelude (Eq, Json, Maybe, Either, List, Integer)
    
    prod What = (Integer
    derive Eq What
    
    $ lbf-prelude-to-haskell ANOTHERTEST.lbf
    ANOTHERTEST.lbf:6.7: error:
    unexpected keyword
    expecting s-expression
    

References