Giter Site home page Giter Site logo

iroha-java's Introduction

Iroha2 Java

Iroha2-java-dev ci passed

The repository contains the client library of Hyperledger Iroha2 written in Kotlin. This includes:

  • client to work with Iroha2 API
  • admin-client with Iroha2Client extension
  • codegen to generate models into model by Iroha2 schema
  • model with models generated by codegen
  • block with genesis classes and some generated serializers and deserializers for data models
  • test-tools to create tests for Iroha2

Iroha version

Docker image: hyperledger/iroha2:lts@sha256:4b61b866e15039989e689e3403986ebb207628c36d956d2dc99078e19764e212

Get Started

Check out Hyperledger Iroha2 Tutorial that introduces you to Iroha2 concepts and features and also provides you with a step-by-step guide for Kotlin/Java.

Usage

allprojects {
    repositories {
        maven { url 'https://jitpack.io' }
    }
}

dependencies {
    api 'com.github.hyperledger.iroha-java:client:iroha2-dev-SNAPSHOT'
    api 'com.github.hyperledger.iroha-java:model:iroha2-dev-SNAPSHOT'
    api 'com.github.hyperledger.iroha-java:block:iroha2-dev-SNAPSHOT'
    api 'com.github.hyperledger.iroha-java:test-tools:iroha2-dev-SNAPSHOT'
}

To get specific javadoc/lib version(s), refer to JitPack features.

If you have any questions

Please contact the community to get answers as soon as possible.

iroha-java's People

Contributors

alexey-n-chernyshov avatar alexstroke avatar arndey avatar bastos525 avatar gv-timur avatar jwagantall avatar maglighter avatar mingela avatar mversic avatar outoftardis avatar rkharisov avatar wpi86 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

iroha-java's Issues

Implement generic JSON serialization of genesis

We need to serialize genesis to json to specify initial state if the Iroha2 testcontainer. But serialization to JSON rust aware structures is tricky due there are structures with unnamed properties and they require special treat. Need to implement generic way to serialize such structures instead of specifying custom serializer for every such struct

Android build error with fresh project and latest version 7.1.0

With a fresh project from Android Studio and the following build.gradle I get this when building the app.

> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Failed to transform client-7.1.0.jar (com.github.hyperledger.iroha-java:client:7.1.0) to match attributes {artifactType=android-dex, asm-transformed-variant=NONE, dexing-enable-desugaring=true, dexing-incremental-transform=true, dexing-is-debuggable=true, dexing-min-sdk=21, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime}.
      > Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
         > No variants of io.grpc:protoc-gen-grpc-java:1.33.1 match the consumer attributes:
             - io.grpc:protoc-gen-grpc-java:1.33.1:
                 - Incompatible because this component declares attribute 'artifactType' with value 'pom' and the consumer needed attribute 'artifactType' with value 'android-classes-jar'
                 - Other compatible attributes:
                     - Doesn't say anything about asm-transformed-variant (required 'NONE')
                     - Doesn't say anything about dexing-enable-desugaring (required 'true')
                     - Doesn't say anything about dexing-incremental-transform (required 'true')
                     - Doesn't say anything about dexing-is-debuggable (required 'true')
                     - Doesn't say anything about dexing-min-sdk (required '21')

Thanks for any help

Implement own scale codec

Currently we use third-party library for that, but it has drawbacks

  • it not fully fit our necessities and doesn't natively support all required types
  • it can be downloaded only from bintray and it will be closed soon

Support expression evaluation for instructions

Iroha2 allows to send it expressions that can be evaluated in some value with static type. Need to support this feature un SDK. For example, if some method accepts EvaluatesTo, it can be combined expressions that eventually can be evaluated as Bool type

Tutorial expansion with Kotlin SDK samples

Notion link provided privately

Tutorial should be supplemented with:

  • How to install/add dependency
  • Any uncommon for a Java/Kotlin project general development experience stuff highlighted
  • How to Generate/Parse Iroha node config
  • Following of the existing scenarios, providing implementation with comments
    Additionally the repository readme files should become relevant (per module description etc)

Redesign the integer type representation in SDK

Iroha2 model operates with unsigned types U8-U256. Currently in the SDK they are represented as Kotlin experimental unsigned types. It has a drawbacks

  • multiple conversions to signed type and back during encoding/decoding
  • it is experimental feature so not reliable
  • Java interop issues

Need to design and implement way to represent them as traditional Kotlin signed integers

Fix broken `iroha2-dev` branch

Iroha2 docker images was not created for a while, therefore iroha2 sdk is not up to date. Need to regenerate schema and fix all tests

Implement upstream generating of data model in case schema was updated

Currently we need to track if schema was updated and manually download schema and regenerated models. It will be very convenient if it can be done automatically. How I see this

Possible flow:

  • merge in iroha2 repository to branch iroha2-dev branch triggers action in iroha2-java repository
  • action downloads schema.json artifact and compare hash of the downloaded artifact with previous one
  • if the hash is the same that means schema was not changed and nothing need to do
  • if it is different then action replace existing schema in repository and create pull request.
  • action updates schema version. This is final step for this action
  • in PR another action generates schema and run tests

master-SNAPSHOT is not available

This is what I get when compiling a project that depends on master-SNAPSHOT of iroha-java:

