npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

chorpiler

v0.12.0

Published

[![Node.js CI](https://github.com/fstiehle/chorpiler/actions/workflows/node.js.yml/badge.svg)](https://github.com/fstiehle/chorpiler/actions/workflows/node.js.yml) - A compiler to transform BPMN 2.0 choreographies to efficient smart contract components, b

Downloads

9

Readme

Chorpiler

Node.js CI

  • A compiler to transform BPMN 2.0 choreographies to efficient smart contract components, based on petri-net reductions.
  • Current targets supported: Solidity Smart Contracts

Overview

| Element | Supported | |--------------------|------------| | Choreography tasks | ✔ | | Events | Start, End | | Gateways | XOR, AND | | Looping behaviour | ✔ |

Usage

Install and use through npm.

npm install chorpiler

Chorpiler offers two types of output that implement the process model: (i) a smart contract that can be used directly to execute the process, and performs conformance checks on each task. (ii) a state channel smart contract (see an example usage of channels in fstiehle/leafhopper).

See below example.

import chorpiler from 'chorpiler';

const parser = new chorpiler.Parser();

// to generate a smart contract implementing the process
const contractGenerator = new chorpiler
  .generators.sol.DefaultContractGenerator();

// (advanced) to generate a state channel  contract
const stateChannelGenerator = new chorpiler
  .generators.sol.StateChannelContractGenerator();

Complete example usage to parse and generate.

import * as fs from 'fs';
import chorpiler, { ProcessEncoding } from 'chorpiler';

const parser = new chorpiler.Parser();

const contractGenerator = new chorpiler
  .generators.sol.DefaultContractGenerator();

const bpmnXML = fs.readFileSync("yourBPMNXML.bpmn");   
// parse BPMN file into petri net
const iNet = await parser.fromXML(bpmnXML);

// compile to smart contract
contractGenerator.compile(iNet)
.then((gen) => {
  fs.writeFileSync(
    "Process.sol", 
    gen.target, 
    { flag: 'w+' }
  );
  console.log("Process.sol generated.");
  // log encoding of participants and tasks, 
  // can also be written to a .json file
  console.log(ProcessEncoding.toJSON(gen.encoding));
})
.catch(err => console.error(err));

For usage see also the tests defined in tests/compiler. For usage of the resulting smart contracts also see tests/output.

Run & Tests

If you have node installed, a simple npm install is enough. To confirm, you can execute tests using npm run test.

Two groups of tests exist:

  • Testing the parser and compiler: By running npm run test/compiler, tests are executed confirming that the parser and compiler produce outputs from a range of correct and supported process models without reporting errors and rejects malformed and unsupported BPMN elements with reporting errors. These tests are found in tests/compiler.
  • Testing the generated output: By running npm run test/output, tests are executed confirming that the produced outputs are valid artefacts, by replaying conforming logs (which must lead to a valid execution) and non-conforming logs (which must be rejected). Gas cost are also reported for the conforming logs. These tests are found in tests/output.

npm run test runs both test groups.

Architecture

[!NOTE] More on this soon.

Theory

Petri net generation

Our approach is based on the optimised translation technique presented in Garćıa-Bañuelos et al. [1]: a process model is converted into a Petri net, and this net is reduced according to well-established equivalence rules. In the smart contract, the process state is then encoded as a bit array. Our approach is based on interaction Petri nets, which are a special kind of labelled Petri nets. Interaction Petri nets have been proposed as the formal basis for BPMN choreographies [2]. As labels, they store the initiator and respondent information, which are essential for the channel construction. After conversion, we apply the same reduction rules as in [1].

In contrast to [1], we must restrict enforcement to certain roles: only initiators are allowed to enforce tasks.3 Thus, in our approach, we can differentiate between manual and autonomous transitions. Manual transitions correspond to tasks that are initiated by a participant; these must be explicitly executed. Autonomous transitions are the remaining silent transitions. Converting a process model into a Petri net creates silent transitions. While most of them can be deleted through reduction, some can not be removed without creating infinite-loops [1]. These transitions must then be performed by the blockchain autonomously, given that the correct conditions are met. Consequently, these transitions are not bound to a role. The differentiation allows a more efficient execution: if the conditions for a manual task are met, it is fired and terminated; further autonomous transitions may be fired, without requiring further manual transitions.

Petri net generation

[1]: Garćıa-Bañuelos, L., Ponomarev, A., Dumas, M., Weber, I.: Optimized Execution of Business Processes on Blockchain. In: BPM. Springer, Cham (2017) 130–146

[2]: Decker, G., Weske, M.: Local enforceability in interaction Petri nets. In: BPM. Volume 4714 of LNCS., Springer, Cham (2007) 305–319