From Agents to Blockchain: Stairway to Integration
Abstract
:1. Introduction
1.1. Motivation
1.2. Contribution
- We present and discuss the dimensions of agent–blockchain integration (computation vs. interaction) and the impact on agent-oriented practice and blockchain, then we enumerate and analyze viable approaches to integration by considering what we call “agent-vs-blockchain” and “agent-to-blockchain” approaches, such as letting agents interact with the blockchain vs. modelling agents as smart contracts, or injecting blockchain and smart contract concepts into agents (e.g., programming agents through smart contracts). Accordingly, we propose two roadmaps for the exploration of the aforementioned approaches
- We validate the first steps of our roadmaps through Tenderfone [16,19], which is a prototype of agent-oriented blockchain we designed and implemented, where smart contracts are empowered with autonomy through mechanisms endowing them control flow and asynchronous interaction means, showing the advantages of pushing smart contracts closer to agent abstraction.
1.3. Structure
2. Stairway to Integration
2.1. Smart Contracts and Agents at a Glance
- In the bottom layer, a number of validator nodes take care of achieving consensus about ordering of transactions so as to actually create the chain of blocks constituting the shared ledger, representing the agreement about who made what happen, and when.
- The middle layer is where the machinery executing smart contracts resides. This machinery is an interpreter/virtual machine replicated on every node (as validators), which ensures consistency amongst distributed executions. Here is where the operational semantics of a specific programming language for smart contracts is implemented.
- The top layer is the application level, whose state and behavior are defined by the collective of smart contracts deployed on the blockchain at any given time.
- user-centric
- —created and deployed by end users, for end users
- transparent
- —their source code can be inspected by any participant
- immutable
- —their source code cannot be altered after deployment
- reactive
- —they must always be triggered from end users in the first place
- stateful
- —each smart contract encapsulates state and behaviour
- deterministic
- —given the same initial state and inputs, their output is always the same, consistently across nodes
- synchronous
- —they are invoked through a synchronous request-response protocol
- situated
- social
- —Agents may overcome their own individual limitations by interacting with others, through both explicit communication mechanisms, such as message passing, and implicit ones, such as stigmergy [28].
- goal-oriented
- [29]—Agents act towards achievement of a goal, either embedded in their design (goal-driven) or explicitly represented and amenable of manipulation (goal-governed).
2.2. State of the Art
2.3. The Roadmaps
2.4. Discussion
3. Towards Autonomous SC with Tenderfone
3.1. An Agent-Oriented Language for
3.1.1. Computational Autonomy
3.1.2. Asynchronous Interaction
- receive(+Message, @SenderID) is a callback that specifies what a smart contract should do every time it is triggered by an invocation transaction carrying a Message, and coming from either an end user (through invoke/2) or another smart contract (through send/2) identified by SenderID. The execution of each receive/2 callback, on any smart contract, is atomic and must terminate like in any other SC-enabled blockchain technology. However, differently from other BCT, smart contracts in Tenderfone can trigger their own receive/2 callbacks, autonomously, by means of some mechanisms described below. For instance, a smart contract may simply decide to store the message but process it later on, through the time-aware constructs described in next subsection, so as to preserve its autonomy without hindering the blockchain semantics.
- send(+Message, @ReceiverID) is a built-in predicate aimed at letting smart contracts send messages to each other. It works by simply adding Message to the outbox of the current smart contract, in order to let it be eventually dispatched to ReceiverID. However, the actual dispatching of Message does not occur immediately. Accordingly, we say that the send/2 built-in predicate just “outboxes” a Message. As any other built-in predicate, the send/2 one can only be used within the body of some callback. According to Tenderfone asynchronous semantics, the actual dispatching of the (possibly many) messages outboxed by the (possibly multiple) invocations of the send/2 predicate within a given callback is conditioned by the successful execution of such callback. If (and only if) the execution of the wrapping callback terminates successfully, then the messages in the outbox are actually dispatched to their recipients. This implies that the receive/2 callback is then triggered on the receiver smart contracts (i.e., the ones identified by ReceiverID) by means of an invocation transaction, which is generated by the Tenderfone Interpreter whenever some callback successfully terminates.
- answer(+Message, @SenderID, -Result) is a callback that specifies how the smart contract should answer (with which Result) every time it is triggered through observe/3 API primitive (last paragraph) by an end user whose identifier is SenderID. Any side effect possibly produced by the callback during its execution is simply dropped as soon as the callback terminates. In other words, the answer/3 callback is aimed at serving users’ queries in a read-only fashion. In fact, this callback is intended to promote encapsulation: by defining many answer/3, the developer chooses which parts of the SC status to make observable.
3.1.3. Reactiveness to Time
- now(-Timestamp) is a built-in predicate aimed at letting SC inspect the current time. It works by retrieving the last value of shared through consensus, that is, the value of stored in the block whose commit has triggered execution of the current smart contract. Hence, multiple invocations of this predicate occurring in the same callback will always get the same value for Timestamp.
- when(@Instant, +Goal) is a built-in predicate aimed at letting SC postpone a computation for a future moment in time. It works by scheduling the execution of the receive(Goal, Me) callback, assuming Me is the executing smart contract ID, as soon as Instant, as a way to delay a computation to an absolute point in time.
- delay(@Interval, +Goal) is a built-in predicate aimed at letting SC delay a computation for a relative amount of time. It works by scheduling the execution of the receive(Goal, Me) callback as soon as Interval, where is the value of the global time when delay/2 was invoked.
- periodically(@Period, +Goal) is a built-in predicate aimed at letting SC execute a computation periodically. It works by (i) triggering the receive(Goal, Me) callback other than (ii) scheduling the future execution of the same callback for the first possible instant Period, where is the value of the global time when receive/2 was first invoked. Such process is repeated again as soon as the receive/2 callback is executed twice. The repetition of this process over and over again produces a periodic series of executions of the receive/2 callback, which is unlimited in length. The temporal distance among any two consecutive executions of the receive(Goal, Me) is constant and is equal to Period units of time. The series is interrupted as soon as some execution of receive(Goal, Me) fails.
3.1.4. Miscellaneous
- self(-Identifier) retrieves the Identifier of the current smart contract—which is automatically generated by the Tenderfone Interpreter and immutably stored into each SC’s static KB upon creation.
- owner(-Identifier) retrieves the Identifier of the owner of the current smart contract—that is, by construction, the user creating it.
- set_data(@Key, ?Value) either stores the (Key, Value) pair in the dynamic KB of the current smart contract or replaces (Key, Whatever), if present.
- get_data(?Key, ?Value) checks if a pair matching (Key, Value) exists within the current smart contract’s dynamic KB, and, if it does, lets the SC read it.
3.1.5. End User API
- deploy(@StaticKB, +Args, -GeneratedID) creates a smart contract whose static KB is set to StaticKB and triggers its callback init/1 with arguments Args. If execution of the callback is successful, the smart contract is actually deployed, and a fresh and unique identifier is automatically assigned to it by the Tenderfone Interpreter. Furthermore, the generated identifier is bound to variable GeneratedID and thus returned to the user.
- invoke(+Goal, @SmartContractID) triggers the receive(Goal, UserID) callback, where UserID is the identifier of the calling user, on the smart contract whose identifier is SmartContractID. Execution fails if receive(Goal, UserID) fails, and in that case, all side effects occurred are discarded; hence, invoke/2 has all-or-nothing semantics.
- observe(+Query, @SmartContractID, -Result) triggers the answer(Query, User, Result) callback, where variable User is bound to the identifier of the invoking user, on the smart contract whose identifier is SmartContractID. Execution fails if and only if the triggered answer/2 callback fails. In any case, all side effects possibly occurred are dropped, as observe/3 is intended with a read-only semantics to let users inspect the state of the blockchain and of SC.
3.2. The Tenderfone Interpreter
- via consensus, validators agree on the content of the th (i.e., transactions ) block and on its time-stamp ;
- each validator then notifies the beginning of the protocol to its local interpreter, informing it that the management of block i begins at time ;
- the local interpreter joins the protocol by returning a list of spontaneous transactions, one for each computation which has been previously postponed, delayed, or scheduled to an instant not later than ;
- then, the protocol makes each validator forward each transaction to the local interpreter, which in turn
- executes , possibly updating the current state of the system (e.g., by creating, destroying, or altering the internal state of some smart contract),
- appends all the outgoing messages possibly sent by any smart contract triggered during the previous step into a temporary outbox queue;
- once all transactions have been processed, validators notify the commitment of the block to their local interpreter;
- each interpreter should then conclude the protocol by returning another list of spontaneous transactions, one for each outgoing message accumulated into the aforementioned outbox queue—which is finally emptied.
3.3. Autonomy vs. Security
4. Case Studies: Supply Chain and Public Tender
4.1. Supply Chains
4.2. Automatic Applications to Public Calls
5. Conclusions & Outlook
Author Contributions
Funding
Acknowledgments
Conflicts of Interest
References
- Herlihy, M. Blockchains from a Distributed Computing Perspective. Commun. ACM 2019, 62, 78–85. [Google Scholar] [CrossRef] [Green Version]
- Stanciu, A. Blockchain Based Distributed Control System for Edge Computing. In Proceedings of the 2017 21st International Conference on Control Systems and Computer Science (CSCS), Bucharest, Romania, 29–31 May 2017; pp. 667–671. [Google Scholar]
- Shafagh, H.; Burkhalter, L.; Hithnawi, A.; Duquennoy, S. Towards Blockchain-based Auditable Storage and Sharing of IoT Data. In Proceedings of the 2017 on Cloud Computing Security Workshop, Dallas, TX, USA, 3–5 November 2017; pp. 45–50. [Google Scholar]
- Xu, Q.; Aung, K.M.M.; Zhu, Y.; Yong, K.L. A Blockchain-Based Storage System for Data Analytics in the Internet of Things. In New Advances in the Internet of Things; Yager, R.R., Pascual Espada, J., Eds.; Springer International Publishing: Cham, Switzerland, 2018; pp. 119–138. [Google Scholar]
- Casado-Vara, R.; Prieto, J.; la Prieta, F.D.; Corchado, J.M. How blockchain improves the supply chain: Case study alimentary supply chain. Procedia Comput. Sci. 2018, 134, 393–398. [Google Scholar] [CrossRef]
- Mettler, M. Blockchain technology in healthcare: The revolution starts here. In Proceedings of the 2016 IEEE 18th International Conference on e-Health Networking, Applications and Services (Healthcom), Munich, Germany, 14–17 September 2016; pp. 1–3. [Google Scholar]
- Calvaresi, D.; Dubovitskaya, A.; Calbimonte, J.P.; Taveter, K.; Schumacher, M. Multi-Agent Systems and Blockchain: Results from a Systematic Literature Review. In Advances in Practical Applications of Agents, Multi-Agent Systems, and Complexity: The PAAMS Collection; Demazeau, Y., An, B., Bajo, J., Fernández-Caballero, A., Eds.; Springer International Publishing: Cham, Switzerland, 2018; pp. 110–126. [Google Scholar]
- Calvaresi, D.; Dubovitskaya, A.; Retaggi, D.; Dragoni, F.A.; Schumacher, M. Trusted Registration, Negotiation, and Service Evaluation in Multi-Agent Systems throughout the Blockchain Technology. In Proceedings of the 2018 IEEE/WIC/ACM International Conference on Web Intelligence (WI); Santiago, Chile: 3–6 December 2018; pp. 56–63.
- Amato, F.; Femia, P.; Moscato, F. Enabling Accountable Collaboration in Distributed, Autonomous Systems by Intelligent Agents. In Complex, Intelligent, and Software Intensive Systems; Barolli, L., Hussain, F.K., Ikeda, M., Eds.; Springer International Publishing: Cham, Switzerland, 2020; pp. 807–816. [Google Scholar]
- Papi, F.G.; Hübner, J.F.; de Brito, M. Instrumenting Accountability in MAS with Blockchain. In Proceedings of the First Workshop on Computational Accountability and Responsibility in Multiagent Systems co-located with 20th International Conference on Principles and Practice of Multi-Agent Systems, Nice, France, 30 October–3 November 2017; pp. 20–34. [Google Scholar]
- Castelló Ferrer, E. The Blockchain: A New Framework for Robotic Swarm Systems. In Future Technologies Conference (FTC); Arai, K., Bhatia, R., Kapoor, S., Eds.; Springer International Publishing: Cham, Switzerland, 2019; pp. 1037–1058. [Google Scholar]
- Ciatto, G.; Mariani, S.; Omicini, A. Blockchain for Trustworthy Coordination: A First Study with Linda and Ethereum. In Proceedings of the 2018 IEEE/WIC/ACM International Conference on Web Intelligence (WI), Santiago, Chile, 3–6 December 2018; pp. 696–703. [Google Scholar]
- Macrinici, D.; Cartofeanu, C.; Gao, S. Smart contract applications within blockchain technology: A systematic mapping study. Telemat. Inform. 2018, 35, 2337–2354. [Google Scholar] [CrossRef]
- Wegner, P. Why Interaction is More Powerful Than Algorithms. Commun. ACM 1997, 40, 80–91. [Google Scholar] [CrossRef]
- Ciatto, G.; Mariani, S.; Maffi, A.; Omicini, A. Blockchain-Based Coordination: Assessing the Expressive Power of Smart Contracts. Information 2020, 11, 52. [Google Scholar] [CrossRef] [Green Version]
- Ciatto, G.; Maffi, A.; Mariani, S.; Omicini, A. Smart Contracts are More than Objects: Pro-activeness on the Blockchain. In Blockchain and Applications; Prieto, J., Kumar, A.D., Ferretti, S., Pinto, A., Corchado, J.M., Eds.; Springer: New York, NY, USA, 2020; Volume 1010, pp. 45–53. [Google Scholar]
- Christidis, K.; Devetsikiotis, M. Blockchains and Smart Contracts for the Internet of Things. IEEE Access 2016, 4, 2292–2303. [Google Scholar] [CrossRef]
- Gatteschi, V.; Lamberti, F.; Demartini, C.; Pranteda, C.; Santamaría, V. Blockchain and Smart Contracts for Insurance: Is the Technology Mature Enough? Future Internet 2018, 10, 20. [Google Scholar] [CrossRef] [Green Version]
- Ciatto, G.; Maffi, A.; Mariani, S.; Omicini, A. Towards Agent-oriented Blockchains: Autonomous Smart Contracts. In Advances in Practical Applications of Survivable Agents and Multi-Agent Systems: The PAAMS Collection; Demazeau, Y., Matson, E., Corchado, J.M., De la Prieta, F., Eds.; Springer International Publishing: Cham, Switzerland, 2019; Volume 11523, pp. 29–41. [Google Scholar]
- Szabo, N. Smart Contracts. 1994. Available online: http://www.fon.hum.uva.nl/rob/Courses/InformationInSpeech/CDROM/Literature/LOTwinterschool2006/szabo.best.vwh.net/smart.contracts.html (accessed on 22 October 2020).
- Wood, G. Ethereum: A Secure Decentralised Generalised Transaction Ledger. 2014. Available online: https://ethereum.github.io/yellowpaper/paper.pdf (accessed on 22 October 2020).
- Androulaki, E.; Barger, A.; Bortnikov, V.; Cachin, C.; Christidis, K.; De Caro, A.; Enyeart, D.; Ferris, C.; Laventman, G.; Manevich, Y. Hyperledger Fabric: A Distributed Operating System for Permissioned Blockchains. In Proceedings of the 13th EuroSys Conference (EuroSys’18), London, UK, 18–21 April 2018. [Google Scholar]
- Stark, J. Making Sense of Blockchain Smart Contracts; CoinDesk: New York, NY, USA, 2016. [Google Scholar]
- Odell, J. Objects and Agents Compared. J. Object Technol. 2002, 1, 41–53. [Google Scholar] [CrossRef]
- Omicini, A.; Ricci, A.; Viroli, M. Artifacts in the A&A Meta-Model for Multi-Agent Systems. Auton. Agents-Multi-Agent Syst. 2008, 17, 432–456. [Google Scholar] [CrossRef]
- Suchman, L.A. Plans and Situated Actions: The Problem of Human-Machine Communication; Cambridge University Press: New York, NY, USA, 1987. [Google Scholar]
- Omicini, A.; Ricci, A.; Viroli, M. Timed Environment for Web Agents. Web Intell. Agent Syst. 2007, 5, 161–175. [Google Scholar]
- Ricci, A.; Omicini, A.; Viroli, M.; Gardelli, L.; Oliva, E. Cognitive Stigmergy: Towards a Framework Based on Agents and Artifacts. In Environments for MultiAgent Systems III; Springer: New York, NY, USA, 2007; Volume 4389, pp. 124–140. [Google Scholar]
- Conte, R.; Castelfranchi, C. Cognitive and Social Action; UCL Press: London, UK, 1995; p. 215. [Google Scholar]
- Xu, X.; Pautasso, C.; Zhu, L.; Gramoli, V.; Ponomarev, A.; Tran, A.B.; Chen, S. The Blockchain as a Software Connector. In Proceedings of the 2016 13th Working IEEE/IFIP Conference on Software Architecture (WICSA), Venice, Italy, 5–8 April 2016; pp. 182–191. [Google Scholar]
- Ferber, J.; Müller, J.P. Influences and Reaction: A Model of Situated Multiagent Systems. In Proceedings of the Second International Conference on Multi-Agent Systems (ICMAS-96), Kyoto, Japan, 9–13 December 1996; pp. 72–79. [Google Scholar]
- Castelfranchi, C.; Dignum, F.; Jonker, C.M.; Treur, J. Deliberative Normative Agents: Principles and Architecture. In Intelligent Agents VI. Agent Theories, Architectures, and Languages; Jennings, N.R., Lespérance, Y., Eds.; Springer: New York, NY, USA, 2000; Volume 1757, pp. 364–378. [Google Scholar]
- O’Brien, P.D.; Nicol, R.C. FIPA—Towards a standard for software agents. BT Technol. J. 1998, 16, 51–59. [Google Scholar] [CrossRef]
- Kwon, J. Tendermint: Consensus without Mining. 2014. Available online: https://tendermint.com/static/docs/tendermint.pdf (accessed on 22 October 2020).
- Denti, E.; Omicini, A.; Ricci, A. tuProlog: A Light-weight Prolog for Internet Applications and Infrastructures. In Practical Aspects of Declarative Languages; Springer: New York, NY, USA, 2001; Volume 1990, pp. 184–198. [Google Scholar]
- Kowalski, R.A. Predicate Logic as Programming Language. In Proceedings of the 1974 IFIP Congress, Stockholm, Sweden, 5–10 August 1974; pp. 569–574. [Google Scholar]
- Ciatto, G.; Calegari, R.; Mariani, S.; Denti, E.; Omicini, A. From the Blockchain to Logic Programming and Back: Research Perspectives. In Proceedings of the 19th Workshop “From Objects to Agents”, Palermo, Italy, 28–29 June 2018; pp. 69–74. [Google Scholar]
- Fischer, M.J.; Lynch, N.A.; Paterson, M.S. Impossibility of Distributed Consensus with One Faulty Process. J. ACM 1985, 32, 374–382. [Google Scholar] [CrossRef]
Programming → ↓ Unit | Monolitic | Modular | Object-Oriented | Agent |
---|---|---|---|---|
Behavior | Non-modular | Modular | Modular | Modular |
State | External | External | Internal | Internal |
Invocation | External | External (calls) | External (messages) | Internal (rules, goals) |
Callback | Executor | Trigger | Carrier | Initiator |
---|---|---|---|---|
init(A) | a SC whose KB = T | API deploy(T, A) | deployment TX | a user |
receive(M, S) | a SC R | API invoke(M, R) built-in send(M, R) | invocation TX message | a user S a SC S |
receive(M, R) | a SC R | built-in when(T, M) built-in delay(D, M) built-in periodically(P, M) | message message message | a SC R a SC R a SC R |
answer(Q, S, X) | a SC R | API observe(Q, R, X) | query | a user SC S |
Publisher’s Note: MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations. |
© 2020 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 (http://creativecommons.org/licenses/by/4.0/).
Share and Cite
Ciatto, G.; Mariani, S.; Omicini, A.; Zambonelli, F. From Agents to Blockchain: Stairway to Integration. Appl. Sci. 2020, 10, 7460. https://doi.org/10.3390/app10217460
Ciatto G, Mariani S, Omicini A, Zambonelli F. From Agents to Blockchain: Stairway to Integration. Applied Sciences. 2020; 10(21):7460. https://doi.org/10.3390/app10217460
Chicago/Turabian StyleCiatto, Giovanni, Stefano Mariani, Andrea Omicini, and Franco Zambonelli. 2020. "From Agents to Blockchain: Stairway to Integration" Applied Sciences 10, no. 21: 7460. https://doi.org/10.3390/app10217460
APA StyleCiatto, G., Mariani, S., Omicini, A., & Zambonelli, F. (2020). From Agents to Blockchain: Stairway to Integration. Applied Sciences, 10(21), 7460. https://doi.org/10.3390/app10217460