Code Monkey home page Code Monkey logo

fabric-gateway's Introduction

Hyperledger Fabric Gateway

For information on using the Gateway, including client SDK API references, please visit the Fabric Gateway documentation.

Overview

The original proposal is described in the Fabric Gateway RFC. Adding a Gateway component to the Fabric Peer provides a single entry point to a Fabric network, and removes much of the transaction submission logic from the client application.

The Gateway component in the Fabric Peer exposes a simple gRPC interface to client applications and manages the lifecycle of transaction invocation on behalf of the client. This minimises the network traffic passing between the client and the blockchain network as well as minimising the number of network ports that need to be opened.

See the gateway.proto file for details of the gRPC interface.

Building and testing

Install pre-reqs

This repository comprises three functionally equivalent client APIs, written in Go, Typescript, and Java. In order to build these components, the following needs to be installed and available in the PATH:

  • Go 1.16
  • Node 14
  • Java 8
  • Docker
  • Make
  • Protobuf compiler (https://developers.google.com/protocol-buffers/docs/downloads)
  • Some Go tools:
    • go install github.com/cucumber/godog/cmd/[email protected]
    • go get google.golang.org/grpc google.golang.org/protobuf/cmd/protoc-gen-go google.golang.org/grpc/cmd/protoc-gen-go-grpc
    • go get honnef.co/go/tools/cmd/staticcheck
    • go get github.com/golang/mock/mockgen
  • pkcs11 enabled fabric-ca-client
    • go get -tags 'pkcs11' github.com/hyperledger/fabric-ca/cmd/fabric-ca-client
  • SoftHSM, which can either be:
    • installed using the package manager for your host system:
      • Ubuntu: sudo apt install softhsm2
      • macOS: brew install softhsm
      • Windows: unsupported
    • or compiled and installed from source:
      1. install openssl 1.0.0+ or botan 1.10.0+
      2. download the source code from https://dist.opendnssec.org/source/softhsm-2.5.0.tar.gz
      3. tar -xvf softhsm-2.5.0.tar.gz
      4. cd softhsm-2.5.0
      5. ./configure --disable-gost (would require additional libraries, turn it off unless you need 'gost' algorithm support for the Russian market)
      6. make
      7. sudo make install

Build using make

The following Makefile targets are available

  • make generate - generate mock implementations used by unit tests
  • make unit-test-go - run unit tests for the gateway server and Go SDK
  • make unit-test-node - run unit tests for the Node SDK
  • make unit-test-java - run unit tests for the Java SDK
  • make unit-test - run unit tests for the gateway server and all three SDKs
  • make pull-latest-peer - fetch the latest peer docker image containing the gateway server
  • make scenario-test-go - run the scenario (end to end integration) tests for Go SDK
  • make scenario-test-node - run the scenario tests for Node SDK
  • make scenario-test-java - run the scenario tests for Java SDK
  • make scenario-test - run the scenario tests for all SDKs
  • make test - run all unit and scenario tests
  • make sample-network - create the sample network used to run samples
  • make sample-network-clean - remove the sample network
  • make run-samples-go - run the samples for the Go SDK
  • make run-samples-node - run the samples for the Node SDK
  • make run-samples-java - run the samples for the Java SDK
  • make run-samples - create the sample network, run samples for all three SDKs, and remove the sample network

Note that immediately after creating a fresh copy of this repository, auto-generated test mocks will not be preset so Go code will show errors. Running the unit-test make target will generate the required mock implementations, and they can also be generated explicitly by running make generate.

Scenario tests

The scenario tests create a Fabric network comprising two orgs (one peer in each org) and a single gateway within a set of docker containers. The clients connect to the gateway to submit transactions and query the ledger state.

The tests are defined as feature files using the Cucumber BDD framework. The same set of feature files is used across all three SDKs to ensure consistency of behaviour.

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.