Skip to content

Commit

Permalink
Merge branch 'hyperledger-labs:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
vipinsun authored Mar 18, 2022
2 parents fdc5238 + a60f23b commit 999f5d2
Show file tree
Hide file tree
Showing 340 changed files with 14,271 additions and 11,691 deletions.
39 changes: 0 additions & 39 deletions .github/workflows/dvpfabtoken.yml

This file was deleted.

6 changes: 2 additions & 4 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ jobs:
runs-on: ubuntu-latest
env:
GOPATH: ${{ github.workspace }}
GOFLAGS: -mod=mod
defaults:
run:
working-directory: ${{ env.GOPATH }}/src/github.com/hyperledger-labs/fabric-token-sdk
Expand All @@ -34,7 +35,4 @@ jobs:
run: make checks

- name: Unit Tests
run: make unit-tests

- name: Integration Tests
run: make integration-tests
run: make unit-tests-race
1 change: 1 addition & 0 deletions .github/workflows/tccdlog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jobs:
runs-on: ubuntu-latest
env:
GOPATH: ${{ github.workspace }}
GOFLAGS: -mod=mod
defaults:
run:
working-directory: ${{ env.GOPATH }}/src/github.com/hyperledger-labs/fabric-token-sdk
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/ut.yml → .github/workflows/tccdvpdlog.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Unit tests
name: Token DVP with DLOG Driver

on:
push:
Expand All @@ -12,6 +12,7 @@ jobs:
runs-on: ubuntu-latest
env:
GOPATH: ${{ github.workspace }}
GOFLAGS: -mod=mod
defaults:
run:
working-directory: ${{ env.GOPATH }}/src/github.com/hyperledger-labs/fabric-token-sdk
Expand All @@ -29,5 +30,5 @@ jobs:
- name: Checks
run: make checks

- name: Unit Tests
run: make unit-tests
- name: Integration Tests
run: make integration-tests-tcc-dvp-dlog
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: DvP with DLOG Driver
name: Token DVP with FabToken Driver

on:
push:
Expand All @@ -12,6 +12,7 @@ jobs:
runs-on: ubuntu-latest
env:
GOPATH: ${{ github.workspace }}
GOFLAGS: -mod=mod
defaults:
run:
working-directory: ${{ env.GOPATH }}/src/github.com/hyperledger-labs/fabric-token-sdk
Expand All @@ -21,12 +22,6 @@ jobs:
with:
path: ${{ env.GOPATH }}/src/github.com/hyperledger-labs/fabric-token-sdk

- name: Checkout Fabric Smart Client
uses: actions/checkout@v2
with:
repository: hyperledger-labs/fabric-smart-client
path: ${{ env.GOPATH }}/src/github.com/hyperledger-labs/fabric-smart-client

- name: Set up Go
uses: actions/setup-go@v2
with:
Expand All @@ -36,4 +31,4 @@ jobs:
run: make checks

- name: Integration Tests
run: make integration-tests-dvp-dlog
run: make integration-tests-tcc-dvp-fabtoken
1 change: 1 addition & 0 deletions .github/workflows/tccfabtoken.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jobs:
runs-on: ubuntu-latest
env:
GOPATH: ${{ github.workspace }}
GOFLAGS: -mod=mod
defaults:
run:
working-directory: ${{ env.GOPATH }}/src/github.com/hyperledger-labs/fabric-token-sdk
Expand Down
31 changes: 13 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,6 @@ dependencies:
go get -u github.com/gordonklaus/ineffassign
go get -u github.com/google/addlicense

.PHONY: integration-tests
integration-tests: docker-images dependencies
cd ./integration/token/dvp/dlog; ginkgo -keepGoing --slowSpecThreshold 60 .
cd ./integration/token/dvp/fabtoken; ginkgo -keepGoing --slowSpecThreshold 60 .
cd ./integration/token/tcc/basic/dlog; ginkgo -keepGoing --slowSpecThreshold 60 .
cd ./integration/token/tcc/basic/fabtoken; ginkgo -keepGoing --slowSpecThreshold 60 .

.PHONY: integration-tests-dvp-dlog
integration-tests-dvp-dlog: docker-images dependencies
cd ./integration/token/dvp/dlog; ginkgo -keepGoing --slowSpecThreshold 60 .