Could not find artifact com.github.hyperledger:iroha-java:jar:master-219d32262a-1 in jitpack.io (https://jitpack.io)

I suspect this is the result of the failed build of the last commit (219d322).

Implement conversion from decimal to fixed point

Iroha2 supports assets with type AssetValueType::Fixed. It allows to have assets with non-integer amount. Client needs to convert from decimal to integer with base i64 and 9 decimal places. Details of implementation can be found in rust's crate fixnum

Update permissions and other improvments

Also:

  • Investigate jitpack build error
  • Investigate genesis role error
  • Use iroha2 image with version
  • Add to Instructions possibility to create peer instruction
  • Add healthcheck
  • Move serializers to other module
  • Add deserializers for Genesis

Won't compile

I don't usually use Java, so I might be just stupid.
It doesn't compile, so I leave a issue here. I use debian.
Please help me.

1)Adding compile "com.github.hyperledger.iroha-java:client:master-SNAPSHOT" to my build.gradle does not work. Isn't compile outdated?

So, I decided to build jar file.

  1. "task wrapper(..." made error, so I changed it to "task". Now, there is no error about it.

3)gradle build did not build it. Here is an output of gradle :
out.txt

Derive returned type based on QueryRequest

Currently we have method query in Iroha2Client. It accepts two arguments

  • ResultExtractor - resolve "actual" payload from QueryResult
  • QueryRequest - request with query details need to send to peer

Need to avoid providing ResultExtractor due it types depends on type of query request

use .jar in xamarin

Is it possible to use this client with binding library on xamarin android project ?

Transaction wrong status

We've written a simple test script for our app on iroha-java(link)

But when we send a transaction, observer shows us that transaction status NOT_RECEIVED and transaction is COMPLETE. However, the transaction actually is COMMITTED correctly and everything works (we checked it using queries).

image

In the picture above, you can see how "state" of the chain is changed, but the observers show us that all transactions are not received.

You can try to test it by pulling our project
Link to script to run provided above.

Error on querying: 'query signatories did not pass validation'

I have the following code that adds some asset quantity to a user, transfers some of it to another user and then queries their asset balances:

public class App {
  private static final Ed25519Sha3 crypto = new Ed25519Sha3();

  private static int getAccountBalance(IrohaAPI api, String user, KeyPair userKeypair, String asset) {
    QueryAPI qapi = new QueryAPI(api, user, userKeypair);

    List<AccountAsset> assets = qapi.getAccountAssets(user, 1, asset)
        .getAccountAssetsList();

    Optional<AccountAsset> assetOptional = assets.stream()
        .filter(a -> a.getAssetId().equals(asset))
        .findFirst();

    return assetOptional.map(a -> Integer.parseInt(a.getBalance()))
        .orElse(0);
  }

  public static void main(String[] args) {
    String adminPriv = "", adminPub = "", testPriv = "", testPub = "";
    try {
      adminPriv= new String(Files.readAllBytes(
          Paths.get("/home/george/Misc/iroha/example/[email protected]")
      ));
      adminPub= new String(Files.readAllBytes(
          Paths.get("/home/george/Misc/iroha/example/[email protected]")
      ));

      testPriv= new String(Files.readAllBytes(
          Paths.get("/home/george/Misc/iroha/example/[email protected]")
      ));
      testPub= new String(Files.readAllBytes(
          Paths.get("/home/george/Misc/iroha/example/[email protected]")
      ));
    } catch (IOException err) {
      System.err.println("Failed reading keys: " + err.getMessage());
      System.exit(-1);
    }

    KeyPair adminKeypair = Ed25519Sha3.keyPairFromBytes(
        parseHexBinary(adminPriv),
        parseHexBinary(adminPub)
    );

    KeyPair testKeypair = Ed25519Sha3.keyPairFromBytes(
        parseHexBinary(testPriv),
        parseHexBinary(testPub)
    );

    TransactionOuterClass.Transaction tx = Transaction.builder("admin@test")
        .addAssetQuantity("coin#test", "100.00")
        .transferAsset(
            "admin@test",
            "test@test",
            "coin#test",
            "Reason",
            "50.00"
        )
        .sign(adminKeypair)
        .build();

    TransactionStatusObserver txObserver = TransactionStatusObserver.builder()
        .onTransactionFailed(ftx -> System.out.println(String.format(
                "Transaction %s failed: %s",
                ftx.getTxHash(),
                ftx.getErrOrCmdName()
            ))
        )
        .onError(err -> System.out.println("Failed: " + err))
        .onTransactionCommitted(ctx -> {
            System.out.println(ctx.getTxHash());
            System.out.println("Committed");
        })
        .onComplete(() -> System.out.println("Completed"))
        .build();

    IrohaAPI api = new IrohaAPI("0.0.0.0", 50051);

    api.transaction(tx)
        .blockingSubscribe(txObserver);

    int adminBalance = getAccountBalance(api, "admin@test", adminKeypair, "coin#test");
    int testBalance = getAccountBalance(api, "test@test", testKeypair, "coin#test");
    System.out.println(Integer.toString(adminBalance));
    System.out.println(Integer.toString(testBalance));
  }
}

As you can see from the code, I'm using the default configuration files together with the latest master branch version of Iroha, which I start in the following way:

 build/bin/irohad --config example/config.sample --genesis_block example/genesis.block --keypair_name example/node0 --overwrite_ledger

At the moment I have a hard time figuring out why the queries fail validation. The initial transaction for creating and transferring the asset succeeds and I've also tried to use the Python bindings on similar code and I had no problems with that.

Travis CI is no longer supported

Travis CI has changed how open source projects are supported, and Hyperledger can no longer build there. I suggest Azure Pipelines or GitHub Actions as a replacement.

Documentation

Lack of documentation and examples: e.g atomic batch is not properly explained. It is hard to understand how to use it. Will there be extensions of documentation in the near future?

Restrict execution race during subscribing/sending transaction

Currently to receive final status of transaction we subscribe to it status first and then send the transaction to peer. But due each action is executed async it is possible transaction will be send before subscription is established and therefore client miss status of the transaction. Need to allow send transaction only when subscription is established

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.