GithubHelp home page GithubHelp logo

tankerwng / daml-on-fabric Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hacera/daml-on-fabric

0.0 1.0 0.0 91.9 MB

HACERA's work with Digital Asset on enabling DAML applications to run on Hyperledger Fabric

License: Apache License 2.0

Makefile 0.18% Scala 22.72% Shell 3.57% Java 65.76% Go 7.44% Dockerfile 0.33%

daml-on-fabric's Introduction

DAML on Fabric

This is an implementation of DAML ledger that stores data (transactions and state) using Hyperledger Fabric 1.4 LTS.

Quick Start Guide

Prerequisites

These are the minimal requirements that this flow was tested with. It's good to use greater versions or sometimes even lower, but not advised.

  • docker-compose version 1.24.0
  • docker CE version 18.09.6
  • Java / JDK version 1.8.0
  • Scala version 2.12.7
  • SBT version 1.2.8
  • DAML SDK version 0.13.41
  • Fabric SDK Java version 1.4.1
  • Fabric version 1.4.4

Docker and Docker-Compose are required to run a Hyperledger Fabric network, everything else is a typical dependency list for building and running a DAML ledger.

Note: running Docker as root is not recommended, this may cause issues.

Cloning DAML-on-Fabric

For the sake of cleanness, we are using the directory ~/daml-on-fabric as the root for the repository.

$ cd
$ git clone https://github.com/hacera/daml-on-fabric.git

Running a local Hyperledger Fabric network

This is achieved by running a Docker-Compose network which is a typical way to set up Fabric for development environments. Our particular example sets up a network of 5 peers, of which two will be used for endorsement.

$ cd ~/daml-on-fabric/src/test/fixture/
$ ./restart_fabric.sh

The script used is a shortcut for ./fabric.sh down && ./fabric.sh up that will erase all current data and start a fresh network.

DAML-on-Fabric command line and Services

The basic command to run the ledger right from the repository is like this:

$ sbt "run --role <roles> [--port NNNN] [DAMLArchive.dar DAMLArchive2.dar ...]"

Important: the ledger will connect to a Fabric network specified in config.json file.

Generally, if you run the ledger not against a local network, you need to provide additional argument to SBT, like this:

$ sbt "run ..." -J-DfabricConfigFile=<configuration file>

By default, it will use "config.json", which you can use for reference.

Services, or "Roles"

You may have noticed that the required argument for DAML-on-Fabric is "role".

There are several roles that define which parts of the service are going to be executed:

  • provision: will connect to Fabric and prepare it to be used as storage for a DAML ledger.
  • ledger: will run a DAML Ledger API endpoint at a port specified with --port argument.
  • time: will run a DAML time service, which writes heartbeats to the ledger. There should be exactly one time service per ledger.
  • explorer: will run a block explorer service that exposes a REST API to view the content of blocks and transactions inside the Fabric network for debugging or demonstration purposes. The explorer will run at a port specified in config.json file. It provides REST API that responds at endpoints /blocks[?id=...] and /transactions[?id=...]

One ledger may perform multiple roles at the same time, in which case roles are separated with comma. Example of this will be given later (we are using a single node just for the example).

Running Java Quick Start against DAML-on-Fabric

Step 1. Start Hyperledger Fabric

$ cd ~/daml-on-fabric/src/test/fixture/
$ ./restart_fabric.sh

Step 2. Extract and build Quick Start project

$ cd
$ rm -rf quickstart
$ daml new quickstart quickstart-java
Created a new project in "quickstart" based on the template "quickstart-java".
$ cd ~/quickstart/
$ daml build
Compiling daml/Main.daml to a DAR
Created .daml/dist/quickstart-0.0.1.dar

Step 3. Run the Ledger with Quick Start DAR archive

$ cd ~/daml-on-fabric/
$ sbt "run --port 6865 --role provision,time,ledger,explorer ../quickstart/.daml/dist/quickstart-0.0.1.dar"

Step 4. Run DAML Navigator

$ cd ~/quickstart/
daml navigator server localhost 6865 --port 4000

Step 5. Conclusion

Now you can explore your freshly setup DAML ledger.

You should have the following services running:

More information on Quick Start example and DAML in general can be found here:

https://docs.daml.com/getting-started/quickstart.html

Step 6. Running a Multi-node Setup

Start Fabric Network

  • cd src/test/fixture && ./restart_fabric.sh

Output DAR from test tool

  • cd src/test/fixture && ./download_test_tool_extract_dars.sh

First Participant Node

  • sbt "run --role ledger,time,provision --port 11111" -J-DfabricConfigFile=config.json

Second Participant Node

  • sbt "run --role ledger --port 12222" -J-DfabricConfigFile=config.json

Third Participant Node

  • sbt "run --role ledger --port 13333 src/test/fixture/SemanticTests.dar src/test/fixture/Test-stable.dar" -J-DfabricConfigFile=config.json

Run Ledger Test Tool against all nodes

  • java -jar ledger-api-test-tool.jar localhost:11111 --include=SemanticTests --timeout-scale-factor 2.0
  • java -jar ledger-api-test-tool.jar localhost:12222 --include=SemanticTests --timeout-scale-factor 2.0
  • java -jar ledger-api-test-tool.jar localhost:13333 --include=SemanticTests --timeout-scale-factor 2.0

daml-on-fabric's People

Contributors

dasormeter avatar hacera-jonathan avatar mrtea-hacera avatar gleber avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.