Giter Site home page Giter Site logo

aergoio / heraj Goto Github PK

View Code? Open in Web Editor NEW
22.0 10.0 7.0 11.12 MB

Java client framework for aergo

Home Page: https://heraj-docs.aergo.io

License: MIT License

Ruby 0.10% HTML 0.33% CSS 0.62% JavaScript 0.06% Shell 0.80% Java 97.79% Lua 0.28%
aergo java client

heraj's Introduction

heraj - Java client framework for aergo

MIT License LoC github build codecov.io

The hera is the client-side framework for the aergo. This repository, heraj is java implementation for hera.

Latest

v1.4.2

build with aergo-protobuf 6ce439c7600ae7b167c6c61e66ce2ac38bb2bef9

Compatibility

  • Aergo : v2.2.x
  • Java : JDK 8 or higher
  • Android : Android 3.0 (API 11) or higher

Download

There are 3 kind of library:

  • heraj-transport : minimum library including all of the base
  • heraj-wallet : nonce handling wallet library (depends on heraj-transport)
  • heraj-smart-contract : simple client to call smart contract with a java interface (depends on heraj-wallet)

If you just want a minimum one, use heraj-transport. Or need more feature, use heraj-wallet or heraj-smart-contract.

Module Structure

  • core
    • annotation : Store annotations used within heraj.
    • common : Store models used within heraj.
    • protobuf : Keeps java files generated from *.proto.
    • transport : Transport module interacting with aergo node using grpc.
    • util : Utils used within heraj.
  • client
    • wallet : Provides KeyStore to store aergo key. Provides WalletApi to interacting with KeyStore.
    • smart-contract : Modules for interface-based smart contract interaction.

Maven

...

<dependencies>
  <dependency>
    <groupId>io.aergo</groupId>
    <artifactId>heraj-transport</artifactId>
    <version>${herajVersion}</version>
  </dependency>
  <dependency>
    <groupId>io.aergo</groupId>
    <artifactId>heraj-wallet</artifactId>
    <version>${herajVersion}</version>
  </dependency>
  <dependency>
    <groupId>io.aergo</groupId>
    <artifactId>heraj-smart-contract</artifactId>
    <version>${herajVersion}</version>
  </dependency>
</dependencies>

Gradle

...

dependencies {
  implementation "io.aergo:heraj-transport:${herajVersion}"
  implementation "io.aergo:heraj-wallet:${herajVersion}"
  implementation "io.aergo:heraj-smart-contract:${herajVersion}"
}

Build from source

Prerequisites

Clone

$ git clone --recurse-submodule https://github.com/aergoio/heraj.git

Submodule

Initialize submodule (if not initialized)

$ git submodule init

Update submodule

$ git submodule update

Build

  • Clean: ./gradlew clean
  • Generate protobuf based files: ./gradlew :core:protobuf:build
  • Lint: ./gradlew lint
  • Test: ./gradlew test
    • Coverage (need test task): ./gradlew test coverage (individual), ./gradlew test allcoverage (all)
    • Integration Test: ./test/run-it.sh (need docker running)
    • Benchmark Test: ./gradlew {target_project}:jmh
  • Docs: ./gradlew javadoc (individual), ./gradlew alljavadoc (all)
  • Build (also lint, test): ./gradlew build
  • Shadow Jar: ./gradlew shadowJar (generated in ./assembly/build/libs)
  • Install to local: ./gradlew publishToMavenLocal

Kind of test

Unit test

They are classes with 'Test' suffix.

Integration test

They are classes with 'IT' suffix meaning integration test.

Benchmark test

They are classes with 'Benchmark' suffix, which using jmh.

Contribution

Guidelines for any code contributions:

  1. Any changes should be accompanied by tests. It's guaranteed by travis ci.
  2. Code coverage should be maintained. Any requests dropping down code coverage significantly will be not confirmed.
  3. All contributions must be licensed MIT and all files must have a copy of statement indicating where license is (can be copied from an existing file).
  4. All java files should be formatted according to Google's Java style guide. You can use checkstyle plugin for eclipse or IntelliJ. And you can check by running ./gradlew lint
  5. Please squash all commits for a change into a single commit (this can be done using git rebase -i). Make sure to have a meaningful commit message for the change.

heraj's People

Contributors

acktsap avatar bylee avatar graup avatar hayarobi avatar yoonjoojang avatar

Stargazers

 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

heraj's Issues

can's save() in AergoKeyStore

Can't save an aergoKey in file based keystore (class hera.keystore.AergoKeyStore) if that identity is not in keystore directory.
It looks like a bug, since In-memory keystore operates exactly the opposite.

