<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>ChorChain: A Model-Driven Framework for Choreography-Based Systems Using Blockchain⋆</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Flavio Corradini</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Alessandro Marcelletti</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Andrea Morichetta</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Andrea Polini</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Barbara Re</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Francesco Tiezzi</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>University of Camerino</institution>
          ,
          <addr-line>Camerino 62032, IT</addr-line>
        </aff>
      </contrib-group>
      <abstract>
        <p>The complexity in the development of distributed systems has increased the necessity to consider new model-driven methodologies for their implementation. This complexity is higher when combined with the lack of a trusted execution environment necessary to guarantee the correct behaviour of all the involved participants. In such context, the BPMN standard, in particular the choreography diagram, is one of the advocated modelling languages able to represent the interactions that should occur among distributed components. This modelling language, combined with the immutable and trusted nature of the blockchain technology, provides a promising solution to master complexity in developing and executing trusted distributed systems. This paper describes a model-driven methodology based on blockchain technology and the related framework named ChorChain. Starting from a BPMN choreography model, ChorChain generates the corresponding smart contract and the respective infrastructure for the choreography execution. To show the ChorChain feasibility, we have been tested it on a Room Booking scenario.</p>
      </abstract>
      <kwd-group>
        <kwd>Distributed systems • BPMN • Choreography • Blockchain</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>-</title>
      <p>
        In the last years, model-driven engineering methodologies are used to master the
complexity of coordination in distributed systems involving multi-party
organisations. These methodologies allow the passage from abstract modelling languages,
describing the interaction logic, to code executable on a targeted run-time
environment. In such a direction, the BPMN standard 1 nowadays has become a
prominent modelling language to describe collaborative systems in distributed
environments [
        <xref ref-type="bibr" rid="ref10 ref4 ref5">4, 5, 10</xref>
        ]. In this paper, we rely on choreography diagrams, which
permit us to describe system interactions in terms of the exchange of messages
from a global perspective, without exposing the internal behaviour of each
component.
⋆ Copyright ' 2021 for this paper by its authors. Use permitted under Creative
      </p>
      <p>Commons License Attribution 4.0 International (CC BY 4.0).
1 https://www.omg.org/spec/BPMN/2.0/PDF</p>
      <p>
        In addition to coordination complexity, distributed systems may lack of trust
among the involved parties. This trustelessness issue [
        <xref ref-type="bibr" rid="ref9">9</xref>
        ] can be mitigated by the
inclusion of blockchain technology, as envisioned in [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ]. The blockchain, indeed,
guarantees the integrity and the immutability of data, without relying on a
central authority or any particular participant [
        <xref ref-type="bibr" rid="ref1 ref7 ref8">1, 7, 8</xref>
        ]. This allows choreography
participants to have a clear view of the ongoing system execution and tangible
proofs of the actions performed by the counterparts [
        <xref ref-type="bibr" rid="ref2 ref3">3, 2</xref>
        ].
      </p>
      <p>
        In this paper, we focus on the use of the model-driven methodology and
the ChorChain framework, introduced in [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ], for the development of trustable
choreography-based systems. In doing this, we focus on a case study related to
a room booking system. The proposed approach supports the full life-cycle of
choreographies, from their modelling to their publishing and instantiation, until
their deployment and execution in the Ethereum blockchain. In particular, the
deployment phase is supported by ChorChain thanks to the automatic
generation of Solidity smart contracts. These contracts indeed are specifically generated
to implement the choreography workflow, thus forcing the correct behaviour of
each participant.
      </p>
      <p>The rest of the paper is organised as follow. Section 2 describes the
proposed methodology, while Section 3 shows the ChorChain framework in practice
applied to a case study. Finally, Section 4 concludes the paper.
2</p>
    </sec>
    <sec id="sec-2">
      <title>ChorChain Methodology</title>
      <p>In this section, we describe the methodological aspects of the proposed approach
that is divided into three main phases in Fig. 1 (i) system modelling, (ii)
instantiation and (iii) execution.</p>
      <p>Interact