.PHONY: integration-tests-dvp-fabtoken
integration-tests-dvp-fabtoken: docker-images dependencies
cd ./integration/token/dvp/fabtoken; ginkgo -keepGoing --slowSpecThreshold 60 .

.PHONY: integration-tests-tcc-dlog
integration-tests-tcc-dlog: docker-images dependencies
cd ./integration/token/tcc/basic/dlog; ginkgo -keepGoing --slowSpecThreshold 60 .
Expand All @@ -70,6 +55,14 @@ integration-tests-tcc-dlog: docker-images dependencies
integration-tests-tcc-fabtoken: docker-images dependencies
cd ./integration/token/tcc/basic/fabtoken; ginkgo -keepGoing --slowSpecThreshold 60 .

.PHONY: integration-tests-tcc-dvp-fabtoken
integration-tests-tcc-dvp-fabtoken: docker-images dependencies
cd ./integration/token/tcc/dvp/fabtoken; ginkgo -keepGoing --slowSpecThreshold 60 .

.PHONY: integration-tests-tcc-dvp-dlog
integration-tests-tcc-dvp-dlog: docker-images dependencies
cd ./integration/token/tcc/dvp/dlog; ginkgo -keepGoing --slowSpecThreshold 60 .

.PHONY: tidy
tidy:
@go mod tidy
Expand All @@ -78,11 +71,13 @@ tidy:
clean:
docker network prune -f
docker container prune -f
rm -rf ./integration/token/dvp/dlog/cmd
rm -rf ./integration/token/dvp/fabtoken/cmd
rm -rf ./integration/token/tcc/basic/dlog/cmd/
rm -rf ./integration/token/tcc/basic/fabtoken/cmd/
rm -rf ./integration/token/tcc/dvp/dlog/cmd/
rm -rf ./integration/token/tcc/dvp/fabtoken/cmd/
rm -rf ./samples/fabric/fungible/cmd
rm -rf ./samples/fabric/dvp/cmd

.PHONY: tokengen
tokengen:
@go install github.com/hyperledger-labs/fabric-token-sdk/cmd/tokengen
@go install ./cmd/tokengen
36 changes: 8 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ token-based distributed application on Hyperledger Fabric.
# Useful Links

- [`Documentation`](./docs/design.md): Discover the design principles of the Fabric Token SDK.
- [`Examples`](./integration/README.md): Learn how to use the Fabric Smart Client via examples. There is nothing better than this.
- [`Samples`](./samples/README.md): A collection of sample applications that demonstrate the use of the Fabric Token SDK.
- `Feedback`: Your help is the key to the success of the Fabric Token SDK.
- Submit your issues [`here`][`fabric-token-sdk` Issues].
- If you have any questions, queries or comments, find us on [GitHub discussions].
Expand All @@ -24,6 +24,11 @@ token-based distributed application on Hyperledger Fabric.
The project will be subject to rapid changes to complete the open-sourcing process, and
the list of features.

# Getting Help

