Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

From the Blockchain to Logic Programming and back: Research perspectives

The blockchain is a novel approach to support distributed systems enabling a common, consistent view of a shared state among distributed nodes. There, smart contracts are computer programs that allow users to deploy arbitrary computations, in charge of automatically regulate state transitions and enforce properties. In this paper we speculate on how the blockchain and smart contracts could take advantage of a logic programming approach, and, complementarily, on how logic programming can benefit from the blockchain infrastructure. Accordingly, we discuss some possible research directions and open questions for future research.

  • Login to see the comments

From the Blockchain to Logic Programming and back: Research perspectives

  1. 1. From the Blockchain to Logic Programming and back Research perspectives Giovanni Ciatto1 Roberta Calegari1 Stefano Mariani2 Enrico Denti1 Andrea Omicini1 1 {roberta.calegari, giovanni.ciatto, enrico.denti, andrea.omicini}@unibo.it 2 stefano.mariani@unimore.it 1Dipartimento di Informatica, Scienza e Ingegneria—Universit`a di Bologna 2Dipartimento di Scienze e Metodi dell’Ingegneria, Universit`a di Modena e Reggio Emilia Talk @ 19th Workshop From Objects to Agents Palermo, June 29, 2018 Ciatto (Univ. of Bologna) BC & LP: Research Perspectives WOA 2018, June 29 1 / 30
  2. 2. Outline 1 Motivations & Context 2 Blockchain and smart contracts 3 Logic-based smart contracts 4 The blockchain for distributed Logic Programming 5 Conclusions and future works Ciatto (Univ. of Bologna) BC & LP: Research Perspectives WOA 2018, June 29 2 / 30
  3. 3. Motivations & Context Next in Line. . . 1 Motivations & Context 2 Blockchain and smart contracts 3 Logic-based smart contracts 4 The blockchain for distributed Logic Programming 5 Conclusions and future works Ciatto (Univ. of Bologna) BC & LP: Research Perspectives WOA 2018, June 29 3 / 30
  4. 4. Motivations & Context Context Blockchain Technology (BCT) Novel way to achieve replication of business-logic & data on the net consistency, untamperability, fault-tolerance, trust over decentralisation eg cryptocurrencies (e.g. Bitcoin) or identity/access/asset management Smart-contracts-enabled BCT (ScBCT) An interpreter as the replicated application, executing smart contracts ie trusted computational entities automatically handling our assets Ethereum as the most prominent example Logic programming (LP) Programming as goal-oriented reasoning, on top of declarative language supports meta-programming and provides understandable outputs (proofs) employed in cognitive agents, e.g. AgentSpeak [Rao96] Ciatto (Univ. of Bologna) BC & LP: Research Perspectives WOA 2018, June 29 4 / 30
  5. 5. Motivations & Context Motivations Can LP be useful within the scope of ScBCTs? LP may positively affect smart contracts’ declarativeness, observability and mutability . . . interaction semantics, through message-passing . . . . . . paving the way towards agent-oriented smart contracts Can BCTs be useful within the scope of LP? BCTs as a shared blackboard for distributed cooperative reasoning Smart contracts as logic services, `a la LPaaS [CDMO18] Ciatto (Univ. of Bologna) BC & LP: Research Perspectives WOA 2018, June 29 5 / 30
  6. 6. Blockchain and smart contracts Next in Line. . . 1 Motivations & Context 2 Blockchain and smart contracts 3 Logic-based smart contracts 4 The blockchain for distributed Logic Programming 5 Conclusions and future works Ciatto (Univ. of Bologna) BC & LP: Research Perspectives WOA 2018, June 29 6 / 30
  7. 7. Blockchain and smart contracts Overview Blockchain & Smart contracts Overview ScBCT consist of a P2P network jointly pursuing State Machine Replication (SMR) [CBPS10, Sch90] maintaining a consistent view/update over/of a shared state . . . . . . among mutually-untrusted nodes, a.k.a. miners replicating an interpreter, i.e. a virtual machine, for smart contracts by means of the PoW Proof-of-Work [Bac02, Nak08] consensus mechanism providing eventual consistency of the whole system state endowing cryptocurrencies with their economic value logging all transactions affecting the shared state on the block-chain issued by end users Ciatto (Univ. of Bologna) BC & LP: Research Perspectives WOA 2018, June 29 7 / 30
  8. 8. Blockchain and smart contracts State, transactions & blocks Blockchain main concepts I TXs hash( ) Index i-1 Timestamp TXs hash( ) Index i Timestamp TXs hash( ) Index i+1 Timestamp Statei-1 Statei Statei+1 States, transactions and blocks: the global p.o.v. Ciatto (Univ. of Bologna) BC & LP: Research Perspectives WOA 2018, June 29 8 / 30
  9. 9. Blockchain and smart contracts State, transactions & blocks Blockchain main concepts II Transactions Blocks Blockchain Miners Clients Miners, clients and replication: the network p.o.v. Ciatto (Univ. of Bologna) BC & LP: Research Perspectives WOA 2018, June 29 9 / 30
  10. 10. Blockchain and smart contracts Smart contracts Smart contracts [Sza96] Definition Stateful, reactive, user-defined, immutable, and deterministic processes executing some arbitrary computation on the blockchain, i.e., while being consistently replicated over the blockchain network Stateful — they encapsulate their own state, like OOP’s objects Reactive — they can only be triggered by issuing some invocation TX User-defined — users can deploy their smart contracts implementing an arbitrary logic by issuing a deployment TX Immutable — their source/byte-code cannot be altered after deployment Arbitrary — they are expressed with a Turing-complete language Replicated — the blockchain is essentially a replicated interpreter, employing a consensus protocol to keep the many replicas consistent ! Disclaimer: focus on the Ethereum platform Ciatto (Univ. of Bologna) BC & LP: Research Perspectives WOA 2018, June 29 10 / 30
  11. 11. Blockchain and smart contracts Smart contracts Smart contracts – Features and problems State encapsulation + sync. interaction + transactional semantics Object-oriented & imperative metaphor, e.g. Solidity Side effects are reverted on exceptions × problems arising from re-entrancy [LCO+16, LL17] × imperative syntax is understandable to experts only Immutability + observability of code =⇒ Trust in financial TXs × may require disassembler or source code Economic dimension of computations: miners need compensation quasi-Turing completeness [Woo14] × per-instruction economic-cost may hinder SW engineering × Immutability =⇒ No bug fixes × Pure reactiveness =⇒ No scheduled/periodic computations × poor practical expressiveness Ciatto (Univ. of Bologna) BC & LP: Research Perspectives WOA 2018, June 29 11 / 30
  12. 12. Blockchain and smart contracts Smart contracts Smart contracts on the blockchain I TXs hash( ) Index i-1 Timestamp TXs hash( ) Index i Timestamp TXs hash( ) Index i+1 Timestamp Statei-1 Statei Statei+1 Smart contracts being deployed and evolving among states Ciatto (Univ. of Bologna) BC & LP: Research Perspectives WOA 2018, June 29 12 / 30
  13. 13. Blockchain and smart contracts Smart contracts Smart contracts on the blockchain II Transactions Blocks Blockchain Miners Clients Smart contracts Smart contracts being replicated among peers Ciatto (Univ. of Bologna) BC & LP: Research Perspectives WOA 2018, June 29 13 / 30
  14. 14. Logic-based smart contracts Next in Line. . . 1 Motivations & Context 2 Blockchain and smart contracts 3 Logic-based smart contracts 4 The blockchain for distributed Logic Programming 5 Conclusions and future works Ciatto (Univ. of Bologna) BC & LP: Research Perspectives WOA 2018, June 29 14 / 30
  15. 15. Logic-based smart contracts Logic-based smart contracts Smart contracts are re-interpreted as logic processes characterised by: Logic theories as specification scripts =⇒ Declarativeness & understandability Strong division between static & dynamic KBs Static KB defined upon deploy and immutable Dynamic KB keeping track of the mutable state =⇒ Controlled mutability by adding/removing rules Special functors define smart contracts interaction semantics API eg receive(Message) :- WhatToDo. eg send(Message, Receiver). send(M, R) triggers goal receive(Message) on R TX is aborted if the goal cannot be proven ! Miners role, consensus mechanism, and transactional semantics remain unchanged Ciatto (Univ. of Bologna) BC & LP: Research Perspectives WOA 2018, June 29 15 / 30
  16. 16. Logic-based smart contracts Features and open questions Interpreted Language & mutability =⇒ observability State and behaviour inspectable without disassembler Controlled mutability: a smart contract modifying it-self (Inspectable) behaviour may be added/fixed after deploy ? Which semantics for inter-smart-contracts communication? ! Sync VS async semantics of the send/2 primitive Async semantics =⇒ encapsulation of control flow ? Delayed messages for post-poned computations Self-sent messages for periodic computations Only makes sense for the async semantics ? Economic-related aspects of (logic-based) computation Who’s paying for message-triggered computations? Which value for unification? back-tracking? asserts? retracts? . . . Ciatto (Univ. of Bologna) BC & LP: Research Perspectives WOA 2018, June 29 16 / 30
  17. 17. Logic-based smart contracts Sync VS Async I Invocation TX Method Call Return from Call End of TX hash( ) Index i Timestamp TX Ciatto (Univ. of Bologna) BC & LP: Research Perspectives WOA 2018, June 29 17 / 30
  18. 18. Logic-based smart contracts Sync VS Async II Invocation TX Message TX Message TX Message TX hash( ) Index i Timestamp hash( ) Index i+2 Timestamp hash( ) Index i+3 Timestamp hash( ) Index i+1 Timestamp TX TX TX TX Ciatto (Univ. of Bologna) BC & LP: Research Perspectives WOA 2018, June 29 18 / 30
  19. 19. The blockchain for distributed Logic Programming Next in Line. . . 1 Motivations & Context 2 Blockchain and smart contracts 3 Logic-based smart contracts 4 The blockchain for distributed Logic Programming 5 Conclusions and future works Ciatto (Univ. of Bologna) BC & LP: Research Perspectives WOA 2018, June 29 19 / 30
  20. 20. The blockchain for distributed Logic Programming The blockchain as a Logic Theory The blockchain as a Logic Theory BCTs essentially provide consistent read/write access to distributed data What if data were logic terms? The whole blockchain represents (the evolution of) a logic theory Clients may issue goals to the blockchain network or asserting/retracting shared knowledge Miners may cooperatively participate to the SLD resolution process Navigating the proof-three in parallel ie publishing partial results on the blockchain ? Economical incentives for a fair balancing of computational efforts Preventing already proven goals to be proven again ? How to freeze the knowledge while reasoning? Ciatto (Univ. of Bologna) BC & LP: Research Perspectives WOA 2018, June 29 20 / 30
  21. 21. The blockchain for distributed Logic Programming Smart contacts enabled BCTs as multiple theories Smart contacts enabled BCTs as multiple theories Smart contracts essentially control consistent read/write access their internal state What if each smart contract was responsible for a monotonic theory? Non-monotone edits spawns a new smart contract in charge of handling the new theory version the old smart contract and its theory continue to exist Multiple, possibly para-consistent logic theories all originating from a common ancestor each theory expresses what is true in a particular space-time point each one is handled by a particular smart contract Clients may query each smart contract’s theory about a particular view of the world smart contracts employ SLD resolution Ciatto (Univ. of Bologna) BC & LP: Research Perspectives WOA 2018, June 29 21 / 30
  22. 22. Conclusions and future works Next in Line. . . 1 Motivations & Context 2 Blockchain and smart contracts 3 Logic-based smart contracts 4 The blockchain for distributed Logic Programming 5 Conclusions and future works Ciatto (Univ. of Bologna) BC & LP: Research Perspectives WOA 2018, June 29 22 / 30
  23. 23. Conclusions and future works Conclusions The blockchain as a means for replicating programs over the network ie Smart contracts Mixing LP and the blockchain is possible in two ways 1 Logic programming and its semantics adopted by smart contracts Logic-based smart contracts Also focusing on their interaction semantics 2 The blockchain as a fault-tolerant middleware for logic programs The blockchain as a blackboard for distributed cooperative reasoning Smart contracts as multiple para-consistent logic theories Several questions, mostly arising from the economic dimension of computation Ciatto (Univ. of Bologna) BC & LP: Research Perspectives WOA 2018, June 29 23 / 30
  24. 24. Conclusions and future works Future Works Developing our own logic-friendly blockchain implementation ? maybe based on Tendermint1 Refining our logic smart contract abstraction towards MAS Re-designing the Ethereum operational semantics [Woo14] in terms of asynchronous interactions Injecting tuProlog2 into some Java-friendly BCT eg Hyperledger Fabric [ABB+18] or Corda3 1 https://tendermint.com 2 http://apice.unibo.it/xwiki/bin/view/Tuprolog/WebHome 3 https://www.corda.net/ Ciatto (Univ. of Bologna) BC & LP: Research Perspectives WOA 2018, June 29 24 / 30
  25. 25. From the Blockchain to Logic Programming and back Research perspectives Giovanni Ciatto1 Roberta Calegari1 Stefano Mariani2 Enrico Denti1 Andrea Omicini1 1 {roberta.calegari, giovanni.ciatto, enrico.denti, andrea.omicini}@unibo.it 2 stefano.mariani@unimore.it 1Dipartimento di Informatica, Scienza e Ingegneria—Universit`a di Bologna 2Dipartimento di Scienze e Metodi dell’Ingegneria, Universit`a di Modena e Reggio Emilia Talk @ 19th Workshop From Objects to Agents Palermo, June 29, 2018 Ciatto (Univ. of Bologna) BC & LP: Research Perspectives WOA 2018, June 29 25 / 30
  26. 26. Appendix Appendix – The problem with re-entrancy I contract MyWallet { function protectSavings ( MoneyHandler handler , uint money) public { handler.deposit.value(money)(1 /* year */); } } contract MoneyHandler { struct ClientInfo { uint duration; uint since; uint amount } mapping(address => ClientInfo) clients; function deposit(uint duration) public { ClientInfo storage c = clients[msg.sender ]; c.duration = duration; c.since = now; c.amount = msg.value; } function withdraw () public { ClientInfo storage c = clients[msg.sender ]; uint amount = c.amount; amount += (now - c.since) % (c.duration * 1 years) * c.amount /100; msg.sender.send(amount); } } Ciatto (Univ. of Bologna) BC & LP: Research Perspectives WOA 2018, June 29 26 / 30
  27. 27. Appendix Appendix – The problem with re-entrancy II contract MyWallet { function protectSavings ( MoneyHandler handler , uint money) public { handler.deposit.value(money)(1 /* year */); } } contract Mallory { uint nOfTheft = 3; /* No deposit function */ function () { // <-- fallback function if (nOfTheft > 0) { MyWallet fool = (MyWallet) msg.sender; fool. protectSavings (this , 1); // <-- re -entrancy! } } } Ciatto (Univ. of Bologna) BC & LP: Research Perspectives WOA 2018, June 29 27 / 30
  28. 28. References References I [ABB+18] Elli Androulaki, Artem Barger, Vita Bortnikov, Christian Cachin, Konstantinos Christidis, Angelo De Caro, David Enyeart, Christopher Ferris, Gennady Laventman, Yacov Manevich, Srinivasan Muralidharan, Chet Murthy, Binh Nguyen, Manish Sethi, Gari Singh, Keith Smith, Alessandro Sorniotti, Chrysoula Stathakopoulou, Marko Vukoli´c, Sharon Weed Cocco, and Jason Yellick. Hyperledger Fabric: A Distributed Operating System for Permissioned Blockchains. Proceedings of the Thirteenth EuroSys Conference on - EuroSys ’18, pages 1–15, jan 2018. [Bac02] Adam Back. Hashcash - A Denial of Service Counter-Measure. Http://Www.Hashcash.Org/Papers/Hashcash.Pdf, (August):1–10, 2002. [CBPS10] Bernadette Charron-Bost, Fernando Pedone, and Andr´e Schiper, editors. Replication: Theory and Practice. Springer-Verlag, Berlin, Heidelberg, 2010. [CDMO18] Roberta Calegari, Enrico Denti, Stefano Mariani, and Andrea Omicini. Logic programming as a service. arXiv preprint arXiv:1806.02577, 2018. Ciatto (Univ. of Bologna) BC & LP: Research Perspectives WOA 2018, June 29 28 / 30
  29. 29. References References II [LCO+16] Loi Luu, Duc-Hiep Chu, Hrishi Olickel, Prateek Saxena, and Aquinas Hobor. Making Smart Contracts Smarter. In Proceedings of the 2016 ACM SIGSAC Conference on Computer and Communications Security - CCS’16, pages 254–269, New York, New York, USA, 2016. ACM Press. [LL17] Iuon-chang Lin and Tzu-chun Liao. A Survey of Blockchain Security Issues and Challenges. International Journal of Network Security, 1919(55):653–659, 2017. [Nak08] Satoshi Nakamoto. Bitcoin: A Peer-to-Peer Electronic Cash System. Www.Bitcoin.Org, page 9, 2008. [Rao96] Anand S. Rao. Agentspeak(l): Bdi agents speak out in a logical computable language. In Walter Van de Velde and John W. Perram, editors, Agents Breaking Away, pages 42–55, Berlin, Heidelberg, 1996. Springer Berlin Heidelberg. [Sch90] Fred B. Schneider. Implementing Fault-tolerant Services Using the State Machine Approach: A Tutorial. ACM Comput. Surv., 22(4):299–319, 1990. Ciatto (Univ. of Bologna) BC & LP: Research Perspectives WOA 2018, June 29 29 / 30
  30. 30. References References III [Sza96] Nick Szabo. Smart Contracts: Building Blocks for Digital Markets. Alamut.Com, (c):16, 1996. [Woo14] Gavin Wood. Ethereum: a secure decentralised generalised transaction ledger. Ethereum Project Yellow Paper, pages 1–32, 2014. Ciatto (Univ. of Bologna) BC & LP: Research Perspectives WOA 2018, June 29 30 / 30

×