Role A</p>
      <p>Role B</p>
      <p>Execution
Subscribe</p>
      <p>InstanceID:1</p>
      <p>Smart Contract
Contract
Generation</p>
      <p>Deploy</p>
      <p>Existing Instances
InstanceID:2
InstanceID:3</p>
      <p>New Instance
Instantiation</p>
      <p>RoleA
RoleB
RoleA
RoleB
RoleA
RoleB
Modeling Environment</p>
      <p>Publish</p>
      <p>Search
Choreographies
Repository
Modelling</p>
      <p>Chopreography</p>
      <p>Model</p>
      <p>Create
New</p>
      <p>Instance</p>
      <p>The first phase consists of the modelling of a distributed system by means
of a choreography specification. This permits focusing on the interactions,
abstracting from low-level implementation details and reducing the development
efort. The created model is published in a choreography repository making it
publicly available as a blueprint.</p>
      <p>A model can be used to generate multiple instances with the same structure
but with diferent participants. When a choreography instance is created, in
order to be executed it has to be subscribed by the participants that are willing
to play a specific role.</p>
      <p>Once all the required roles are filled, the corresponding smart contract is
generated and then deployed, automatically, on the blockchain. At this point,
the execution starts, and the participants can cooperate following the message
protocol established by the choreography specification, and implemented in the
smart contract.
3</p>
      <p>ChorChain on Room Booking Case Study
In this section, we show how the proposed methodology was concretely applied
on a realistic example. For this purpose, we demonstrate the ChorChain
functionalities, with the Room Booking case study. The interested reader can visit
http://pros.unicam.it/chorchain/ for more details about the tool and its usage.
The model shown in Fig. 2 describes the interactions between a Client and a</p>
      <p>Hotel for the booking of a room. In particular, the process starts with the request
of availability for a room on a specific date and a given number of guests. In
absence of a free room, the client iterates making new requests. In the positive
case, instead, the hotel replies with the room number and its quotation. This
open two possible subsequent actions for the client: (i) the rejection of the order
that makes the process ends or (ii) the payment activity of the booked room.
After the payment, the hotel provides in parallel the booking ID and the receipt
ID.</p>
      <p>Here below we show the steps that the parties need to accomplish to
collaborate on such a scenario using the ChorChain framework. The first required step
is the authentication. The parties need to sign-up in the system by registering
their Ethereum accounts. This is necessary to associate all the operations
performed in the blockchain with a participant. Once this step is completed, the
sign-in can be done through the Metamask plugin that facilitates the user in
managing the Ethereum account.</p>
      <p>Then, the participant can start the denfiition of the room booking model
through the integrated modelling environment exploiting the choreography
elements. Additional information related to (i) messages and (ii) guards is also
necessary. These annotations are facilitated by a dedicated interface accessible
for each choreography task. Fig. 3 shows the ChorChain interface for the
definition of the messages and parameters in the Availability check task. The result
of this procedure is a list of parameters included between brackets after the
message name; e.g. check room(string date, uint people) defines the first message
sent by the client. This format is necessary for performing the underlying
function call in the generated smart contract. Similarly, the guards annotation in the
outgoing sequence flows of exclusive gateways is used to enforce the control flow
of the smart contract. This will be translated later as conditions automatically
verified in the contract, guaranteeing a proper execution of the choreography
model when deployed in the blockchain.</p>
      <p>Once the Room Booking model is completed, it is saved in the ChorChain
repository, and it is shown in the model file list on the home page (Fig. 4)
accessible by every logged-in user.</p>
      <p>Selecting the RoomBooking.bpmn file, ChorChain shows the owner of the