Found a bug? Need help to fix an issue? You have a great idea for a new feature? Talk to us! You can reach us on
[Discord](https://discord.gg/hyperledger) in #fabric-token-sdk.

# Motivation

[Hyperledger Fabric]('https://www.hyperledger.org/use/fabric') is a permissioned, modular, and extensible open-source DLT platform. Fabric architecture follows a novel `execute-order-validate` paradigm that supports distributed execution of untrusted code in an untrusted environment. Indeed, Fabric-based distributed applications can be written in any general-purpose programming language.
Expand All @@ -44,38 +49,13 @@ What would happen if the developers could use a `Fabric Token SDK` that let:

Developing Enterprise Token-based distributed applications would become simpler and more secure.

# Use the Fabric Token SDK

## Install

The `Fabric Token SDK` can be downloaded using `go get` as follows:
```
go get github.com/hyperledger-labs/fabric-token-sdk
```

The above command clones the repo under `$GOPATH/github.com/hyperledger-labs/fabric-token-sdk`.

We recommend to use `go 1.16`. We are testing the Token SDK also against more recent versions of the go-sdk to make sure the Token SDK works properly.

## Makefile

The Token SDK is equipped with a `Makefile` to simplify some tasks.
Here is the list of commands available.

- `make checks`: check code formatting, style, and licence header.
- `make unit-tests`: execute the unit-tests.
- `make integration-tests`: execute the integration tests. The integration tests use `ginkgo`. Please, make sure that `$GOPATH/bin` is in your `PATH` env variable.
- `make clean`: clean the docker environment, useful for testing.

Executes the above from `$GOPATH/github.com/hyperledger-labs/fabric-token-sdk`.

## Testing Philosophy
# Testing Philosophy

[Write tests. Not too many. Mostly Integration](https://kentcdodds.com/blog/write-tests)

We also believe that when developing new functions running tests is preferable than running the application to verify the code is working as expected.

## Versioning
# Versioning

We use [`SemVer`](https://semver.org/) for versioning. For the versions available, see the [`tags on this repository`](https://github.com/hyperledger-labs/fabric-token-sdk/tags).

Expand Down
23 changes: 13 additions & 10 deletions docs/design.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
# The Fabric Token SDK

The scope of the `Fabric Token SDK` is to deliver a set of API and services that let developers create token-based
The scope of the `Fabric Token SDK` is to deliver a set of `APIs` and `services` that let developers create token-based
distributed applications on Hyperledger Fabric.
The `Fabric Token SDK` has the following characteristics;
- It adopts the `UTXO model`. In the UTXO model, a direct acyclic graph reflects the movements of the assets.
Nodes are token transactions. Edges are transaction outputs. Each new token transaction consumes some the
UTXOs and create new ones.
- Key-Management via `Wallets`. A Wallet contains a set of `secret keys` and keep track of the list of unspent outputs `owned` those keys.
- Key-Management via `Wallets`. A Wallet contains a set of `secret keys` and keep track of the list of unspent outputs `owned` by those keys.
- It supports `multplie privacy levels`: from a `plain` instantiation, where everything is in the clear on the ledger,
to `Zero Knowledge-based` instantiations that will obfuscate the content of ledger while enforcing the required invariants.
to `Zero Knowledge-based` instantiations that will obfuscate the content of ledger while enforcing the required invariants
(see [drivers](./drivers.md) for more information).
- It allows the developers to write their own `services` on top of the Token SDK to deliver customised components
for their token-based applications.
for token-based applications.

## The Token SDK Stack

Expand All @@ -20,12 +21,14 @@ This is the Fabric Token SDK stack:

It consists of the following layers (from the top):
- `Services` (light-blue boxes): Services offer pre-packaged token-related functionalities,
like `Token Transaction` assembling, `Token Selectors`, and so on.
like `Token Transaction` assembling for a given backend, `Token Selectors` of unspent tokens, and so on.
They are built of top of the `Token API` abstraction. Therefore, they are independent of the underlying token technology.
- `Token API`: This API offers a useful abstraction to deal with tokens in an implementation and blockchain independent way.
- `Driver API`: This API takes the burden of translating calls to the Token API into API calls that are implementation-specific.
- `Driver Implementations`: This is the lowest level of the Token SDK. A driver implementation is responsible for
defining the representation of tokens on the ledger, what it means to perform certain token actions,
- [`Token API`](./token-api.md): This API offers a useful abstraction to deal with tokens in an implementation and blockchain independent way.
Tokens and the related operations are represented in a meta-language that it is then translated into a given backend (Fabric, etc...).
- [`Driver API`](./driver-api.md): This API takes the burden of translating calls to the Token API into API calls that are token implementation-specific.
Indeed, a transfer operation with privacy via Zero Knowledge is not the same as a transfer operation with privacy via plain instantiation.
- [`Driver Implementations`](./drivers.md): This is the lowest level of the Token SDK. A driver implementation is responsible for
defining the representation of tokens, what it means to perform certain token operations,
and when a token transaction is valid, among other things.

The `Fabric Token SDK` is built on top of the `Fabric Smart Client` stack.
Expand All @@ -40,7 +43,7 @@ Le us explore in more details each layer of the Token SDK stack.
- [`Driver API`](./driver-api.md): The Driver API defines the contracts any implementation should respect to
be compatible with the Token API.
- [`Driver Implementations`](./drivers.md): The Token SDK comes equipped with two driver implementations:
- [`FabToken`](./fabtoken.md): This is a simple implementation of the Driver API that does not support privacy.
- [`FabToken`](./fabtoken.md): This is a simple implementation of the Driver API that does not support any privacy.
- [`ZKAT DLog`](./zkat-dlog.md): This driver supports privacy via Zero Knowledge. We follow
a simplified version of the blueprint described in the paper
[`Privacy-preserving auditable token payments in a permissioned blockchain system`]('https://eprint.iacr.org/2019/1058.pdf')
Expand Down
1 change: 0 additions & 1 deletion docs/services.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ using the utility [`tokengen`](./../cmd/tokengen/README.md).
Once initialized, the token chaincode can provide the following functionalities:
- `Fetch the public parameters`. They must be fetched by each FSC node running the Token SDK stack.
This is done automatically.
- `Register issuers and auditors`. Indeed, only certain parties can issue tokens and audit token operations.
- `Fetch Tokens` is used to retrieve the content of tokens by their ids.
- `Validate and Translate Token Requests`. This is one of the essential steps in the lifecycle of a token transaction,
as we have seen in the previous section.
11 changes: 8 additions & 3 deletions docs/token-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,16 @@ A token consists of the following triplet:
- `Type`: The *denomination* of the token;
This is a string whose value can be application specific. Examples are:
The denomination of a digital currency or unique identifiers.
- `Quantity`: The amount stored by this token. It is a positive number
- `Quantity`: The amount stored by this token. It is a positive number, larger or equal to zero,
encoded as a string containing a number in base 16. The string starts with the prefix `0x`.

These tokens are `fungible` with the respect to the same type. In particular,
tokens with the same denomination can be merged and split, if not otherwise forbidden.
These tokens are `fungible` with the respect to the same type.
In particular, tokens with the same denomination can be merged and split, if not otherwise forbidden.

It looks like that the above definition allows the developers to define non-fungible tokens as well.
A non-fungible token is a token whose quantity is `1` and whose type is `unique`.
If uniqueness is guaranteed, then such a token is by all means a non-fungible token.
Drivers are free to implement additional semantics for non-fungible tokens.

A token can be spent only by the `rightful owner`. This concept is implementation dependant. For example,
if the `Owner` field contains a public-key, then a valid signature under that public key must be presented to spend the token.
Expand Down
24 changes: 15 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,31 @@ replace (
)

require (
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751
github.com/consensys/gurvy v0.3.9-0.20210209011448-37644c45f955
github.com/IBM/idemix v0.0.0-20220113150823-80dd4cb2d74e
github.com/IBM/mathlib v0.0.0-20220112091634-0a7378db6912
github.com/containerd/containerd v1.5.5 // indirect
github.com/dgraph-io/badger/v3 v3.2011.1
github.com/dgraph-io/badger/v3 v3.2103.2
github.com/golang/protobuf v1.5.2
github.com/hyperledger-labs/fabric-smart-client v0.0.0-20210920075720-7686bab12fc3
github.com/hyperledger/fabric v1.4.0-rc1.0.20210722174351-9815a7a8f0f7
github.com/hyperledger/fabric-amcl v0.0.0-20200424173818-327c9e2cf77a
github.com/hashicorp/go-uuid v1.0.2
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/hyperledger-labs/fabric-smart-client v0.0.0-20220302104532-f1f2fa782bea
github.com/hyperledger/fabric v1.4.0-rc1.0.20220128025611-fad7f691a967
github.com/hyperledger/fabric-chaincode-go v0.0.0-20210718160520-38d29fabecb9
github.com/hyperledger/fabric-protos-go v0.0.0-20210911123859-041d13f0980c
github.com/json-iterator/go v1.1.10
github.com/libp2p/go-libp2p-core v0.3.0
github.com/maxbrunsfeld/counterfeiter/v6 v6.3.0
github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6 // indirect
github.com/onsi/ginkgo v1.16.4
github.com/onsi/gomega v1.10.3
github.com/onsi/ginkgo v1.16.5
github.com/onsi/gomega v1.16.0
github.com/pkg/errors v0.9.1
github.com/spf13/cobra v1.1.1
github.com/spf13/viper v1.7.0
github.com/stretchr/testify v1.7.0
github.com/stretchr/testify v1.7.1-0.20210116013205-6990a05d54c2
github.com/tedsuo/ifrit v0.0.0-20191009134036-9a97d0632f00
github.com/thedevsaddam/gojsonq v2.3.0+incompatible
go.uber.org/atomic v1.7.0
go.uber.org/zap v1.16.0
golang.org/x/sys v0.0.0-20220307203707-22a9840ba4d7 // indirect
gopkg.in/yaml.v2 v2.4.0
)
Loading

0 comments on commit 999f5d2

Please sign in to comment.