Contenu connexe Similaire à IBM Bluemix Nice Meetup - 20171120 - Smart Contracts (20) Plus de IBM France Lab (20) IBM Bluemix Nice Meetup - 20171120 - Smart Contracts1. 1Page© 2017 IBM Corporation© 2017 IBM Corporation
Blockchain Rule-based
Smart Contracts
With IBM Operational Decision Manager
November 2017
Stephane Mery
Distinguished Engineer, IBM ODM Chief Architect
2. 2Page© 2017 IBM Corporation
Introduction
• Some of that logic is actually Business Logic
• Encode the Business Rules that apply to the transactions
Smart Contract is the Blockchain mechanism to automate transaction processing logic.
• On the market for more than 15 years
• Used by ~1,000 Customers Worldwide for critical business operations – Finance, Insurance, Retail, Supply Chain,
Transportation…
• Provides Enterprise-class capabilities to author, execute and manage decision logic
IBM Operational Decision Manager (ODM) is the market-leading Business Rules
Management System
3. 3Page© 2017 IBM Corporation
Smart Contracts – Challenges and Opportunities
Code in Smart Contract is often Business Logic
• Implementing the clauses of contract & agreement between transacting parties
• Making transactions compliant to the regulation
• Code is essentially “business rules” encoded in Go, Java or JavaScript.
• -- quickly becomes complex to implement and manage without a rule engine
• è need to be more accessible to Business Stakeholders, a high-level business-friendly language would be better
Business Logic might change frequently
• Need proper governance around change
• è need extensive tooling to govern Smart Contracts life-cycle
Semantic of the Smart Contract should be well defined
• Expressivity should be limited to early detect inconsistencies, ambiguities and contradictions
• We should be able to verify, test and simulate Smart Contracts
• è A Rule Engine provides a safer environment, trading expressivity for safety
4. 4Page© 2017 IBM Corporation
Smart Contracts – Use Case – Blockchain for Music
Digital Rights dispatch to Artists
- Current solutions spoil artists
- Intermediaries capture a lot of the value
- Smart Contracts to store artist rights
encoded as rules
- Smart Contract to encode payment split
depending on when/where a song is
broadcast, for instance
- …
Example derived from Sacem/PRS/Ascap general use-case. Not representative of real Customer use-case
6. 6Page© 2017 IBM Corporation
Smart Contracts leveraging IBM Operational Decision Manager
è Externalizing Smart Contract business logic in ODM
- Business decisions involved in Smart Contracts are delegated to the ODM rule engine
- eXecution Object Model generated from HyperLedger Composer Data Model
- Business stakeholders are maintaining the logic in ODM tools, like Decision Center
è Integrating ODM Rule Execution Server with Hyperledger Fabric
- Deploying Rule Execution Server in Blockchain peer nodes
- Calling Decision Services REST API from Hyperledger Composer Smart Contracts
- Deploying Ruleset through Blockchain transactions
7. 7Page© 2017 IBM Corporation
Smart Contracts – Running ODM rules in-chain
- ODM rule engine part of the
Blockchain Peer Nodes
validating transactions
- Deployed as a Docker
image
- Transaction processing logic expressed
as Business Rules with ODM
- Ruleset stored in the Blockchain and
deployed through a Blockchain
transaction
- Out-process REST call from Composer
Transaction Processor
Leveraging ODM Business-friendly tooling to author, test, simulate and govern Smart Contract rules
8. 8Page© 2017 IBM Corporation
• Decision Services are implemented in ODM
- eXecution Object Model and BOM are generated from HyperLedger Composer domain model
- Business Vocabulary created in ODM
- Decisions are implemented as Business Rules & Decision Tables using ODM tooling
• Decision Services exposed as REST/JSON API
- Signature based on the BOM
- Called from the Smart Contract
Invoking Decision Services
9. 9Page© 2017 IBM Corporation
Invoking Decision Services
• HyperLedger Composer Transaction Processors calling-out to Decision Service REST API
- Transaction data and assets are serialized in JSON and passed to the POST API
- Decision result data come back as JSON object, used in the Java Script Transaction Processor code
HyperLedger Composer Transaction Processor
Using Composer ‘post’ API passing the transaction
and related assets referenced by the transaction
Transaction Processor code decodes the decision
service response and takes the appropriate action
10. 10Page© 2017 IBM Corporation
Business Rules life-cycle
• New version of the Ruleset are submitted to the Blockchain as Transactions
- Specific RuleAppUpdated Transaction type specified in Composer
- Specific Transaction Processor in Composer to handle the transaction and deploy the ruleset
- Ruleset deployed to the RES associated to the peer through a facade to the RES exposed as a REST API
• Most current Ruleset version is stored in the Blockchain
- Ruleset are stored in the Blockchain for reference
- The most current version number is written in an asset and used when calling out Decision Services
- If deployment transaction fails, transaction is rolled-back and most current version is unchanged
• XOM changes are deployed the same way
- All logic execution support secured by the Blockchain
11. 11Page© 2017 IBM Corporation
Smart Contracts – Business Rules Lifecycle Management
1 Business Users update rules in
Decision Center following proper
Governance workflow
2
When Business Rules are agreed and
properly validated, they are pushed to
the Ledger as a Transaction and
dispatched to all Nodes
Composer
Chaincode
Specific Transaction Processor
ODM Rule Execution Server
RES Deploy REST API
Blockchain World State
& Ledger
Ruleset Deployment Tx
3
Ruleset is stored in
the Ledger as well
as the current
version
4 Ruleset is deployed to the RES
5
When Deployment
Tx will be validated
on all nodes, the
new version of the
rules is available
Ruleset
Blockchain Peer Node
Blockchain
12. 12Page© 2017 IBM Corporation
Wrap-up
• Smart Contract is a key concept in Blockchain. The logic applied to transactions is likely to be
Business-related.
• IBM ODM, as the Market-leading Decision Management platform, provides Enterprise-class
capabilities to define and manage Business-logic and make it accessible to the Business.
• The combination of Blockchain/Smart Contract and ODM is a way to go beyond technology and
include Business stakeholders in the value chain.
13. 13Page© 2017 IBM Corporation
http://ibm.biz/odm-blockchain
https://github.com/ODMDev/sample-blockchain-vehicle-lifecycle
Article
Sample
References
14. 14Page© 2017 IBM Corporation
Vehicle Lifecycle Blockchain Application
• Developed with Hyperledger Composer and run on Hyperledger Fabric
• Manage the overall lifecycle of a Vehicle from Order to Recycling through registration and
various ownership transfer
• Detect suspicious ownership transfer using Business Rules externalized in ODM
https://www.youtube.com/watch?v=IgNfoQQ5Reg
16. 16Page© 2017 IBM Corporation
Vehicle Lifecycle Data Model in Composer
Participants, Assets and Transactions are defined in HyperLedger Composer
17. 17Page© 2017 IBM Corporation
Vehicle Lifecycle Data Model in ODM
• The same model is designed in ODM as a Java Execution Model (XOM) and a Business Object Model (BOM).
• Could be generated from Composer
• A Business Vocabulary is created in ODM using the business terminology
18. 18Page© 2017 IBM Corporation
Vehicle Lifecycle Data Model in ODM
Based on the Decision Service signature, ODM generates a REST API
19. 19Page© 2017 IBM Corporation
Decision: is this transaction suspicious?
Is the ownership transfer of this Vehicle from this Seller to this Buyer suspicious?
21. 21Page© 2017 IBM Corporation
• HyperLedger Fabric and Composer deployed as a set of Docker Containers
Step1 – Start Hyperledger Fabric and Composer
Please refer to https://hyperledger.github.io/composer/installing/development-tools.html to install and run
HyperLedger Fabric and Composer.
22. 22Page© 2017 IBM Corporation
• Start the ODM Rule Execution Server Docker Container
Step 2 – Start ODM RES Docker Container
In odm-runtime directory , invoke docker-compose up command
23. 23Page© 2017 IBM Corporation
• Start the Deployment Service facade
Step 3 – Start ODM Deployment Service
In odm-deployer directory , invoke docker-compose up command
24. 24Page© 2017 IBM Corporation
• Use Rule Designer to build the XOM and the Ruleapp
it packages the XOM jar and the Ruleapp in the ‘output’ directory
Step 4 – Build the XOM and the RuleApp
Launch IBM ODM Rule Designer on a workspace and import projects from vehicle-lifecycle-xom
and vehicle-lifecycle-decision-service
25. 25Page© 2017 IBM Corporation
• Using Composer API to build and deploy vehicle-lifecycle@1.0.0.bna
Step 5 – Deploy the Vehicle Lifecycle Business Network to Blockchain
Go to vehicle-lifecycle directory , invoke npm run deploy command
26. 26Page© 2017 IBM Corporation
• XOM is built from Rule Designer and deployed to the RES through a Blockchain
transaction
Step 6 – Deploy the XOM to the RES
In vehicle-lifecycle-cli directory, invoke npm run deployXom command (*)
(*) the first time you have to invoke npm install to
initialize the command line
27. 27Page© 2017 IBM Corporation
Step 7 – Deploy the RuleApp to the RES
• The Ruleapp is built from Rule Designer and deployed to the RES through a Blockchain
transaction
In vehicle-lifecycle-cli directory, invoke npm run deployRuleapp command
28. 28Page© 2017 IBM Corporation
• Send specific PrivateVehicleTransfer transactions that are detected as suspicious by
ODM. The decision service returns the suspicion message related to the vehicle
Step 8 – Submit suspicious transactions
In vehicle-lifecycle-cli directory, invoke npm run demo command
29. 29Page© 2017 IBM Corporation
• Use ODM Tooling to change the Business Rules. Increment the version number of the
Ruleset and generate the new Ruleapp archive
Step 9 – Updating the business logic
30. 30Page© 2017 IBM Corporation
• Submit a RuleUpdated transaction with the new ruleapp
Npm run list (in vehicle-lifecycle directory) >
Step 10 – Deploy the new version of the RuleApp
In vehicle-lifecycle-cli directory, invoke the following node command
31. 31Page© 2017 IBM Corporation
• Submit a suspicious transfer again
Step 11 – See impact of business logic change