model, the maximum number of involved participants and the required roles.
Furthermore, the graphical preview and the instantiation functionalities are
accessible by clicking on the related buttons (Create instance and See model
preview ). In the specific case of Fig. 4, the Room Booking instance contains the
address of the creator, and the two roles defined in the model: the Hotel and
the Client. The created instance will remain in a “suspended” state until all the
mandatory roles are subscribed. To fill these roles, participants that are
interested to participate as client or hotel can subscribe and associate their Ethereum
accounts to the role. When all roles are fulfilled and no more vacant roles exist,
ChorChain considers the partnership complete and starts the generation and
deployment of the Solidity smart contract.</p>
      <p>The code generation is completely automatic and transparent to the involved
participants that have no knowledge about low-level implementation details.
In the generated smart contract, messages are represented by public functions
that can be invoked only by a specific participant. For gateways, instead, the
related functions are automatically triggered internally by the smart contract.
The interested reader can refer to http://pros.unicam.it/RoomBooking.sol for
more details about the generated Room Booking smart contract.</p>
      <p>Once the smart contract of the Room Booking scenario is deployed, it is
accessible by the parties in the ChorChain execution page (Fig. 5). Here both the
hotel and the client can interact with each other following the deployed
choreography specification. In particular, the left-hand side of the interface reports a list
of all the deployed contracts, to which the participant is subscribed. In the centre,
it is shown a preview of the model with its current execution state highlighted
by green messages. For the active messages, a form is dynamically constructed
below the model, to insert the parameters and executing it (give availability ).
Notably, the submission form is shown only to the participant subscribed and in
charge to play that role. The counterpart (client in the give availability message)
has only knowledge of the active message, without the possibility of submitting
it. For each message submission, ChorChain produces a blockchain transaction
that has to be confirmed through the Metamask pop-up. As soon as the
transaction is stored in the blockchain, an event is emitted and is used for notifying
all the other participants about the advancement of the system status until an
end event is reached. To log the current value of variables, on the bottom-right
side of Fig. 5 a panel is shown. In particular it contains the check room message
with its two parameters (date and people) with the respective values retrieved
from the blockchain.</p>
      <p>Considering costs for executing the Room Booking scenario we have 4,510,860
units of gas used for the deployment of the contract and 817,389 for its execution.
On average each transaction uses around 116,769 units of gas. The execution time
instead is strictly related to the technology used and we registered on average
15 seconds for the inclusion of each transaction in the Rinkeby network.
4</p>
    </sec>
    <sec id="sec-3">
      <title>Conclusions</title>
      <p>
        In this work, we faced the problem of the trustworthy implementation of
