Research on Smart Contract Verification and Generation Method Based on BPMN
Abstract
:1. Introduction
- To verify the correctness of the BPMN and its alignment with business requirements, we propose a set of transformation rules from the BPMN to Prolog. The Swish [13] supports Prolog-based validation, which enables the detection of errors in both syntax and the business description within the BPMN models.
- To generate a Go smart contract, we propose a set of transformation rules from the BPMN to Go programming language.
- We propose a new development process model that encompasses the design of visual requirements, their verification, and the subsequent generation of smart contract code. Demonstrated through a typical bank loan assessment case and experiments, this development paradigm alleviates the communication challenges between requirement specifiers and smart contract developers, providing a valuable enhancement to the existing paradigms in software engineering.
2. Related Works
3. Smart Contract Modeling, Validation, and Generation
3.1. Method Overview
3.2. Rules Based on Sequent Calculus
3.3. Definition of Transformation Operators
- 1.
- Definition 1 (transformation operator φ)
- 2.
- Definition 2 (transformation operator ψ)
- 3.
- Characteristic 1 (semantic consistency in language transformation)
3.4. Smart Contract Modeling Based on BPMN
3.5. Transformation and Validation of BPMN to Prolog
Algorithm 1: BPMN to Prolog Statements Transformation | |
Input: BPMN file bfile (.xml) | |
Output: Prolog statement description file plfile(. pl) | |
1 | Traverse all notations in bfile until the end; |
2 | switch (type of the notation) |
3 case startEvent: startX→elist; startNode(StartEventName).→plfile ; | |
4 if (flowOutY ∉elist && nodeZ ∉elist) then <flowOutY,nodeZ >→flist; | |
5 else <flowOutY,nodeZ > ← flist; connectionLink(flowOutY, startX, nodeZ).→plfile; | |
6 case exclusiveGateway: exGateX→elist; | |
7 gateway(GatewayName).→plfile; gatewayName(GatewayName,GatewayId).→plfile; | |
8 if (flowInY ∉elist || flowOutZ ∉elist) then | |
9 | <flowInY, exGateX>→flist; <flowOutZ, exGateX >→flist; |
10 else <flowX, nodeN> ← flist; | |
11 | if (flowX==flowInY || flowX==flowOutZ) then |
12 | connectionLink(flowInY, nodeN,exGateX).||connectionLink(flowOutZ, exGateX, nodeN).→plfile; |
13 case task: taskN→elist ; task(TaskName).→plfile; taskName(TaskName,TaskId).→plfile; | |
14 if (flowInY∉elist && flowOutZ ∉elist) then | |
15 flowInY&& flowOutZ→elist; < flowInY, taskN> && <flowOutZ, taskN>→flist; 16 else <flowX, taskN> ← flist; | |
17 if (flowX== flowInY || flowX== flowOutZ) then | |
18 | connectionLink(flowInY, taskN, nodeN). or connectionLink(flowOutZ, nodeN, taskN).→plfile; |
19 case sequence flow: if (flowX ∉elist) then flowX→elist; | |
20 | if (sourceRefX ∉elist && targetRefX ∉elist) then |
21 | <flowX, sourceRef> ← flist; <flowX, targetRef> ← flist; |
22 | connectionLink(flowX, sourceRefX, targetRefX).→plfile; |
23 | else if (sourceRefX ∉elist || targetRefX ∉elist ) then |
24 | sourceRefX|| targetRefX→elist; <flowX, sourceRefX> || < flowX, targetRefX>→flist; |
25 case endEvent: endN→elist; endNode(EndEventName).→plfile; | |
26 | if (flowInY ∉elist) then |
27 flowInY→elist ; <flowInY, endN>→flist; | |
28 | else <flowInY, nodeX> ← flist; connectionLink(flowInY, nodeX, endN).→plfile; |
29 | |
30 end switch | |
31 Output: plfile |
Algorithm 2: BPMN Verification |
Input: BPMN file (.xml) |
Output: Correctness |
1 IsAnyEndnodePairNotConnected( ) |
2 IsAnyStartnodePairNotConnected( ) |
3 IsAnyStartEndNodePairNotConnected(Startnode,Endnode) |
4 IsStartnodeConntected(Startnodes) |
5 IsEndnodeConntected(Endnodes) |
6 IsAllGatewaynodesConnected(Gatewaynodes) |
7 IsGatewayandTaskNodesConnected(Tasknode1,Tasknode2,Gatewaynode) |
8 IsAnyTasknodePairNotConnected(Tasknodes) |
3.6. BPMN Transformation and Smart Contract Generation
3.7. Soundness and Completeness
3.7.1. Soundness
3.7.2. Completeness
4. Experimental Analysis
4.1. Application Cases
4.2. Experimental Analysis
4.2.1. Analysis of Model Transition Time from BPMN to Prolog
4.2.2. Transition Time Analysis of BPMN to Go Language Smart Contract
4.2.3. Analysis of Transformation Time before and after Code Reuse
5. Conclusions
Author Contributions
Funding
Data Availability Statement
Conflicts of Interest
References
- Graphical Smart Contract Generation Editor. Available online: http://www.lianmenhu.com/blockchain-4658-1 (accessed on 16 December 2023).
- Li, Y.S.; Li, Y.; Jin, X. Visual Blockchain Smart Contract Framework and Deployment Methods for Smart Contract Development. CN112148278A, 29 December 2020. [Google Scholar]
- López-Pintado, O.; García-Bañuelos, L.; Dumas, M.; Weber, I. Caterpillar: A Blockchain-Based Business Process Management System. Bus. Process Manag. 2017, 172, 1–5. [Google Scholar]
- Tran, A.B.; Lu, Q.; Weber, I. Lorikeet: A Model-Driven Engineering Tool for Blockchain-Based Business Process Execution and Asset Management. In Proceedings of the International Conference on Business Process Management, Sydney, NSW, Australia, 9–14 September 2018. [Google Scholar]
- Gajski, D.D.; Abdi, S.; Gerstlauer, A.; Schirner, G. Embedded System Design: Modeling, Synthesis and Verification; Springer: New York, NY, USA, 2009; pp. 49–111. [Google Scholar]
- Baier, C.; Katoen, J.P. Principles of Model Checking; MIT press: Cambridge, MA, USA, 2008; pp. 25–40. [Google Scholar]
- Cosenz, F.; Rodrigues, V.P.; Rosati, F. Dynamic Business Modeling for Sustainability: Exploring a System Dynamics Perspective to Develop Sustainable Business Models. Bus. Strateg. Environ. 2020, 29, 651–664. [Google Scholar] [CrossRef]
- Yu, W.S. Research on task-oriented business process modeling and verification method. Master's Thesis, Nanjing University of Aeronautics and Astronautics, Jiangsu, China, 2015. [Google Scholar]
- Ghilardi, S.; Gianola, A.; Montali, M.; Rivkin, A. Petri Nets with Parameterised Data: Modelling and Verification. In Proceedings of the International Conference on Business Process Management, Seville, Spain, 13–18 September 2020. [Google Scholar]
- Hermenegildo, M.V.; Morales, J.F.; Lopez-Garcia, P.; Carro, M. Types, Modes and so Much More—The Prolog Way. In Prolog: The Next 50 Years, 1st ed.; Warren, D.S., Dahl, V., Eiter, T., Hermenegildo, M.V., Kowalski, R., Rossi, F., Eds.; Springer Nature: Cham, Switzerland, 2023; Volume 13900, pp. 23–37. [Google Scholar]
- Business Process Model and Notation. Available online: http://www.bpmn.org/ (accessed on 14 May 2024).
- Maqbool, B.; Azam, F.; Anwar, M.W.; Butt, W.H.; Zeb, J.; Zafar, I.; Nazir, A.K.; Umair, Z. A Comprehensive Investigation of BPMN Models Generation from Textual Requirements—Techniques, Tools and Trends. In Proceedings of the Information Science and Applications (ICISA), Hong Kong, China, 20–22 March 2018. [Google Scholar]
- Swish. Available online: https://www.swi-prolog.org/ (accessed on 14 May 2024).
- Liu, Y.; Ma, Z.Y.; He, X.; Shao, W.Z. A conversion method from UML model to reliability analysis model. J. Softw. 2010, 21, 287–304. [Google Scholar] [CrossRef]
- Yamasathien, S.; Vatanawood, W. An Approach to Construct Formal Model of Business Process Model from BPMN Workflow Patterns. In Proceedings of the 2014 Fourth International Conference on Digital Information and Communication Technology and its Applications (DICTAP), Bangkok, Thailand, 6–8 May 2014. [Google Scholar]
- Du, Y.; Xiong, P.; Fan, Y.; Li, X. Dynamic Checking and Solution to Temporal Violations in Concurrent Workflow Processes. IEEE Trans. Syst. Hum. Cybern. A 2011, 41, 1166–1181. [Google Scholar]
- Downen, P.; Ariola, Z.M. A Tutorial on Computational Classical Logic and the Sequent Calculus. J. Funct. Program 2018, 28, e3. [Google Scholar] [CrossRef]
- Shi, J.F.; Wu, H.; Gao, H.R.; Zhang, W.B. Overview on Parallel Execution Models of Smart Contract Transactions in Blockchains. J. Softw. 2022, 33, 4084–4106. [Google Scholar]
Name | Description | Symbol | Name | Description | Symbol |
---|---|---|---|---|---|
start | The starting point of the process, defines how the process starts | exclusive gateway | Modeling decisions in a process | ||
task | An atomic activity that represents an action that needs to be performed | end | The end of a branch in a process or subprocess | ||
Sequence flow | A connector between two notations in a process |
BPMN Statement | Prolog Statement |
---|---|
<bpmn2:startEvent id=“StartEventId” name=“StartEventName”> | startNode(StartEventName). |
<bpmn2:endEvent id=“EndEventId” name=“EndEventName”> | endNode(EndEventName). |
<bpmn2:task id=“TaskId” name=“TaskName”> | task(TaskName). taskName(TaskName,TaskId). |
<bpmn2:sequenceFlow id=“FlowId” sourceRef=“SourceId” targetRef=“TargetId”/> | connectionLink(FlowId,SourceId,TargetId). |
<bpmn2:exclusiveGateway id=“GatewayId” name=“GatewayName”> | gateway(GatewayName). gatewayName(GatewayName,GatewayId). |
Index | BPMN Notation | Notations of Go Smart Contract |
---|---|---|
1 | <bpmn2:definitions name=“ContractName” other notations...... </bpmn2:definitions> | ContractName.go |
2 | <bpmn2:task id=“TaskID” name=“TaskName”> other notations...... </bpmn2:task> | func TaskName(// Parameters for function) (return value, error){ task specific logic... } |
3 | <bpmn2:startEvent id=“ StartEventId “ name=“StarteventName”> </bpmn2:startEvent> | func main(){ main function code... } |
4 | <bpmn2:sequenceFlow id=“StartEventId” sourceRef=“SourceId” targetRef=“TargetId”> </bpmn2:sequenceFlow> | func SourceIdName(){ task function code corresponding to SourceId…} func TargetIdName(){ task function code corresponding to TargetId…} |
5 | <exclusiveGateway id=“GatewayName”> <documentation> Determine whether condition 1 is met </documentation> </exclusiveGateway> <sequenceFlow id=“flow1 “ sourceRef=“gate” targetRef=“Target Node”> <![CDATA[Condition 1]]> </sequenceFlow> | if(Condition 1){ business function code... } else{ business function code... ...... } |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2024 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).
Share and Cite
Jin, J.; Yan, L.; Zou, Y.; Li, J.; Yu, Z. Research on Smart Contract Verification and Generation Method Based on BPMN. Mathematics 2024, 12, 2158. https://doi.org/10.3390/math12142158
Jin J, Yan L, Zou Y, Li J, Yu Z. Research on Smart Contract Verification and Generation Method Based on BPMN. Mathematics. 2024; 12(14):2158. https://doi.org/10.3390/math12142158
Chicago/Turabian StyleJin, Jun, Le Yan, Yidan Zou, Jie Li, and Zhen Yu. 2024. "Research on Smart Contract Verification and Generation Method Based on BPMN" Mathematics 12, no. 14: 2158. https://doi.org/10.3390/math12142158
APA StyleJin, J., Yan, L., Zou, Y., Li, J., & Yu, Z. (2024). Research on Smart Contract Verification and Generation Method Based on BPMN. Mathematics, 12(14), 2158. https://doi.org/10.3390/math12142158