disconnection with GOAWAY message when long idle

If heard client is idle so that only sends a keepalive pings to the server, the server send back the following message, and close connection in some times;
Received GOAWAY with ENHANCE_YOUR_CALM. Debug data: {}

According to the related information, there are two main causes, and both seem to be caused by the mismatch between the server and the client's grpc settings.
https://grpc.github.io/grpc/core/md_doc_keepalive.html

Currently, the server is using the default connection setting, so GRPC_ARG_KEEPALIVE_PERMIT_WITHOUT_CALLS is false, GRPC_ARG_HTTP2_MIN_RECV_PING_INTERVAL_WITHOUT_DATA_MS is 300 seconds, but the heraj's GRPC settings are true and 300 seconds.
Even if GRPC_ARG_KEEPALIVE_TIME_MS time is set to be greater than 300 seconds, a problem still occurs due to the GRPC_ARG_KEEPALIVE_PERMIT_WITHOUT_CALLS setting value.

It is not yet clear whether this problem is the cause of the intermittent 'io.grpc.StatusRuntimeException:UNAVAILABLE:' error.

==================

클라이언트가 아이들 상태가 지속이 되어서 서버에 keepalive 핑만 보내다보면, 서버는 아래와 같은 메시지를 보내고나서 접속을 끊음
Received GOAWAY with ENHANCE_YOUR_CALM. Debug data: {}

관련 내용을 조사해보면 원인이 크게 두 가지 나오는데, 두 가지 모두 서버와 클라이언트의 grpc설정이 안 맞아서 발생하는 것으로 보임.
https://grpc.github.io/grpc/core/md_doc_keepalive.html

현재 서버는 기본 접속 설정을 사용하고 있어서 GRPC_ARG_KEEPALIVE_PERMIT_WITHOUT_CALLS는 false이고 GRPC_ARG_HTTP2_MIN_RECV_PING_INTERVAL_WITHOUT_DATA_MS 는 300초인데, heraj의 커넥션은 이것에 대응하는 설정이 GRPC_ARG_KEEPALIVE_PERMIT_WITHOUT_CALLS는 true이고 GRPC_ARG_KEEPALIVE_TIME_MS는 서버와 동일한 300초로 하드코딩이 되어있음.
테스트로 GRPC_ARG_KEEPALIVE_TIME_MS 시간을 300초보다 크게 잡아도 GRPC_ARG_KEEPALIVE_PERMIT_WITHOUT_CALLS 설정값 때문에 여전히 문제가 발생함.

이 문제가 간헐적인 io.grpc.StatusRuntimeException: UNAVAILABLE: 에러의 원인인지는 아직 명확하지 않음.

Wallet is too mixed one

Wallet should have a single role, but it extends too many interfaces. I think we have to split key managing with client.

It's hard to remove it in 1.x. Maybe it should be remove in 2.x. But until then, it's good to introduce fine-grained api for alternatives. And in 2.x, introduce new coarse-grained api as an alternative to current Wallet interface.

Fine-grained apis should have following roles

  • KeyManaging (abstraction for interaction with java keystore or server keystore)
  • Nonce handling
  • ChainIdHash handling
  • Failover handling

Before that, we have to refactor context to handle failover elegantly.

Need more test in nonce handling

Assume we commit 10 transaction with nonce 1 to 10.
What if transaction with nonce 3 fails?
Maybe following transaction using 4 to 10 would stay in mempool waiting for nonce 3 to be used.
Of course, this may be resolved if we request tx using nonce 3 successfully. But we need to handle those case in handling nonce.

Wallet unlock is always requesting state of unlocked one

I think it's not necessary feature. Wallet should be able to unlock on not connected state.

@Override
public boolean unlock(final Authentication authentication) {
try {
this.account = getKeyStore().unlock(authentication);
getCurrentAccount().bindState(getAccountState());
return true;
} catch (InvalidAuthentiationException e) {
return false;
} catch (Exception e) {
throw new WalletException(e);
}
}

Contract Definition/Execution to raw transaction

Currently, There is no way to make contract-related raw transaction without constructor. We need a way to make a such transaction just like

RawTransaction rawDeployTransaction = ContractDefinition.newBuilder()
    .encodedContract(contractPayload)
    .constructorArgs(deployKey, deployIntVal, deployStringVal)
    .build()
    .asTransaction(account, fee, nonce); 

Maybe we can combine such class with PayloadResolver which is in charge of resolving appropriate payload form corresponding with transaction type (eg. staking, contract deploying, etc)

Also we can expand those more to general transaction builder in charge of making all kind of transaction.

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.