distributed systems through the use of multi-party choreographies. The concrete
realisations of such systems sufer from the lack of a concrete implementation
that guarantees also trust to the participants. To address such a challenge we
proposed in [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ] a novel model-driven methodology for managing the whole
choreography life-cycle, relying on a blockchain infrastructure. The methodology is
concretely supported by the ChorChain framework, which implements all the
functionalities from the diagram specification to its execution on the blockchain.
We demonstrate here the feasibility of the solution and its efectiveness by
applying the ChorChain approach to a Room Booking case study.
      </p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <surname>Almeida</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Albuquerque</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Silva</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          :
          <article-title>An approach to develop software that uses blockchain</article-title>
          . In: Computer Science Conference. pp.
          <fpage>346</fpage>
          -
          <lpage>355</lpage>
          . Springer (
          <year>2018</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <surname>Corradini</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Marcelletti</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Morichetta</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Polini</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Re</surname>
            ,
            <given-names>B.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Scala</surname>
            ,
            <given-names>E.</given-names>
          </string-name>
          , et al.:
          <article-title>Model-driven engineering for multi-party business processes on multiple blockchains</article-title>
          .
          <source>Blockchain: Research</source>
          and Applications p.
          <volume>100018</volume>
          (
          <year>2021</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <surname>Corradini</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Marcelletti</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Morichetta</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Polini</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Re</surname>
            ,
            <given-names>B.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Tiezzi</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          :
          <article-title>Engineering trustable choreography-based systems using blockchain</article-title>
          .
          <source>In: 35th Annual ACM SAC</source>
          . pp.
          <fpage>1470</fpage>
          -
          <lpage>1479</lpage>
          (
          <year>2020</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <given-names>Di</given-names>
            <surname>Ciccio</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            ,
            <surname>Cecconi</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            ,
            <surname>Dumas</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            ,
            <surname>Garıac</surname>
          </string-name>
          ´ -Ban˜uelos, L.,
          <article-title>Lop´ez-</article-title>
          <string-name>
            <surname>Pintado</surname>
            ,
            <given-names>O.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Lu</surname>
            ,
            <given-names>Q.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Mendling</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Ponomarev</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Tran</surname>
            ,
            <given-names>A.B.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Weber</surname>
            ,
            <given-names>I.</given-names>
          </string-name>
          :
          <article-title>Blockchain support for collaborative business processes</article-title>
          .
          <source>Informatik Spektrum</source>
          <volume>42</volume>
          (
          <issue>3</issue>
          ),
          <fpage>182</fpage>
          -
          <lpage>190</lpage>
          (
          <year>2019</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <surname>Lop</surname>
          </string-name>
          <article-title>´ez-</article-title>
          <string-name>
            <surname>Pintado</surname>
            ,
            <given-names>O.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Garıac</surname>
          </string-name>
          ´ -Ban˜uelos, L.,
          <string-name>
            <surname>Dumas</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Weber</surname>
            ,
            <given-names>I.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Ponomarev</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          :
          <article-title>Caterpillar: a business process execution engine on the ethereum blockchain</article-title>
          .
          <source>Software: Practice and Experience</source>
          <volume>49</volume>
          (
          <issue>7</issue>
          ),
          <fpage>1162</fpage>
          -
          <lpage>1193</lpage>
          (
          <year>2019</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6.
          <string-name>
            <surname>Mendling</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Weber</surname>
            ,
            <given-names>I.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Aalst</surname>
            ,
            <given-names>W.V.D.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Brocke</surname>
            ,
            <given-names>J.V.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Cabanillas</surname>
            ,
            <given-names>C.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Daniel</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Debois</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Ciccio</surname>
            ,
            <given-names>C.D.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Dumas</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Dustdar</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          , et al.:
          <article-title>Blockchains for business process management-challenges and opportunities</article-title>
          .
          <source>TMIS</source>
          <volume>9</volume>
          (
          <issue>1</issue>
          ),
          <fpage>1</fpage>
          -
          <lpage>16</lpage>
          (
          <year>2018</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7.
          <string-name>
            <surname>Porru</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Pinna</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Marchesi</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Tonelli</surname>
          </string-name>
          , R.:
          <article-title>Blockchain-oriented software engineering: challenges and new directions</article-title>
          . In: ICSE-C. pp.
          <fpage>169</fpage>
          -
          <lpage>171</lpage>
          . IEEE (
          <year>2017</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          8.
          <string-name>
            <surname>Rocha</surname>
            ,
            <given-names>H.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Ducasse</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          :
          <article-title>Preliminary steps towards modeling blockchain oriented software</article-title>
          .
          <source>In: WETSEB</source>
          . pp.
          <fpage>52</fpage>
          -
          <lpage>57</lpage>
          . IEEE (
          <year>2018</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          9.
          <string-name>
            <surname>Tai</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          : Continuous, trustless, and
          <article-title>fair: Changing priorities in services computing</article-title>
          .
          <source>In: Conf. on Service-Oriented and Cloud Computing</source>
          . pp.
          <fpage>205</fpage>
          -
          <lpage>210</lpage>
          . Springer (
          <year>2016</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          10.
          <string-name>
            <surname>Tran</surname>
            ,
            <given-names>A.B.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Lu</surname>
            ,
            <given-names>Q.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Weber</surname>
            ,
            <given-names>I.</given-names>
          </string-name>
          :
          <article-title>Lorikeet: A model-driven engineering tool for blockchain-based business process execution and asset management</article-title>
          .
          <source>In: BPM</source>
          . pp.
          <fpage>56</fpage>
          -
          <lpage>60</lpage>
          (
          <year>2018</year>
          )
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>